]> git.eshelyaron.com Git - emacs.git/commitdiff
* keymap.c (QCadvertised_binding): New constant.
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 11 Sep 2009 00:58:59 +0000 (00:58 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 11 Sep 2009 00:58:59 +0000 (00:58 +0000)
(syms_of_keymap): Initialize it.
(Fwhere_is_internal): Try and use bindings from :advertised-binding
if applicable.

* progmodes/xscheme.el (xscheme-evaluation-commands):
Put a :advertised-binding property rather than using
advertised-xscheme-send-previous-expression.
(advertised-xscheme-send-previous-expression): Declare obsolete.
* emulation/crisp.el (crisp-mode-map): Use `undo' rather than
`advertised-undo'.
(crisp-mode): Add corresponding bindings to
undo's :advertised-binding instead.
* dired.el (dired-mode-map): Put a :advertised-binding property rather
than using dired-advertised-find-file.
(dired-advertised-find-file):
* simple.el (advertised-undo):
* wid-edit.el (advertised-widget-backward): Declare obsolete.
(widget-keymap): Put a :advertised-binding property rather
than using advertised-widget-backward.
* bindings.el (ctl-x-map): Put a :advertised-binding property rather
than using advertised-undo.
* tutorial.el (tutorial--default-keys): Adjust accordingly.

12 files changed:
etc/NEWS
lisp/ChangeLog
lisp/bindings.el
lisp/dired.el
lisp/emulation/crisp.el
lisp/progmodes/xscheme.el
lisp/simple.el
lisp/startup.el
lisp/textmodes/picture.el
lisp/tutorial.el
lisp/wid-edit.el
src/keymap.c

index 30b0d9bafb35e11d73b292e1c0e2cef8cd73949f..c6772138bb680c5f15d36c3cee38e4d1210b8fe5 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -204,6 +204,11 @@ functions and variables.
 \f
 * Lisp changes in Emacs 23.2
 
+** You can control which binding is preferentially shown in menus and
+docstrings by adding a `:advertised-binding' property to the corresponding
+command's symbol.  That property can hold a single binding or a list
+of bindings.
+
 ** New macro with-silent-modifications to tweak text properties without
 affecting the buffer's modification state.
 ** All the default-FOO variables that hold the default value of the FOO
index 6487d3fcbef6952e2ac829b86d507e9128ae10e0..9513e9ecb4e153c2924946633646a7c1bc950d62 100644 (file)
@@ -1,3 +1,24 @@
+2009-09-11  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * progmodes/xscheme.el (xscheme-evaluation-commands):
+       Put a :advertised-binding property rather than using
+       advertised-xscheme-send-previous-expression.
+       (advertised-xscheme-send-previous-expression): Declare obsolete.
+       * emulation/crisp.el (crisp-mode-map): Use `undo' rather than
+       `advertised-undo'.
+       (crisp-mode): Add corresponding bindings to
+       undo's :advertised-binding instead.
+       * dired.el (dired-mode-map): Put a :advertised-binding property rather
+       than using dired-advertised-find-file.
+       (dired-advertised-find-file):
+       * simple.el (advertised-undo):
+       * wid-edit.el (advertised-widget-backward): Declare obsolete.
+       (widget-keymap): Put a :advertised-binding property rather
+       than using advertised-widget-backward.
+       * bindings.el (ctl-x-map): Put a :advertised-binding property rather
+       than using advertised-undo.
+       * tutorial.el (tutorial--default-keys): Adjust accordingly.
+
 2009-09-10  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * subr.el (define-key-rebound-commands): Mark obsolete.
index 9ee6c3fa30675e93a29f3cee339f64473771b824..9f3f43c7cd7fa0eb3b031ece6ea234e842959331 100644 (file)
@@ -757,7 +757,8 @@ language you are using."
 (define-key ctl-x-map "\e\e" 'repeat-complex-command)
 ;; New binding analogous to M-:.
 (define-key ctl-x-map "\M-:" 'repeat-complex-command)
-(define-key ctl-x-map "u" 'advertised-undo)
+(define-key ctl-x-map "u" 'undo)
+(put 'undo :advertised-binding [?\C-x ?u])
 ;; Many people are used to typing C-/ on X terminals and getting C-_.
 (define-key global-map [?\C-/] 'undo)
 (define-key global-map "\C-_" 'undo)
index 21734f6ae7d7bc27ad475faeacac0b4b6e10164b..cf975158cf57590a5409a0d3d3e9bfc1c5263bda 100644 (file)
@@ -1292,7 +1292,8 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
     (define-key map "d" 'dired-flag-file-deletion)
     (define-key map "e" 'dired-find-file)
     (define-key map "f" 'dired-find-file)
-    (define-key map "\C-m" 'dired-advertised-find-file)
+    (define-key map "\C-m" 'dired-find-file)
+    (put 'dired-find-file :advertised-binding "\C-m")
     (define-key map "g" 'revert-buffer)
     (define-key map "h" 'describe-mode)
     (define-key map "i" 'dired-maybe-insert-subdir)
@@ -1685,7 +1686,7 @@ Type \\[dired-mark] to Mark a file or subdirectory for later commands.
 Type \\[dired-unmark] to Unmark a file or all files of a subdirectory.
 Type \\[dired-unmark-backward] to back up one line and unflag.
 Type \\[dired-do-flagged-delete] to eXecute the deletions requested.
-Type \\[dired-advertised-find-file] to Find the current line's file
+Type \\[dired-find-file] to Find the current line's file
   (or dired it in another buffer, if it is a directory).
 Type \\[dired-find-file-other-window] to find file or dired directory in Other window.
 Type \\[dired-maybe-insert-subdir] to Insert a subdirectory in this buffer.
@@ -1859,7 +1860,7 @@ Creates a buffer if necessary."
        (error "File no longer exists; type `g' to update dired buffer")))))
 
 ;; Force C-m keybinding rather than `f' or `e' in the mode doc:
-(defalias 'dired-advertised-find-file 'dired-find-file)
+(define-obsolete-function-alias 'dired-advertised-find-file 'dired-find-file "23.2")
 (defun dired-find-file ()
   "In Dired, visit the file or directory named on this line."
   (interactive)
index 64ca561fbe24b221ea0f5b073e37db1207aa7400..a53adf00feac5ecdfcbe757793a267fde1989e4f 100644 (file)
@@ -55,6 +55,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 ;; local variables
 
 (defgroup crisp nil
@@ -205,8 +207,8 @@ does not load the scroll-all package."
 (define-key crisp-mode-map [(meta m)]       'set-mark-command)
 (define-key crisp-mode-map [(meta n)]       'bury-buffer)
 (define-key crisp-mode-map [(meta p)]       'crisp-unbury-buffer)
-(define-key crisp-mode-map [(meta u)]       'advertised-undo)
-(define-key crisp-mode-map [(f14)]          'advertised-undo)
+(define-key crisp-mode-map [(meta u)]       'undo)
+(define-key crisp-mode-map [(f14)]          'undo)
 (define-key crisp-mode-map [(meta w)]       'save-buffer)
 (define-key crisp-mode-map [(meta x)]       'crisp-meta-x-wrapper)
 (define-key crisp-mode-map [(meta ?0)]      (lambda ()
@@ -357,6 +359,9 @@ With ARG, turn CRiSP mode on if ARG is positive, off otherwise."
                       (not crisp-mode)
                     (> (prefix-numeric-value arg) 0)))
   (when crisp-mode
+    ;; Make menu entries show M-u or f14 in preference to C-x u.
+    (put 'undo :advertised-binding
+         (list* [?\M-u] [f14] (get 'undo :advertised-binding)))
     ;; Force transient-mark-mode, so that the marking routines work as
     ;; expected.  If the user turns off transient mark mode, most
     ;; things will still work fine except the crisp-(copy|kill)
index 56c4aaaa5dae503a58eaf70816be6b920ef9be89..5cf4651ad133e7d7df071327ee4f27f8c08e2df5 100644 (file)
@@ -134,7 +134,7 @@ has finished evaluating will signal an error."
 
 (defcustom xscheme-startup-message
   "This is the Scheme process buffer.
-Type \\[advertised-xscheme-send-previous-expression] to evaluate the expression before point.
+Type \\[xscheme-send-previous-expression] to evaluate the expression before point.
 Type \\[xscheme-send-control-g-interrupt] to abort evaluation.
 Type \\[describe-mode] for more information.
 
@@ -158,7 +158,8 @@ When called, the current buffer will be the Scheme process-buffer."
 
 (defun xscheme-evaluation-commands (keymap)
   (define-key keymap "\e\C-x" 'xscheme-send-definition)
-  (define-key keymap "\C-x\C-e" 'advertised-xscheme-send-previous-expression)
+  (define-key keymap "\C-x\C-e" 'xscheme-send-previous-expression)
+  (put 'xscheme-send-previous-expression :advertised-binding "\C-x\C-e")
   (define-key keymap "\eo" 'xscheme-send-buffer)
   (define-key keymap "\ez" 'xscheme-send-definition)
   (define-key keymap "\e\C-m" 'xscheme-send-previous-expression)
@@ -317,7 +318,7 @@ With argument, asks for a command line."
   "Major mode for interacting with an inferior MIT Scheme process.
 Like  scheme-mode  except that:
 
-\\[advertised-xscheme-send-previous-expression] sends the expression before point to the Scheme process as input
+\\[xscheme-send-previous-expression] sends the expression before point to the Scheme process as input
 \\[xscheme-yank-pop] yanks an expression previously sent to Scheme
 \\[xscheme-yank-push] yanks an expression more recently sent to Scheme
 
@@ -475,8 +476,8 @@ with no args, if that value is non-nil.
            (scheme-interaction-mode-initialize)
            (scheme-interaction-mode t)))))
 
-(fset 'advertised-xscheme-send-previous-expression
-      'xscheme-send-previous-expression)
+(define-obsolete-function-alias 'advertised-xscheme-send-previous-expression
+  'xscheme-send-previous-expression "23.2")
 \f
 ;;;; Debugger Mode
 
index c3e7c49e194433aa0e057f8ca6d03a8a050cd6fa..f318d496776ce6c2b3b6fcf33803ec8f97ac0226 100644 (file)
@@ -1610,7 +1610,7 @@ Go to the history element by the absolute history position HIST-POS."
 
 \f
 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
-(defalias 'advertised-undo 'undo)
+(define-obsolete-function-alias 'advertised-undo 'undo "23.2")
 
 (defconst undo-equiv-table (make-hash-table :test 'eq :weakness t)
   "Table mapping redo records to the corresponding undo one.
index a260cd7c57921b8866342621b8db3417c2835a1f..5802b33b6435d03e4dadcea56032540a89908912 100644 (file)
@@ -1841,7 +1841,7 @@ To quit a partially entered command, type Control-g.\n")
                    'action (lambda (button) (help-with-tutorial))
                    'follow-link t)
     (insert (substitute-command-keys
-             "\t   \\[help-with-tutorial]\tUndo changes\t   \\[advertised-undo]\n"))
+             "\t   \\[help-with-tutorial]\tUndo changes\t   \\[undo]\n"))
     (insert-button "Buy manuals"
                    'action (lambda (button) (view-order-manuals))
                    'follow-link t)
index 92412eccd103edd1cf3421dcda749e0121312bbb..378c2e668b95e805a8cb309c9b9f1e9e6334a7ec 100644 (file)
@@ -719,7 +719,7 @@ You can manipulate rectangles with these commands:
   Insert rectangle from named register:           \\[picture-yank-rectangle-from-register]
   Draw a rectangular box around mark and point:   \\[picture-draw-rectangle]
   Copies a rectangle to a register:               \\[copy-rectangle-to-register]
-  Undo effects of rectangle overlay commands:     \\[advertised-undo]
+  Undo effects of rectangle overlay commands:     \\[undo]
 
 You can return to the previous mode with \\[picture-mode-exit], which
 also strips trailing whitespace from every line.  Stripping is suppressed
index 7d6bf1c7c7223c37315d674bd440c9b278d967f4..3290d67a99a276f8af8ecb95a349b5960f50c64c 100644 (file)
@@ -264,8 +264,7 @@ LEFT and RIGHT are the elements to compare."
              (yank-pop [?\M-y])
 
              ;; * UNDO
-             (advertised-undo [?\C-x ?u])
-             (advertised-undo [?\C-x ?u])
+             (undo [?\C-x ?u])
 
              ;; * FILES
              (find-file [?\C-x ?\C-f])
index e9156e729dbce1094f22613149dccbaa92ccfd1e..5a22b371db073b2c940166c8548b78438b4864d3 100644 (file)
@@ -857,14 +857,16 @@ button end points."
 ;; This alias exists only so that one can choose in doc-strings (e.g.
 ;; Custom-mode) which key-binding of widget-keymap one wants to refer to.
 ;; http://lists.gnu.org/archive/html/emacs-devel/2008-11/msg00480.html
-(defalias 'advertised-widget-backward 'widget-backward)
+(define-obsolete-function-alias 'advertised-widget-backward
+  'widget-backward "23.2")
 
 ;;;###autoload
 (defvar widget-keymap
   (let ((map (make-sparse-keymap)))
     (define-key map "\t" 'widget-forward)
     (define-key map "\e\t" 'widget-backward)
-    (define-key map [(shift tab)] 'advertised-widget-backward)
+    (define-key map [(shift tab)] 'widget-backward)
+    (put 'widget-backward :advertised-binding [(shift tab)])
     (define-key map [backtab] 'widget-backward)
     (define-key map [down-mouse-2] 'widget-button-click)
     (define-key map [down-mouse-1] 'widget-button-click)
index 4ffb071272cf09906a55d2f933e60b0cfb7219fe..7f539fd57b5d7d2f0e441302842904fcf07c8a94 100644 (file)
@@ -97,6 +97,7 @@ Lisp_Object Vemulation_mode_map_alists;
 Lisp_Object Vdefine_key_rebound_commands;
 
 Lisp_Object Qkeymapp, Qkeymap, Qnon_ascii, Qmenu_item, Qremap;
+Lisp_Object QCadvertised_binding;
 
 /* Alist of elements like (DEL . "\d").  */
 static Lisp_Object exclude_keys;
@@ -2818,6 +2819,7 @@ remapped command in the returned list.  */)
      because remapping is not done recursively by Fcommand_remapping: you
      can't remap and remapped command.  */
   int remapped = 0;
+  Lisp_Object tem;
 
   /* Refresh the C version of the modifier preference.  */
   where_is_preferred_modifier
@@ -2843,6 +2845,20 @@ remapped command in the returned list.  */)
       && !NILP (Fcommand_remapping (definition, Qnil, keymaps)))
     RETURN_UNGCPRO (Qnil);
 
+  if (SYMBOLP (definition)
+      && !NILP (firstonly)
+      && !NILP (tem = Fget (definition, QCadvertised_binding)))
+    {
+      /* We have a list of advertized bindings.  */
+      while (CONSP (tem))
+       if (EQ (shadow_lookup (keymaps, XCAR (tem), Qnil), definition))
+         return XCAR (tem);
+       else
+         tem = XCDR (tem);
+      if (EQ (shadow_lookup (keymaps, tem, Qnil), definition))
+       return tem;
+    }
+
   sequences = Freverse (where_is_internal (definition, keymaps,
                                           !NILP (noindirect), nomenus));
 
@@ -4036,6 +4052,9 @@ preferred.  */);
   Qremap = intern ("remap");
   staticpro (&Qremap);
 
+  QCadvertised_binding = intern (":advertised-binding");
+  staticpro (&QCadvertised_binding);
+
   command_remapping_vector = Fmake_vector (make_number (2), Qremap);
   staticpro (&command_remapping_vector);