diff options
| author | Bastien Guerry <bzg@gnu.org> | 2014-01-13 23:13:44 +0100 |
|---|---|---|
| committer | Bastien Guerry <bzg@gnu.org> | 2014-01-13 23:13:44 +0100 |
| commit | e3f33e5dbbdf45eb28a88d82f8d7a8d03384fdc2 (patch) | |
| tree | b2f4d9b0c28f1dcf3e99011dfddcb4be54203128 /lisp | |
| parent | d6b738fcf5a98309f93ba1d74a28980111087c05 (diff) | |
| download | emacs-e3f33e5dbbdf45eb28a88d82f8d7a8d03384fdc2.tar.gz | |
`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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/simple.el | 34 |
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 @@ +2014-01-13 Bastien Guerry <bzg@gnu.org> + + * 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. + 2014-01-13 Stefan Monnier <monnier@iro.umontreal.ca> * 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.") ;; ;;;###autoload (push '("My impl name" . my-impl-symbol) COMMAND-alternatives (defmacro define-alternatives (command &rest customizations) - "Define new command `COMMAND'. -The variable `COMMAND-alternatives' will contain alternative -implementations of COMMAND, so that running `C-u M-x COMMAND' -will allow the user to chose among them. + "Define the new command `COMMAND'. + +The argument `COMMAND' should be a symbol. + +Running `M-x COMMAND RET' for the first time prompts for which +alternative to use and record the selected command as a custom +variable. + +Running `C-u M-x COMMAND RET' prompts again and overwrite the +previous choice. + +The variable `COMMAND-alternatives' contains an alist with +alternative implementations of COMMAND. + CUSTOMIZATIONS, if non-nil, should be composed of alternating `defcustom' keywords and values to add to the declaration of `COMMAND-alternatives' (typically :group and :version)." @@ -7688,13 +7698,19 @@ contains the list of implementations currently supported for this command." (interactive "P") (when (or arg (null ,varimp-sym)) (let ((val (completing-read - ,(format "Select implementation for command `%s': " command-name) - ,varalt-sym nil t))) + ,(format "Select implementation for command `%s': " + command-name) + ,varalt-sym nil t))) (unless (string-equal val "") - (customize-save-variable ',varimp-sym - (cdr (assoc-string val ,varalt-sym)))))) + (when (null ,varimp-sym) + (message + "Use `C-u M-x %s RET' to select another implementation" + ,command-name) + (sit-for 3)) + (customize-save-variable ',varimp-sym + (cdr (assoc-string val ,varalt-sym)))))) (if ,varimp-sym - (funcall ,varimp-sym) + (call-interactively ,varimp-sym) (message ,(format "No implementation selected for command `%s'" command-name))))))) |
