# HG changeset patch # User Aidan Kehoe # Date 1272554207 -3600 # Node ID 9fa29ec759e3e23b73e1219018051160287002f9 # Parent 1096ef427b56483139a80b59cc1bc3e107d92886 Implement suggest-key-bindings in terms of teach-extended-commands-p 2010-04-29 Aidan Kehoe * cmdloop.el (suggest-key-bindings): Make this available, documenting that it's for GNU Emacs compatibility. Implement it in terms of teach-extended-commands-p and teach-extended-commands-timeout, using Ben's set-symbol-value-handler functionality. diff -r 1096ef427b56 -r 9fa29ec759e3 lisp/ChangeLog --- a/lisp/ChangeLog Thu Apr 29 15:49:21 2010 +0100 +++ b/lisp/ChangeLog Thu Apr 29 16:16:47 2010 +0100 @@ -1,3 +1,12 @@ +2010-04-29 Aidan Kehoe + + * cmdloop.el (suggest-key-bindings): + Make this available, documenting that it's for GNU Emacs + compatibility. + Implement it in terms of teach-extended-commands-p and + teach-extended-commands-timeout, using Ben's + set-symbol-value-handler functionality. + 2010-04-17 Aidan Kehoe * loadup.el (load-history): Be a bit more discriminate in the diff -r 1096ef427b56 -r 9fa29ec759e3 lisp/cmdloop.el --- a/lisp/cmdloop.el Thu Apr 29 15:49:21 2010 +0100 +++ b/lisp/cmdloop.el Thu Apr 29 16:16:47 2010 +0100 @@ -301,16 +301,31 @@ :group 'keyboard) ;That damn RMS went off and implemented something differently, after -;we had already implemented it. We can't support both properly until -;we have Lisp magic variables. -;(defvar suggest-key-bindings t -; "*FSFmacs equivalent of `teach-extended-commands-*'. -;Provided for compatibility only. -;Non-nil means show the equivalent key-binding when M-x command has one. -;The value can be a length of time to show the message for. -;If the value is non-nil and not a number, we wait 2 seconds.") -; -;(make-obsolete-variable 'suggest-key-bindings 'teach-extended-commands-p) +;we had already implemented it. +(defcustom suggest-key-bindings t + "*FSFmacs equivalent of `teach-extended-commands-p'. +Provided for compatibility only. +Non-nil means show the equivalent key-binding when M-x command has one. +The value can be a length of time to show the message for, in seconds. + +If the value is non-nil and not a number, we wait the number of seconds +specified by `teach-extended-commands-timeout'." + :type '(choice + (const :tag "off" nil) + (integer :tag "time" 2) + (other :tag "on"))) + +(dontusethis-set-symbol-value-handler + 'suggest-key-bindings + 'set-value + #'(lambda (sym args fun harg handler) + (setq args (car args)) + (if (null args) + (setq teach-extended-commands-p nil) + (setq teach-extended-commands-p t + teach-extended-commands-timeout + (or (and (integerp args) args) + (and args teach-extended-commands-timeout)))))) (defun execute-extended-command (prefix-arg) "Read a command name from the minibuffer using 'completing-read'. diff -r 1096ef427b56 -r 9fa29ec759e3 lisp/obsolete.el --- a/lisp/obsolete.el Thu Apr 29 15:49:21 2010 +0100 +++ b/lisp/obsolete.el Thu Apr 29 16:16:47 2010 +0100 @@ -273,6 +273,8 @@ parent) (make-compatible 'set-keymap-parent 'set-keymap-parents) +(make-compatible-variable 'suggest-key-bindings 'teach-extended-commands-p) + ;; too bad there's not a way to check for aref, assq, and nconc ;; being called on the values of functions known to return keymaps, ;; or known to return vectors of events instead of strings...