1 ;;; muse-mode.el --- mode for editing Muse files; has font-lock support
3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
5 ;; This file is part of Emacs Muse. It is not part of GNU Emacs.
7 ;; Emacs Muse is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 2, or (at your
10 ;; option) any later version.
12 ;; Emacs Muse is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with Emacs Muse; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
24 ;; The Emacs Muse major mode is basically a hyped-up text-mode which
25 ;; knows a lot more about the apparent structure of the document.
29 ;; Andrea Riciputi (ariciputi AT pito DOT com) gave an initial
30 ;; implementation for tag completion by means of the `muse-insert-tag'
33 ;; Per B. Sederberg (per AT med DOT upenn DOT edu) contributed the
34 ;; insertion of relative links and list items, backlink searching, and
35 ;; other things as well.
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 ;; Emacs Muse Major Mode
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (require 'muse-regexps
)
47 (require 'muse-project
)
49 (autoload 'muse-use-font-lock
"muse-colors")
50 (autoload 'muse-publish-this-file
"muse-publish")
51 (autoload 'muse-publish-get-style
"muse-publish")
52 (autoload 'muse-publish-output-file
"muse-publish")
57 (require 'pcomplete
) ; load if available
62 (defgroup muse-mode nil
63 "Options controlling the behavior of the Muse editing Mode."
66 (defcustom muse-mode-highlight-p t
67 "If non-nil, highlight the content of Muse buffers."
72 (defcustom muse-mode-auto-p nil
73 "If non-nil, automagically determine when Muse mode should be activated."
78 (add-hook 'find-file-hooks
'muse-mode-maybe
)
79 (remove-hook 'find-file-hooks
'muse-mode-maybe
))
83 (defun muse-mode-maybe-after-init ()
84 (when muse-mode-auto-p
85 (add-hook 'find-file-hooks
'muse-mode-maybe
)))
87 ;; If the user sets this value in their init file, make sure that
89 (add-hook 'after-init-hook
'muse-mode-maybe-after-init
)
91 (defcustom muse-mode-intangible-links nil
92 "If non-nil, use the intangible property on links.
93 This can cause problems with flyspell (and potentially fill-mode),
94 so only enable this if you don't use either of these."
98 (defcustom muse-mode-hook nil
99 "A hook that is run when Muse mode is entered."
101 :options
'(flyspell-mode footnote-mode turn-on-auto-fill
102 highlight-changes-mode
)
105 (defcustom muse-grep-command
106 "find %D -type f ! -name '*~' | xargs -I {} echo \\\"{}\\\" | xargs egrep -n -e \"%W\""
107 "The command to use when grepping for backlinks and other
108 searches through the muse projects. The string %D is replaced by
109 the directories from muse-project-alist, space-separated. The
110 string %W is replaced with the name of the muse page or whatever
111 else you are searching for. This command has been modified to
112 handle spaces in filenames, which were giving egrep a problem.
114 Note: We highly recommend using glimpse to search large projects.
115 To use glimpse, install and edit a file called .glimpse_exclude
116 in your home directory. Put a list of glob patterns in that file
117 to exclude Emacs backup files, etc. Then, run the indexer using:
119 glimpseindex -o <list of Wiki directories>
121 Once that's completed, customize this variable to have the
126 Your searches will go much, much faster, especially for very
127 large projects. Don't forget to add a user cronjob to update the
132 (defvar muse-insert-map
133 (let ((map (make-sparse-keymap)))
134 (define-key map
"l" 'muse-insert-relative-link-to-file
)
135 (define-key map
"t" 'muse-insert-tag
)
139 (defvar muse-mode-map
140 (let ((map (make-sparse-keymap)))
141 (define-key map
[(control ?c
) (control ?a
)] 'muse-index
)
142 (define-key map
[(control ?c
) (control ?c
)] 'muse-follow-name-at-point
)
143 (define-key map
[(control ?c
) (control ?e
)] 'muse-edit-link-at-point
)
144 (define-key map
[(control ?c
) (control ?l
)] 'font-lock-mode
)
145 (define-key map
[(control ?c
) (control ?t
)] 'muse-publish-this-file
)
146 (define-key map
[(control ?c
) (control ?v
)] 'muse-browse-result
)
148 (define-key map
[(control ?c
) ?
=] 'muse-what-changed
)
150 (define-key map
[tab] 'muse-next-reference)
151 (define-key map [(control ?i)] 'muse-next-reference)
153 (if (featurep 'xemacs)
155 (define-key map [(button2)] 'muse-follow-name-at-mouse)
156 (define-key map [(shift button2)]
157 'muse-follow-name-at-mouse-other-window))
158 (define-key map [(shift control ?m)]
159 'muse-follow-name-at-point-other-window)
160 (define-key map [mouse-2] 'muse-follow-name-at-mouse)
161 (define-key map [(shift mouse-2)]
162 'muse-follow-name-at-mouse-other-window))
164 (define-key map [(shift tab)] 'muse-previous-reference)
165 (unless (featurep 'xemacs)
166 (define-key map [(shift iso-lefttab)] 'muse-previous-reference)
167 (define-key map [(shift control ?i)] 'muse-previous-reference))
169 (define-key map [(control ?c) (control ?f)] 'muse-project-find-file)
170 (define-key map [(control ?c) (control ?p)] 'muse-project-publish)
172 (define-key map [(control ?c) tab] 'muse-insert-tag)
173 (define-key map [(control ?c) (?i)] 'muse-insert-thing)
175 ;; Searching functions
176 (define-key map [(control ?c) (control ?b)] 'muse-find-backlinks)
177 (define-key map [(control ?c) (control ?s)] 'muse-search)
179 ;; Enhanced list functions
180 (define-key map [(meta return)] 'muse-insert-list-item)
181 (define-key map [(control ?>)] 'muse-increase-list-item-indentation)
182 (define-key map [(control ?<)] 'muse-decrease-list-item-indentation)
184 (when (featurep 'pcomplete)
185 (define-key map [(meta tab)] 'pcomplete)
186 (define-key map [(meta control ?i)] 'pcomplete))
189 "Keymap used by Emacs Muse mode.")
194 (define-derived-mode muse-mode text-mode "Muse"
195 "Muse is an Emacs mode for authoring and publishing documents.
197 ;; Since we're not inheriting from normal-mode, we need to
198 ;; explicitly run file variables.
200 (hack-local-variables)
201 (error (message "File local-variables error: %s"
202 (prin1-to-string err))))
203 ;; Avoid lock-up caused by use of the 'intangible' text property
205 (unless muse-mode-intangible-links
206 (set (make-local-variable 'inhibit-point-motion-hooks) t))
207 (setq muse-current-project (muse-project-of-file))
208 (muse-project-set-variables)
209 ;; Make fill not split up links
210 (when (boundp 'fill-nobreak-predicate)
211 (make-local-variable 'fill-nobreak-predicate)
212 ;; Work around annoying inconsistency in fill handling between
214 (if (< emacs-major-version 22)
215 (setq fill-nobreak-predicate 'muse-mode-fill-nobreak-p)
216 (add-to-list 'fill-nobreak-predicate
217 'muse-mode-fill-nobreak-p)))
218 ;; Make fill work nicely with item lists
219 (set (make-local-variable 'adaptive-fill-regexp)
220 (concat "\\s-+\\(-\\|[0-9]+\\.\\)\\s-+\\|\\[[0-9]+\\]\\s-*"
221 "\\|\\s-*::\\s-*\\|\\s-*"))
222 (set (make-local-variable 'paragraph-start)
223 (concat paragraph-start "\\|\\s-+\\(-\\|[0-9]+\\.\\)\\s-+"
224 "\\|\\[[0-9]+\\]\\s-*\\|\\s-*::\\s-*"))
225 ;; Comment syntax is `; comment'
226 (set (make-local-variable 'comment-start)
228 (set (make-local-variable 'comment-start-skip)
230 ;; If we're using Emacs21, this makes flyspell work like it should
231 (when (boundp 'flyspell-generic-check-word-p)
232 (set (make-local-variable 'flyspell-generic-check-word-p)
233 'muse-mode-flyspell-p))
234 ;; If pcomplete is available, set it up
235 (when (featurep 'pcomplete)
236 (set (make-local-variable 'pcomplete-default-completion-function)
237 'muse-mode-completions)
238 (set (make-local-variable 'pcomplete-command-completion-function)
239 'muse-mode-completions)
240 (set (make-local-variable 'pcomplete-parse-arguments-function)
241 'muse-mode-current-word))
242 ;; Initialize any auto-generated variables
243 (run-hooks 'muse-update-values-hook)
244 (when muse-mode-highlight-p
245 (muse-use-font-lock)))
248 'flyspell-mode-predicate
249 'muse-mode-flyspell-p)
251 (defun muse-mode-fill-nobreak-p ()
252 "Return nil if we should allow a fill to occur at point.
253 Otherwise return non-nil.
255 This is used to keep long explicit links from being mangled by
259 (and (re-search-backward "\\[\\[\\|\\]\\]"
260 (line-beginning-position) t)
261 (string= (or (match-string 0) "")
264 (defun muse-mode-flyspell-p ()
265 "Return non-nil if we should allow spell-checking to occur at point.
266 Otherwise return nil.
268 This is used to keep links from being improperly colorized by flyspell."
269 (and (not (get-text-property (if (bobp) (point) (1- (point)))
272 (null (muse-link-at-point)))))
274 (defun muse-mode-choose-mode ()
275 "Turn the proper Emacs Muse related mode on for this file."
276 (let ((project (muse-project-of-file)))
277 (funcall (or (and project (muse-get-keyword :major-mode (cadr project) t))
280 (defun muse-mode-maybe ()
281 "Maybe turn Emacs Muse mode on for this file."
282 (let ((project (muse-project-of-file)))
284 (funcall (or (muse-get-keyword :major-mode (cadr project) t)
287 ;;; Enhanced list editing
289 (defun muse-on-blank-line ()
290 "See if point is on a blank line"
293 (looking-at (concat "[" muse-regexp-blank "]?[\n]+"))))
295 (defun muse-get-paragraph-start ()
296 "Return the start of the current paragraph. This function will
297 return nil if there are no prior paragraphs and the beginning of
298 the line if point is on a blank line."
299 (let ((para-start (concat "[\n]+[" muse-regexp-blank "]?[\n]+")))
300 ;; search back to start of paragraph
303 (if (not (muse-on-blank-line))
304 (re-search-backward para-start nil t)
305 (line-beginning-position))))))
307 (defun muse-insert-thing ()
308 "Prompt for something to insert into the current buffer."
310 (message "Insert:\nl link\nt tag")
312 (let ((overriding-local-map muse-insert-map))
313 (setq key (read-key-sequence nil)))
314 (if (commandp (setq cmd (lookup-key muse-insert-map key)))
316 (call-interactively cmd))
317 (message "Not inserting anything"))))
320 (defun muse-insert-list-item ()
321 "Insert a list item at the current point, taking into account
322 your current list type and indentation level."
324 (let ((newitem " - ")
326 (pstart (muse-get-paragraph-start))
327 (list-item (format muse-list-item-regexp
328 (concat "[" muse-regexp-blank "]*"))))
329 ;; search backwards for start of current item
331 (when (re-search-backward list-item pstart t)
332 ;; save the matching item
333 (setq newitem (match-string 0))
334 ;; see what type it is
335 (if (string-match "::" (match-string 0))
336 ;; is a definition, replace the term
337 (setq newitem (concat " "
338 (read-string "Term: ")
340 ;; see if it's a numbered list
341 (when (string-match "[0-9]+" newitem)
342 ;; is numbered, so increment
345 (match-string 0 newitem))))
346 (setq newitem (replace-match
347 (number-to-string itemno)
348 nil nil newitem))))))
349 ;; insert the new item
350 (insert (concat "\n" newitem))))
352 (defun muse-alter-list-item-indentation (operation)
353 "Alter the indentation of the current list item.
354 Valid values of OPERATION are 'increase and 'decrease."
355 (let ((pstart (muse-get-paragraph-start))
356 (list-item (format muse-list-item-regexp
357 (concat "[" muse-regexp-blank "]*")))
358 beg move-func indent)
359 ;; search backwards until start of paragraph to see if we are on a
362 (if (or (progn (goto-char (muse-line-beginning-position))
364 (looking-at list-item))
365 ;; not on item, so search backwards
366 (re-search-backward list-item pstart t))
369 (setq indent (buffer-substring (match-beginning 0)
370 (match-beginning 1)))
371 (muse-forward-list-item (muse-list-item-type (match-string 1))
372 (concat "[" muse-regexp-blank "]*")
375 (narrow-to-region beg (point))
376 (goto-char (point-min))
378 (while (< (point) (point-max))
379 ;; increase or decrease the indentation
381 (cond ((eq operation 'increase)
383 ((eq operation 'decrease)
385 ;; we have enough space, so delete it
386 (delete-region (match-beginning 0)
390 ;; we are not on an item, so warn
391 (message "You are not on a list item.")))))
394 (defun muse-increase-list-item-indentation ()
395 "Increase the indentation of the current list item."
397 (muse-alter-list-item-indentation 'increase))
400 (defun muse-decrease-list-item-indentation ()
401 "Decrease the indentation of the current list item."
403 (muse-alter-list-item-indentation 'decrease))
405 ;;; Support page name completion using pcomplete
407 (defun muse-mode-completions ()
408 "Return a list of possible completions names for this buffer."
409 (let ((project (muse-project-of-file)))
411 (while (pcomplete-here
412 (mapcar 'car (muse-project-file-alist project)))))))
414 (defun muse-mode-current-word ()
418 (skip-chars-backward (concat "^\\[\n" muse-regexp-blank))
419 (narrow-to-region (point) end))
420 (pcomplete-parse-buffer-arguments))))
422 ;;; Navigate/visit links or URLs. Use TAB, S-TAB and RET (or mouse-2).
424 (defun muse-link-at-point (&optional pos)
425 "Return link text if a URL or link is at point."
426 (let ((case-fold-search nil)
427 (inhibit-point-motion-hooks t)
428 (here (or pos (point))))
429 ;; if we are using muse-colors, we can just use link properties to
430 ;; determine whether we are on a link
431 (if (featurep 'muse-colors)
432 (when (get-text-property here 'muse-link)
434 (when (and (not (bobp))
435 (get-text-property (1- here) 'muse-link))
436 (goto-char (or (previous-single-property-change here 'muse-link)
438 (if (looking-at muse-explicit-link-regexp)
440 (goto-char (match-beginning 1))
441 (muse-handle-explicit-link))
442 (muse-handle-implicit-link))))
443 ;; use fallback method to find a link
445 (and (char-after pos)
446 (not (eq (char-syntax (char-after pos)) ?\ ))))
449 ;; check for explicit link here or before point
450 (if (or (looking-at muse-explicit-link-regexp)
452 (re-search-backward "\\[\\[\\|\\]\\]"
453 (muse-line-beginning-position)
455 (string= (or (match-string 0) "") "[[")
456 (looking-at muse-explicit-link-regexp)))
458 (goto-char (match-beginning 1))
459 (muse-handle-explicit-link))
461 ;; check for bare URL or other link type
462 (skip-chars-backward (concat "^'\"<>{}(\n" muse-regexp-blank))
463 (and (looking-at muse-implicit-link-regexp)
464 (muse-handle-implicit-link))))))))
466 (defun muse-make-link (link &optional desc)
467 "Return a link to LINK with DESC as the description."
468 (when (string-match muse-explicit-link-regexp link)
469 (unless desc (setq desc (muse-get-link-desc link)))
470 (setq link (muse-get-link link)))
473 (not (string= desc ""))
474 (not (string= link desc)))
475 (concat "[[" (muse-link-escape link) "][" (muse-link-escape desc) "]]")
476 (concat "[[" (muse-link-escape link) "]]")))
479 (defun muse-insert-relative-link-to-file ()
480 "Insert a relative link to a file, with optional description,
481 at the current point."
482 ;; Perhaps the relative location should be configurable, so that the
483 ;; file search would start in the publshing directory and then
484 ;; insert the link relative to the publishing directory
488 (file-relative-name (read-file-name "Link: "))
489 (read-string "Text: "))))
492 (defun muse-edit-link-at-point ()
493 "Edit the current link.
494 Do not rename the page originally referred to."
496 (if (muse-link-at-point)
497 (let ((link (muse-get-link))
498 (desc (muse-get-link-desc)))
502 (read-string "Link: " link)
503 (read-string "Text: " desc)))
505 (error "There is no valid link at point")))
507 (defun muse-visit-link-default (link &optional other-window)
508 "Visit the URL or link named by LINK.
509 If ANCHOR is specified, search for it after opening LINK.
511 This is the default function to call when visiting links; it is
512 used by `muse-visit-link' if you have not specified :visit-link
513 in `muse-project-alist'."
514 (if (string-match muse-url-regexp link)
515 (muse-browse-url link)
518 (when (string-match "#" link)
519 (setq anchor (substring link (match-beginning 0))
520 link (if (= (match-beginning 0) 0)
521 ;; If there is an anchor but no link, default
522 ;; to the current page.
524 (substring link 0 (match-beginning 0)))))
526 (setq base-buffer (get-buffer link))
527 (if (and base-buffer (not (buffer-file-name base-buffer)))
528 ;; If file is temporary (no associated file), just switch to
531 (switch-to-buffer-other-window base-buffer)
532 (switch-to-buffer base-buffer))
533 (let ((project (muse-project-of-file)))
535 (muse-project-find-file link project
537 'find-file-other-window))
539 (find-file-other-window link)
540 (find-file link))))))
543 (goto-char (point-min))
544 (unless (re-search-forward (concat "^\\W*" (regexp-quote anchor)
547 (goto-char pos)))))))
549 (defun muse-visit-link (link &optional other-window)
550 "Visit the URL or link named by LINK."
551 (let ((visit-link-function
552 (muse-get-keyword :visit-link (cadr (muse-project-of-file)) t)))
553 (if visit-link-function
554 (funcall visit-link-function link other-window)
555 (muse-visit-link-default link other-window))))
558 (defun muse-browse-result (style &optional other-window)
559 "Visit the current page's published result."
560 (interactive (list (muse-publish-get-style
563 (cons (muse-get-keyword :base style) style))
564 (muse-project-applicable-styles
565 buffer-file-name (cddr muse-current-project))))
567 (setq style (muse-style style))
569 (muse-publish-output-file buffer-file-name
570 (muse-style-element :path style) style)))
571 (if (not (file-readable-p result-path))
572 (error "Cannot open output file '%s'" result-path)
574 (find-file-other-window result-path)
575 (let ((func (muse-style-element :browser style t)))
577 (funcall func result-path)
578 (message "The %s publishing style does not support browsing."
582 (defun muse-follow-name-at-point (&optional other-window)
583 "Visit the link at point, or insert a newline if none is found."
585 (let ((link (muse-link-at-point)))
587 (muse-visit-link link other-window)
588 (error "There is no valid link at point"))))
591 (defun muse-follow-name-at-point-other-window ()
592 "Visit the link at point in other window."
594 (muse-follow-name-at-point t))
596 (defun muse-follow-name-at-mouse (event &optional other-window)
597 "Visit the link at point, or yank text if none is found."
600 (cond ((fboundp 'event-window) ; XEmacs
601 (set-buffer (window-buffer (event-window event)))
602 (and (funcall (symbol-function 'event-point) event)
603 (goto-char (funcall (symbol-function 'event-point) event))))
604 ((fboundp 'posn-window) ; Emacs
605 (set-buffer (window-buffer (posn-window (event-start event))))
606 (goto-char (posn-point (event-start event)))))
607 (let ((link (muse-link-at-point)))
609 (muse-visit-link link other-window)
610 ;; Fall back to normal binding for this event
612 (lookup-key (current-global-map) (this-command-keys)))))))
614 (defun muse-follow-name-at-mouse-other-window (event)
615 "Visit the link at point"
617 ;; throw away the old window position, since other-window will
619 (select-window (car (cadr event)))
620 (muse-follow-name-at-mouse event t))
623 (defun muse-next-reference ()
624 "Move forward to next Muse link or URL, cycling if necessary."
626 (let ((cycled 0) pos)
628 (when (get-text-property (point) 'muse-link)
629 (goto-char (or (next-single-property-change (point) 'muse-link)
632 (let ((next (point)))
633 (if (while (and (null pos)
635 (next-single-property-change next 'muse-link)))
636 (when (get-text-property next 'muse-link)
639 (goto-char (point-min))
640 (setq cycled (1+ cycled))))))
645 (defun muse-previous-reference ()
646 "Move backward to the next Muse link or URL, cycling if necessary.
647 This function is not entirely accurate, but it's close enough."
649 (let ((cycled 0) pos)
652 (let ((prev (point)))
653 (if (while (and (null pos)
655 (previous-single-property-change
657 (when (get-text-property prev 'muse-link)
660 (goto-char (point-max))
661 (setq cycled (1+ cycled))))))
666 (defun muse-what-changed ()
667 "Show the unsaved changes that have been made to the current file."
669 (diff-backup buffer-file-name))
672 ;;; Find text in project pages, or pages referring to the current page
674 (defvar muse-search-history nil)
676 (defun muse-grep (string &optional grep-command-no-shadow)
677 "Grep for STRING in the project directories.
678 GREP-COMMAND if passed will supplant `muse-grep-command'."
679 ;; careful - grep-command leaks into compile, so we call it
680 ;; -no-shadow instead
682 (let* ((str (or grep-command-no-shadow muse-grep-command))
683 (muse-directories (mapcar
687 (dirs (mapconcat (lambda (dir)
688 (shell-quote-argument
689 (expand-file-name dir)))
690 muse-directories " ")))
691 (while (string-match "%W" str)
692 (setq str (replace-match string t t str)))
693 (while (string-match "%D" str)
694 (setq str (replace-match dirs t t str)))
695 (if (fboundp 'compilation-start)
696 (compilation-start str nil (lambda (&rest args) "*search*")
698 (and (fboundp 'compile-internal)
699 (compile-internal str "No more search hits" "search"
700 nil grep-regexp-alist)))))
703 (defun muse-search-with-command (text)
704 "Search for the given TEXT string in the project directories
705 using the specified command."
707 (list (let ((str (concat muse-grep-command)) pos)
708 (when (string-match "%W" str)
709 (setq pos (match-beginning 0))
710 (unless (featurep 'xemacs)
712 (setq str (replace-match "" t t str)))
713 (read-from-minibuffer "Search command: "
714 (cons str pos) nil nil
715 'muse-search-history))))
716 (muse-grep nil text))
719 (defun muse-search ()
720 "Search for the given TEXT using the default grep command."
722 (muse-grep (read-string "Search: ")))
725 (defun muse-find-backlinks ()
726 "Grep for the current pagename in all the project directories."
728 (muse-grep (muse-page-name)))
731 ;;; Generate an index of all known Muse pages
733 (defun muse-generate-index (&optional as-list exclude-private)
734 "Generate an index of all Muse pages."
735 (let ((index (muse-index-as-string as-list exclude-private)))
736 (with-current-buffer (get-buffer-create "*Muse Index*")
743 "Display an index of all known Muse pages."
745 (message "Generating Muse index...")
746 (let ((project (muse-project)))
747 (with-current-buffer (muse-generate-index)
748 (goto-char (point-min))
750 (setq muse-current-project project)
751 (pop-to-buffer (current-buffer))))
752 (message "Generating Muse index...done"))
754 (defun muse-index-as-string (&optional as-list exclude-private exclude-current)
755 "Generate an index of all Muse pages.
756 If AS-LIST is non-nil, insert a dash and spaces before each item.
757 If EXCLUDE-PRIVATE is non-nil, exclude files that have private permissions.
758 If EXCLUDE-CURRENT is non-nil, exclude the current file from the output."
759 (let ((files (sort (copy-alist (muse-project-file-alist))
762 (string-lessp (car l) (car r)))))))
763 (when (and exclude-current (muse-page-name))
764 (setq files (delete (assoc (muse-page-name) files) files)))
767 (unless (and exclude-private
768 (muse-project-private-p (cdar files)))
769 (insert (if as-list " - " "") "[[" (caar files) "]]\n"))
770 (setq files (cdr files)))
773 ;;; Insert tags interactively on C-c TAB
775 (defvar muse-tag-history nil
776 "List of recently-entered tags; used by `muse-insert-tag'.
777 If you want a tag to start as the default, you may manually set
778 this variable to a list.")
780 (defvar muse-custom-tags nil
781 "Keep track of any new tags entered in `muse-insert-tag'.
782 If there are (X)HTML tags that you use frequently with that
783 function, you might want to set this manually.")
786 (defun muse-insert-tag (tag)
787 "Insert a tag interactively with a blank line after it."
792 (when muse-tag-history
793 (concat "(default: " (car muse-tag-history) ") ")))
795 (require 'muse-publish)
796 (mapcar 'list (nconc (mapcar 'car muse-publish-markup-tags)
798 nil nil nil 'muse-tag-history
799 (car muse-tag-history))))
801 (setq tag (car muse-tag-history)))
802 (unless (interactive-p)
803 (require 'muse-publish))
804 (let ((tag-entry (assoc tag muse-publish-markup-tags))
806 ;; Add to custom list if no entry exists
808 (add-to-list 'muse-custom-tags tag))
810 (when (nth 2 tag-entry)
811 (setq options (read-string "Option: ")))
812 (unless (equal options "")
813 (setq options (concat " " options)))
814 ;; Insert the tag, closing if necessary
815 (when tag (insert (concat "<" tag options ">")))
816 (when (nth 1 tag-entry)
817 (insert (concat "\n\n</" tag ">\n"))
822 ;;; muse-mode.el ends here