diff options
| author | Bastien Guerry | 2014-01-13 23:13:44 +0100 |
|---|---|---|
| committer | Bastien Guerry | 2014-01-13 23:13:44 +0100 |
| commit | e3f33e5dbbdf45eb28a88d82f8d7a8d03384fdc2 (patch) | |
| tree | b2f4d9b0c28f1dcf3e99011dfddcb4be54203128 | |
| parent | d6b738fcf5a98309f93ba1d74a28980111087c05 (diff) | |
| download | emacs-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/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 @@ | |||
| 1 | 2014-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 | |||
| 1 | 2014-01-13 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2014-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'. |
| 7658 | The variable `COMMAND-alternatives' will contain alternative | 7658 | |
| 7659 | implementations of COMMAND, so that running `C-u M-x COMMAND' | 7659 | The argument `COMMAND' should be a symbol. |
| 7660 | will allow the user to chose among them. | 7660 | |
| 7661 | Running `M-x COMMAND RET' for the first time prompts for which | ||
| 7662 | alternative to use and record the selected command as a custom | ||
| 7663 | variable. | ||
| 7664 | |||
| 7665 | Running `C-u M-x COMMAND RET' prompts again and overwrite the | ||
| 7666 | previous choice. | ||
| 7667 | |||
| 7668 | The variable `COMMAND-alternatives' contains an alist with | ||
| 7669 | alternative implementations of COMMAND. | ||
| 7670 | |||
| 7661 | CUSTOMIZATIONS, if non-nil, should be composed of alternating | 7671 | CUSTOMIZATIONS, 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 | ||