aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastien Guerry2014-01-13 23:13:44 +0100
committerBastien Guerry2014-01-13 23:13:44 +0100
commite3f33e5dbbdf45eb28a88d82f8d7a8d03384fdc2 (patch)
treeb2f4d9b0c28f1dcf3e99011dfddcb4be54203128
parentd6b738fcf5a98309f93ba1d74a28980111087c05 (diff)
downloademacs-e3f33e5dbbdf45eb28a88d82f8d7a8d03384fdc2.tar.gz
emacs-e3f33e5dbbdf45eb28a88d82f8d7a8d03384fdc2.zip
`define-alternatives' bugfix and UI enhancement
* simple.el (define-alternatives): Call the selected command interactively. When setting `COMMAND--implementation' for the first time, tell the user how to chose another implementation. Enhance the docstring.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/simple.el34
2 files changed, 32 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dbba63d8d2c..22a31f336ac 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12014-01-13 Bastien Guerry <bzg@gnu.org>
2
3 * simple.el (define-alternatives): Call the selected command
4 interactively. When setting `COMMAND--implementation' for the
5 first time, tell the user how to chose another implementation.
6 Enhance the docstring.
7
12014-01-13 Stefan Monnier <monnier@iro.umontreal.ca> 82014-01-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * vc/log-edit.el: Fix highlighting of summary when it's the first line. 10 * vc/log-edit.el: Fix highlighting of summary when it's the first line.
diff --git a/lisp/simple.el b/lisp/simple.el
index ae18ae65fb5..8ff6b9c55f4 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -7654,10 +7654,20 @@ warning using STRING as the message.")
7654;; ;;;###autoload (push '("My impl name" . my-impl-symbol) COMMAND-alternatives 7654;; ;;;###autoload (push '("My impl name" . my-impl-symbol) COMMAND-alternatives
7655 7655
7656(defmacro define-alternatives (command &rest customizations) 7656(defmacro define-alternatives (command &rest customizations)
7657 "Define new command `COMMAND'. 7657 "Define the new command `COMMAND'.
7658The variable `COMMAND-alternatives' will contain alternative 7658
7659implementations of COMMAND, so that running `C-u M-x COMMAND' 7659The argument `COMMAND' should be a symbol.
7660will allow the user to chose among them. 7660
7661Running `M-x COMMAND RET' for the first time prompts for which
7662alternative to use and record the selected command as a custom
7663variable.
7664
7665Running `C-u M-x COMMAND RET' prompts again and overwrite the
7666previous choice.
7667
7668The variable `COMMAND-alternatives' contains an alist with
7669alternative implementations of COMMAND.
7670
7661CUSTOMIZATIONS, if non-nil, should be composed of alternating 7671CUSTOMIZATIONS, if non-nil, should be composed of alternating
7662`defcustom' keywords and values to add to the declaration of 7672`defcustom' keywords and values to add to the declaration of
7663`COMMAND-alternatives' (typically :group and :version)." 7673`COMMAND-alternatives' (typically :group and :version)."
@@ -7688,13 +7698,19 @@ contains the list of implementations currently supported for this command."
7688 (interactive "P") 7698 (interactive "P")
7689 (when (or arg (null ,varimp-sym)) 7699 (when (or arg (null ,varimp-sym))
7690 (let ((val (completing-read 7700 (let ((val (completing-read
7691 ,(format "Select implementation for command `%s': " command-name) 7701 ,(format "Select implementation for command `%s': "
7692 ,varalt-sym nil t))) 7702 command-name)
7703 ,varalt-sym nil t)))
7693 (unless (string-equal val "") 7704 (unless (string-equal val "")
7694 (customize-save-variable ',varimp-sym 7705 (when (null ,varimp-sym)
7695 (cdr (assoc-string val ,varalt-sym)))))) 7706 (message
7707 "Use `C-u M-x %s RET' to select another implementation"
7708 ,command-name)
7709 (sit-for 3))
7710 (customize-save-variable ',varimp-sym
7711 (cdr (assoc-string val ,varalt-sym))))))
7696 (if ,varimp-sym 7712 (if ,varimp-sym
7697 (funcall ,varimp-sym) 7713 (call-interactively ,varimp-sym)
7698 (message ,(format "No implementation selected for command `%s'" 7714 (message ,(format "No implementation selected for command `%s'"
7699 command-name))))))) 7715 command-name)))))))
7700 7716