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
)
136 (define-key map
"u" 'muse-insert-url
)
140 (defvar muse-mode-map
141 (let ((map (make-sparse-keymap)))
142 (define-key map
[(control ?c
) (control ?a
)] 'muse-index
)
143 (define-key map
[(control ?c
) (control ?c
)] 'muse-follow-name-at-point
)
144 (define-key map
[(control ?c
) (control ?e
)] 'muse-edit-link-at-point
)
145 (define-key map
[(control ?c
) (control ?l
)] 'font-lock-mode
)
146 (define-key map
[(control ?c
) (control ?t
)]
147 'muse-project-publish-this-file
)
148 (define-key map
[(control ?c
) (control ?T
)] 'muse-publish-this-file
)
149 (define-key map
[(control ?c
) (control ?v
)] 'muse-browse-result
)
151 (define-key map
[(control ?c
) ?
=] 'muse-what-changed
)
153 (define-key map
[tab] 'muse-next-reference)
154 (define-key map [(control ?i)] 'muse-next-reference)
156 (if (featurep 'xemacs)
158 (define-key map [(button2)] 'muse-follow-name-at-mouse)
159 (define-key map [(shift button2)]
160 'muse-follow-name-at-mouse-other-window))
161 (define-key map [(shift control ?m)]
162 'muse-follow-name-at-point-other-window)
163 (define-key map [mouse-2] 'muse-follow-name-at-mouse)
164 (define-key map [(shift mouse-2)]
165 'muse-follow-name-at-mouse-other-window))
167 (define-key map [(shift tab)] 'muse-previous-reference)
168 (unless (featurep 'xemacs)
169 (define-key map [(shift iso-lefttab)] 'muse-previous-reference)
170 (define-key map [(shift control ?i)] 'muse-previous-reference))
172 (define-key map [(control ?c) (control ?f)] 'muse-project-find-file)
173 (define-key map [(control ?c) (control ?p)] 'muse-project-publish)
175 (define-key map [(control ?c) tab] 'muse-insert-thing)
177 ;; Searching functions
178 (define-key map [(control ?c) (control ?b)] 'muse-find-backlinks)
179 (define-key map [(control ?c) (control ?s)] 'muse-search)
181 ;; Enhanced list functions
182 (define-key map [(meta return)] 'muse-insert-list-item)
183 (define-key map [(control ?>)] 'muse-increase-list-item-indentation)
184 (define-key map [(control ?<)] 'muse-decrease-list-item-indentation)
186 (when (featurep 'pcomplete)
187 (define-key map [(meta tab)] 'pcomplete)
188 (define-key map [(meta control ?i)] 'pcomplete))
191 "Keymap used by Emacs Muse mode.")
196 (define-derived-mode muse-mode text-mode "Muse"
197 "Muse is an Emacs mode for authoring and publishing documents.
199 ;; Since we're not inheriting from normal-mode, we need to
200 ;; explicitly run file variables.
202 (hack-local-variables)
203 (error (message "File local-variables error: %s"
204 (prin1-to-string err))))
205 ;; Avoid lock-up caused by use of the 'intangible' text property
207 (unless muse-mode-intangible-links
208 (set (make-local-variable 'inhibit-point-motion-hooks) t))
209 (setq muse-current-project (muse-project-of-file))
210 (muse-project-set-variables)
211 ;; Make fill not split up links
212 (when (boundp 'fill-nobreak-predicate)
213 (make-local-variable 'fill-nobreak-predicate)
214 ;; Work around annoying inconsistency in fill handling between
216 (if (< emacs-major-version 22)
217 (setq fill-nobreak-predicate 'muse-mode-fill-nobreak-p)
218 (add-to-list 'fill-nobreak-predicate
219 'muse-mode-fill-nobreak-p)))
220 ;; Make fill work nicely with item lists
221 (set (make-local-variable 'adaptive-fill-regexp)
222 (concat "\\s-+\\(-\\|[0-9]+\\.\\)\\s-+\\|\\[[0-9]+\\]\\s-*"
223 "\\|\\s-*::\\s-*\\|\\s-*"))
224 (set (make-local-variable 'paragraph-start)
225 (concat paragraph-start "\\|\\s-+\\(-\\|[0-9]+\\.\\)\\s-+"
226 "\\|\\[[0-9]+\\]\\s-*\\|\\s-*::\\s-*"))
227 ;; Comment syntax is `; comment'
228 (set (make-local-variable 'comment-start)
230 (set (make-local-variable 'comment-start-skip)
232 ;; If we're using Emacs21, this makes flyspell work like it should
233 (when (boundp 'flyspell-generic-check-word-p)
234 (set (make-local-variable 'flyspell-generic-check-word-p)
235 'muse-mode-flyspell-p))
236 ;; If pcomplete is available, set it up
237 (when (featurep 'pcomplete)
238 (set (make-local-variable 'pcomplete-default-completion-function)
239 'muse-mode-completions)
240 (set (make-local-variable 'pcomplete-command-completion-function)
241 'muse-mode-completions)
242 (set (make-local-variable 'pcomplete-parse-arguments-function)
243 'muse-mode-current-word))
244 ;; Initialize any auto-generated variables
245 (run-hooks 'muse-update-values-hook)
246 (when muse-mode-highlight-p
247 (muse-use-font-lock)))
250 'flyspell-mode-predicate
251 'muse-mode-flyspell-p)
253 (defun muse-mode-fill-nobreak-p ()
254 "Return nil if we should allow a fill to occur at point.
255 Otherwise return non-nil.
257 This is used to keep long explicit links from being mangled by
261 (and (re-search-backward "\\[\\[\\|\\]\\]"
262 (line-beginning-position) t)
263 (string= (or (match-string 0) "")
266 (defun muse-mode-flyspell-p ()
267 "Return non-nil if we should allow spell-checking to occur at point.
268 Otherwise return nil.
270 This is used to keep links from being improperly colorized by flyspell."
271 (and (not (get-text-property (if (bobp) (point) (1- (point)))
274 (null (muse-link-at-point)))))
276 (defun muse-mode-choose-mode ()
277 "Turn the proper Emacs Muse related mode on for this file."
278 (let ((project (muse-project-of-file)))
279 (funcall (or (and project (muse-get-keyword :major-mode (cadr project) t))
282 (defun muse-mode-maybe ()
283 "Maybe turn Emacs Muse mode on for this file."
284 (let ((project (muse-project-of-file)))
286 (funcall (or (muse-get-keyword :major-mode (cadr project) t)
289 ;;; Enhanced list editing
291 (defun muse-on-blank-line ()
292 "See if point is on a blank line"
295 (looking-at (concat "[" muse-regexp-blank "]?[\n]+"))))
297 (defun muse-get-paragraph-start ()
298 "Return the start of the current paragraph. This function will
299 return nil if there are no prior paragraphs and the beginning of
300 the line if point is on a blank line."
301 (let ((para-start (concat "[\n]+[" muse-regexp-blank "]?[\n]+")))
302 ;; search back to start of paragraph
305 (if (not (muse-on-blank-line))
306 (re-search-backward para-start nil t)
307 (line-beginning-position))))))
309 (defun muse-insert-thing ()
310 "Prompt for something to insert into the current buffer."
312 (message "Insert:\nl link\nt Muse tag\nu URL")
314 (let ((overriding-local-map muse-insert-map))
315 (setq key (read-key-sequence nil)))
316 (if (commandp (setq cmd (lookup-key muse-insert-map key)))
318 (call-interactively cmd))
319 (message "Not inserting anything"))))
322 (defun muse-insert-list-item ()
323 "Insert a list item at the current point, taking into account
324 your current list type and indentation level."
326 (let ((newitem " - ")
328 (pstart (muse-get-paragraph-start))
329 (list-item (format muse-list-item-regexp
330 (concat "[" muse-regexp-blank "]*"))))
331 ;; search backwards for start of current item
333 (when (re-search-backward list-item pstart t)
334 ;; save the matching item
335 (setq newitem (match-string 0))
336 ;; see what type it is
337 (if (string-match "::" (match-string 0))
338 ;; is a definition, replace the term
339 (setq newitem (concat " "
340 (read-string "Term: ")
342 ;; see if it's a numbered list
343 (when (string-match "[0-9]+" newitem)
344 ;; is numbered, so increment
347 (match-string 0 newitem))))
348 (setq newitem (replace-match
349 (number-to-string itemno)
350 nil nil newitem))))))
351 ;; insert the new item
352 (insert (concat "\n" newitem))))
354 (defun muse-alter-list-item-indentation (operation)
355 "Alter the indentation of the current list item.
356 Valid values of OPERATION are 'increase and 'decrease."
357 (let ((pstart (muse-get-paragraph-start))
358 (list-item (format muse-list-item-regexp
359 (concat "[" muse-regexp-blank "]*")))
360 beg move-func indent)
361 ;; search backwards until start of paragraph to see if we are on a
364 (if (or (progn (goto-char (muse-line-beginning-position))
366 (looking-at list-item))
367 ;; not on item, so search backwards
368 (re-search-backward list-item pstart t))
371 (setq indent (buffer-substring (match-beginning 0)
372 (match-beginning 1)))
373 (muse-forward-list-item (muse-list-item-type (match-string 1))
374 (concat "[" muse-regexp-blank "]*")
377 (narrow-to-region beg (point))
378 (goto-char (point-min))
380 (while (< (point) (point-max))
381 ;; increase or decrease the indentation
383 (cond ((eq operation 'increase)
385 ((eq operation 'decrease)
387 ;; we have enough space, so delete it
388 (delete-region (match-beginning 0)
392 ;; we are not on an item, so warn
393 (message "You are not on a list item.")))))
396 (defun muse-increase-list-item-indentation ()
397 "Increase the indentation of the current list item."
399 (muse-alter-list-item-indentation 'increase))
402 (defun muse-decrease-list-item-indentation ()
403 "Decrease the indentation of the current list item."
405 (muse-alter-list-item-indentation 'decrease))
407 ;;; Support page name completion using pcomplete
409 (defun muse-mode-completions ()
410 "Return a list of possible completions names for this buffer."
411 (let ((project (muse-project-of-file)))
413 (while (pcomplete-here
414 (mapcar 'car (muse-project-file-alist project)))))))
416 (defun muse-mode-current-word ()
420 (skip-chars-backward (concat "^\\[\n" muse-regexp-blank))
421 (narrow-to-region (point) end))
422 (pcomplete-parse-buffer-arguments))))
424 ;;; Navigate/visit links or URLs. Use TAB, S-TAB and RET (or mouse-2).
426 (defun muse-link-at-point (&optional pos)
427 "Return link text if a URL or link is at point."
428 (let ((case-fold-search nil)
429 (inhibit-point-motion-hooks t)
430 (here (or pos (point))))
431 ;; if we are using muse-colors, we can just use link properties to
432 ;; determine whether we are on a link
433 (if (featurep 'muse-colors)
434 (when (get-text-property here 'muse-link)
436 (when (and (not (bobp))
437 (get-text-property (1- here) 'muse-link))
438 (goto-char (or (previous-single-property-change here 'muse-link)
440 (if (looking-at muse-explicit-link-regexp)
442 (goto-char (match-beginning 1))
443 (muse-handle-explicit-link))
444 (muse-handle-implicit-link))))
445 ;; use fallback method to find a link
447 (and (char-after pos)
448 (not (eq (char-syntax (char-after pos)) ?\ ))))
451 ;; check for explicit link here or before point
452 (if (or (looking-at muse-explicit-link-regexp)
454 (re-search-backward "\\[\\[\\|\\]\\]"
455 (muse-line-beginning-position)
457 (string= (or (match-string 0) "") "[[")
458 (looking-at muse-explicit-link-regexp)))
460 (goto-char (match-beginning 1))
461 (muse-handle-explicit-link))
463 ;; check for bare URL or other link type
464 (skip-chars-backward (concat "^'\"<>{}(\n" muse-regexp-blank))
465 (and (looking-at muse-implicit-link-regexp)
466 (muse-handle-implicit-link))))))))
468 (defun muse-make-link (link &optional desc)
469 "Return a link to LINK with DESC as the description."
470 (when (string-match muse-explicit-link-regexp link)
471 (unless desc (setq desc (muse-get-link-desc link)))
472 (setq link (muse-get-link link)))
475 (not (string= desc ""))
476 (not (string= link desc)))
477 (concat "[[" (muse-link-escape link) "][" (muse-link-escape desc) "]]")
478 (concat "[[" (or (muse-link-escape link) "") "]]")))
481 (defun muse-insert-relative-link-to-file ()
482 "Insert a relative link to a file, with optional description, at point."
483 ;; Perhaps the relative location should be configurable, so that the
484 ;; file search would start in the publishing directory and then
485 ;; insert the link relative to the publishing directory
488 (muse-make-link (file-relative-name (read-file-name "Link: "))
489 (read-string "Text: "))))
491 (defun muse-insert-url ()
492 "Insert a URL, with optional description, at point."
495 (muse-make-link (read-string "URL: ")
496 (read-string "Text: "))))
499 (defun muse-edit-link-at-point ()
500 "Edit the current link.
501 Do not rename the page originally referred to."
503 (if (muse-link-at-point)
504 (let ((link (muse-link-unescape (muse-get-link)))
505 (desc (muse-link-unescape (muse-get-link-desc))))
509 (read-string "Link: " link)
510 (read-string "Text: " desc)))
512 (error "There is no valid link at point")))
514 (defun muse-visit-link-default (link &optional other-window)
515 "Visit the URL or link named by LINK.
516 If ANCHOR is specified, search for it after opening LINK.
518 This is the default function to call when visiting links; it is
519 used by `muse-visit-link' if you have not specified :visit-link
520 in `muse-project-alist'."
521 (if (string-match muse-url-regexp link)
522 (muse-browse-url link)
525 (when (string-match "#" link)
526 (setq anchor (substring link (match-beginning 0))
527 link (if (= (match-beginning 0) 0)
528 ;; If there is an anchor but no link, default
529 ;; to the current page.
531 (substring link 0 (match-beginning 0)))))
533 (setq base-buffer (get-buffer link))
534 (if (and base-buffer (not (buffer-file-name base-buffer)))
535 ;; If file is temporary (no associated file), just switch to
538 (switch-to-buffer-other-window base-buffer)
539 (switch-to-buffer base-buffer))
540 (let ((project (muse-project-of-file)))
542 (muse-project-find-file link project
544 'find-file-other-window))
546 (find-file-other-window link)
547 (find-file link))))))
550 (goto-char (point-min))
551 (unless (re-search-forward (concat "^\\W*" (regexp-quote anchor)
554 (goto-char pos)))))))
556 (defun muse-visit-link (link &optional other-window)
557 "Visit the URL or link named by LINK."
558 (let ((visit-link-function
559 (muse-get-keyword :visit-link (cadr (muse-project-of-file)) t)))
560 (if visit-link-function
561 (funcall visit-link-function link other-window)
562 (muse-visit-link-default link other-window))))
565 (defun muse-browse-result (style &optional other-window)
566 "Visit the current page's published result."
568 (list (muse-project-get-applicable-style buffer-file-name
569 (cddr muse-current-project))
571 (setq style (muse-style style))
573 (muse-publish-output-file buffer-file-name
574 (muse-style-element :path style) style)))
575 (if (not (file-readable-p result-path))
576 (error "Cannot open output file '%s'" result-path)
578 (find-file-other-window result-path)
579 (let ((func (muse-style-element :browser style t)))
581 (funcall func result-path)
582 (message "The %s publishing style does not support browsing."
586 (defun muse-follow-name-at-point (&optional other-window)
587 "Visit the link at point."
589 (let ((link (muse-link-at-point)))
591 (muse-visit-link link other-window)
592 (error "There is no valid link at point"))))
595 (defun muse-follow-name-at-point-other-window ()
596 "Visit the link at point in other window."
598 (muse-follow-name-at-point t))
600 (defun muse-follow-name-at-mouse (event &optional other-window)
601 "Visit the link at point, or yank text if none is found."
605 (cond ((fboundp 'event-window) ; XEmacs
606 (set-buffer (window-buffer (event-window event)))
607 (and (funcall (symbol-function 'event-point) event)
608 (goto-char (funcall (symbol-function 'event-point)
610 ((fboundp 'posn-window) ; Emacs
611 (set-buffer (window-buffer (posn-window (event-start event))))
612 (goto-char (posn-point (event-start event)))))
613 (let ((link (muse-link-at-point)))
615 (muse-visit-link link other-window)
617 ;; Fall back to normal binding for this event
619 (lookup-key (current-global-map) (this-command-keys)))))
621 (defun muse-follow-name-at-mouse-other-window (event)
622 "Visit the link at point"
624 ;; throw away the old window position, since other-window will
626 (select-window (car (cadr event)))
627 (muse-follow-name-at-mouse event t))
630 (defun muse-next-reference ()
631 "Move forward to next Muse link or URL, cycling if necessary."
633 (let ((cycled 0) pos)
635 (when (get-text-property (point) 'muse-link)
636 (goto-char (or (next-single-property-change (point) 'muse-link)
639 (let ((next (point)))
640 (if (while (and (null pos)
642 (next-single-property-change next 'muse-link)))
643 (when (get-text-property next 'muse-link)
646 (goto-char (point-min))
647 (setq cycled (1+ cycled))))))
652 (defun muse-previous-reference ()
653 "Move backward to the next Muse link or URL, cycling if necessary.
654 This function is not entirely accurate, but it's close enough."
656 (let ((cycled 0) pos)
659 (let ((prev (point)))
660 (if (while (and (null pos)
662 (previous-single-property-change
664 (when (get-text-property prev 'muse-link)
667 (goto-char (point-max))
668 (setq cycled (1+ cycled))))))
673 (defun muse-what-changed ()
674 "Show the unsaved changes that have been made to the current file."
676 (diff-backup buffer-file-name))
679 ;;; Find text in project pages, or pages referring to the current page
681 (defvar muse-search-history nil)
683 (defun muse-grep (string &optional grep-command-no-shadow)
684 "Grep for STRING in the project directories.
685 GREP-COMMAND if passed will supplant `muse-grep-command'."
686 ;; careful - grep-command leaks into compile, so we call it
687 ;; -no-shadow instead
689 (let* ((str (or grep-command-no-shadow muse-grep-command))
690 (muse-directories (mapcar
694 (dirs (mapconcat (lambda (dir)
695 (shell-quote-argument
696 (expand-file-name dir)))
697 muse-directories " ")))
698 (while (string-match "%W" str)
699 (setq str (replace-match string t t str)))
700 (while (string-match "%D" str)
701 (setq str (replace-match dirs t t str)))
702 (if (fboundp 'compilation-start)
703 (compilation-start str nil (lambda (&rest args) "*search*")
705 (and (fboundp 'compile-internal)
706 (compile-internal str "No more search hits" "search"
707 nil grep-regexp-alist)))))
710 (defun muse-search-with-command (text)
711 "Search for the given TEXT string in the project directories
712 using the specified command."
714 (list (let ((str (concat muse-grep-command)) pos)
715 (when (string-match "%W" str)
716 (setq pos (match-beginning 0))
717 (unless (featurep 'xemacs)
719 (setq str (replace-match "" t t str)))
720 (read-from-minibuffer "Search command: "
721 (cons str pos) nil nil
722 'muse-search-history))))
723 (muse-grep nil text))
726 (defun muse-search ()
727 "Search for the given TEXT using the default grep command."
729 (muse-grep (read-string "Search: ")))
732 (defun muse-find-backlinks ()
733 "Grep for the current pagename in all the project directories."
735 (muse-grep (muse-page-name)))
738 ;;; Generate an index of all known Muse pages
740 (defun muse-generate-index (&optional as-list exclude-private)
741 "Generate an index of all Muse pages."
742 (let ((index (muse-index-as-string as-list exclude-private)))
743 (with-current-buffer (get-buffer-create "*Muse Index*")
750 "Display an index of all known Muse pages."
752 (message "Generating Muse index...")
753 (let ((project (muse-project)))
754 (with-current-buffer (muse-generate-index)
755 (goto-char (point-min))
757 (setq muse-current-project project)
758 (pop-to-buffer (current-buffer))))
759 (message "Generating Muse index...done"))
761 (defun muse-index-as-string (&optional as-list exclude-private exclude-current)
762 "Generate an index of all Muse pages.
763 If AS-LIST is non-nil, insert a dash and spaces before each item.
764 If EXCLUDE-PRIVATE is non-nil, exclude files that have private permissions.
765 If EXCLUDE-CURRENT is non-nil, exclude the current file from the output."
766 (let ((files (sort (copy-alist (muse-project-file-alist))
769 (string-lessp (car l) (car r)))))))
770 (when (and exclude-current (muse-page-name))
771 (setq files (delete (assoc (muse-page-name) files) files)))
774 (unless (and exclude-private
775 (muse-project-private-p (cdar files)))
776 (insert (if as-list " - " "") "[[" (caar files) "]]\n"))
777 (setq files (cdr files)))
780 ;;; Insert tags interactively on C-c TAB t
782 (defvar muse-tag-history nil
783 "List of recently-entered tags; used by `muse-insert-tag'.
784 If you want a tag to start as the default, you may manually set
785 this variable to a list.")
787 (defvar muse-custom-tags nil
788 "Keep track of any new tags entered in `muse-insert-tag'.
789 If there are (X)HTML tags that you use frequently with that
790 function, you might want to set this manually.")
793 (defun muse-insert-tag (tag)
794 "Insert a tag interactively with a blank line after it."
799 (when muse-tag-history
800 (concat "(default: " (car muse-tag-history) ") ")))
802 (require 'muse-publish)
803 (mapcar 'list (nconc (mapcar 'car muse-publish-markup-tags)
805 nil nil nil 'muse-tag-history
806 (car muse-tag-history))))
808 (setq tag (car muse-tag-history)))
809 (unless (interactive-p)
810 (require 'muse-publish))
811 (let ((tag-entry (assoc tag muse-publish-markup-tags))
813 ;; Add to custom list if no entry exists
815 (add-to-list 'muse-custom-tags tag))
817 (when (nth 2 tag-entry)
818 (setq options (read-string "Option: ")))
819 (unless (equal options "")
820 (setq options (concat " " options)))
821 ;; Insert the tag, closing if necessary
822 (when tag (insert (concat "<" tag options ">")))
823 (when (nth 1 tag-entry)
824 (insert (concat "\n\n</" tag ">\n"))
829 ;;; muse-mode.el ends here