emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116016: `define-alternatives' bugfix and UI enhance


From: Bastien Guerry
Subject: [Emacs-diffs] trunk r116016: `define-alternatives' bugfix and UI enhancement
Date: Mon, 13 Jan 2014 22:14:33 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116016
revision-id: address@hidden
parent: address@hidden
committer: Bastien Guerry <address@hidden>
branch nick: trunk
timestamp: Mon 2014-01-13 23:13:44 +0100
message:
  `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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/simple.el                 simple.el-20091113204419-o5vbwnq5f7feedwu-403
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-01-13 15:33:01 +0000
+++ b/lisp/ChangeLog    2014-01-13 22:13:44 +0000
@@ -1,3 +1,10 @@
+2014-01-13  Bastien Guerry  <address@hidden>
+
+       * 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  <address@hidden>
 
        * vc/log-edit.el: Fix highlighting of summary when it's the first line.

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2014-01-12 04:00:03 +0000
+++ b/lisp/simple.el    2014-01-13 22:13:44 +0000
@@ -7654,10 +7654,20 @@
 ;; ;;;###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 @@
          (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)))))))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]