diff lisp/cmdloop.el @ 5208:9fa29ec759e3

Implement suggest-key-bindings in terms of teach-extended-commands-p 2010-04-29 Aidan Kehoe <kehoea@parhasard.net> * 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.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 29 Apr 2010 16:16:47 +0100
parents fd36a980d701
children d27c1ee1943b 308d34e9f07d
line wrap: on
line diff
--- 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'.