From d5fa3a9101901b631f941b748636eab2a7da9c67 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Wed, 18 May 2005 06:00:27 +0000 Subject: [PATCH] New feature: tag completion with C-c TAB. * muse-mode.el (muse-mode-map): Map C-c TAB to `muse-insert-tag'. (muse-tag-history, muse-custom-tags): New variables that keep track of the tag history and newly-entered tags respectively for `muse-insert-tag'. (muse-insert-tag): New function that interactively prompts the user for a tag to use. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-33 --- ChangeLog | 18 ++++++++++++++++++ muse-mode.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/ChangeLog b/ChangeLog index 267d089..39bbe90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,24 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-05-18 06:00:27 GMT Michael Olson patch-33 + + Summary: + New feature: tag completion with C-c TAB. + Revision: + muse--main--1.0--patch-33 + + * muse-mode.el (muse-mode-map): Map C-c TAB to `muse-insert-tag'. + (muse-tag-history, muse-custom-tags): New variables that keep track of + the tag history and newly-entered tags respectively for + `muse-insert-tag'. + (muse-insert-tag): New function that interactively prompts the user for + a tag to use. + + modified files: + ChangeLog muse-mode.el + + 2005-05-18 05:49:07 GMT Michael Olson patch-32 Summary: diff --git a/muse-mode.el b/muse-mode.el index 8a208e9..a03d654 100644 --- a/muse-mode.el +++ b/muse-mode.el @@ -26,6 +26,10 @@ ;;; Contributors: +;; Andrea Riciputi (ariciputi AT pito DOT com) gave an initial +;; implementation for tag completion by means of the +;; `muse-insert-tag' function. + ;;; Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -37,6 +41,7 @@ (require 'muse) (require 'muse-regexps) (require 'muse-project) +(require 'muse-publish) (autoload 'muse-use-font-lock "muse-colors") @@ -111,6 +116,9 @@ See `muse-publish' for more information." (define-key map [(control ?c) (control ?f)] 'muse-project-find-file) (define-key map [(control ?c) (control ?p)] 'muse-project-publish) + (define-key map [(control ?c) tab] 'muse-insert-tag) + (define-key map [(control ?c) (control ?i)] 'muse-insert-tag) + (when (featurep 'pcomplete) (define-key map [(meta tab)] 'pcomplete) (define-key map [(meta control ?i)] 'pcomplete)) @@ -359,6 +367,48 @@ This function is not entirely accurate, but it's close enough." (pop-to-buffer (current-buffer)))) (message "Generating Muse index...done")) +;;; Insert tags interactively on C-c TAB + +(defvar muse-tag-history nil + "List of recently-entered tags; used by `muse-insert-tag'. +If you want a tag to start as the default, you may manually set +this variable to a list.") + +(defvar muse-custom-tags nil + "Keep track of any new tags entered in `muse-insert-tag'. +If there are (X)HTML tags that you use frequently with that +function, you might want to set this manually.") + +(defun muse-insert-tag (tag) + "Insert a tag interactively with a blank line after it." + (interactive + (list + (completing-read + (concat "Tag: " + (when muse-tag-history + (concat "(default " (car muse-tag-history) ") "))) + (nconc (mapcar 'car muse-publish-markup-tags) + muse-custom-tags) + nil nil nil 'muse-tag-history + (car muse-tag-history)))) + (when (equal tag "") + (setq tag (car muse-tag-history))) + (let ((tag-entry (assoc tag muse-publish-markup-tags)) + (options "")) + ;; Add to custom list if no entry exists + (unless tag-entry + (add-to-list 'muse-custom-tags tag)) + ;; Get option + (when (nth 2 tag-entry) + (setq options (read-string "Option: "))) + (unless (equal options "") + (setq options (concat " " options))) + ;; Insert the tag, closing if necessary + (when tag (insert (concat "<" tag options ">"))) + (when (nth 1 tag-entry) + (insert (concat "\n\n\n")) + (forward-line -2)))) + (provide 'muse-mode) ;;; muse-mode.el ends here -- 2.11.4.GIT