emacs-diffs
[Top][All Lists]
Advanced

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

scratch/oclosure a9e832df92: Remove support for old-style kbd macros as


From: Stefan Monnier
Subject: scratch/oclosure a9e832df92: Remove support for old-style kbd macros as commands
Date: Tue, 18 Jan 2022 23:11:03 -0500 (EST)

branch: scratch/oclosure
commit a9e832df922ace00f7f9c1af33dde375a8600c6f
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Remove support for old-style kbd macros as commands
    
    * test/lisp/simple-tests.el (command-execute-prune-command-history):
    Avoid old-style kbd macros.
    
    * lisp/replace.el (perform-replace): Don't use the now obsolete second
    arg of `commandp`.
    
    * lisp/macros.el (insert-kbd-macro): Prefer `defalias` over `fset`.
    
    * doc/lispref/commands.texi (Interactive Call): Explain that
    `for-call-interactively` is obsolete.
    (Keyboard Macros): Mention the new `kmacro` function.
    (Command Overview, Interactive Call, Reading One Event):
    * doc/lispref/functions.texi (What Is a Function, Function Cells):
    * doc/lispref/keymaps.texi (Key Lookup): Remove mentions of vectors as
    commands since keyboard macros are normal functions nowadays.
    
    * src/eval.c (Fcommandp): Remove support for old-style kbd macros.
    
    * lisp/subr.el (commandp): Mark `for-call-interactively` as obsolete.
    
    * lisp/simple.el: Use #' to quote named functions.
    (command-execute): Remove support for old-style kbd macros.
    (eval-minibuffer): Obey `lexical-binding`.
    
    * lisp/repeat.el: Use #' to quote named functions.
    (repeat): Remove support for old-style kbd macros.
    
    * lisp/kmacro.el (interactive-form): Fix last change.
---
 doc/lispref/commands.texi  |  39 ++++----
 doc/lispref/functions.texi |   8 +-
 doc/lispref/keymaps.texi   |   6 --
 lisp/apropos.el            |   2 +-
 lisp/calc/calc-ext.el      |   2 +-
 lisp/calc/calc-prog.el     |   2 +-
 lisp/help.el               |   2 +-
 lisp/kmacro.el             |   2 +-
 lisp/macros.el             |   5 +-
 lisp/repeat.el             |  21 ++---
 lisp/replace.el            |   2 +-
 lisp/simple.el             | 226 ++++++++++++++++++++++-----------------------
 lisp/subr.el               |   1 +
 lisp/vc/emerge.el          |   2 +-
 src/eval.c                 |  15 +--
 test/lisp/simple-tests.el  |   2 +-
 16 files changed, 156 insertions(+), 181 deletions(-)

diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 0f12fa7241..4227f40081 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -46,7 +46,7 @@ input with @code{discard-input} (@pxref{Event Input Misc}).
 
   The key sequence is translated into a command through the currently
 active keymaps.  @xref{Key Lookup}, for information on how this is done.
-The result should be a keyboard macro or an interactively callable
+The result should be an interactively callable
 function.  If the key is @kbd{M-x}, then it reads the name of another
 command, which it then calls.  This is done by the command
 @code{execute-extended-command} (@pxref{Interactive Call}).
@@ -66,10 +66,6 @@ use the minibuffer, so if you call @code{find-file} as a 
function from
 Lisp code, you must supply the file name string as an ordinary Lisp
 function argument.
 
-  If the command is a keyboard macro (i.e., a string or vector),
-Emacs executes it using @code{execute-kbd-macro} (@pxref{Keyboard
-Macros}).
-
 @defvar pre-command-hook
 This normal hook is run by the editor command loop before it executes
 each command.  At that time, @code{this-command} contains the command
@@ -721,16 +717,15 @@ the command is a function, @code{command-execute} calls
 command.  You can also call these functions yourself.
 
   Note that the term ``command'', in this context, refers to an
-interactively callable function (or function-like object), or a
-keyboard macro.  It does not refer to the key sequence used to invoke
+interactively callable function (or function-like object).
+It does not refer to the key sequence used to invoke
 a command (@pxref{Keymaps}).
 
 @defun commandp object &optional for-call-interactively
 This function returns @code{t} if @var{object} is a command.
 Otherwise, it returns @code{nil}.
 
-Commands include strings and vectors (which are treated as keyboard
-macros), lambda expressions that contain a top-level
+Commands include lambda expressions that contain a top-level
 @code{interactive} form (@pxref{Using Interactive}), byte-code
 function objects made from such lambda expressions, autoload objects
 that are declared as interactive (non-@code{nil} fourth argument to
@@ -739,9 +734,8 @@ considered a command if it has a non-@code{nil}
 @code{interactive-form} property, or if its function definition
 satisfies @code{commandp}.
 
-If @var{for-call-interactively} is non-@code{nil}, then
-@code{commandp} returns @code{t} only for objects that
-@code{call-interactively} could call---thus, not for keyboard macros.
+@var{for-call-interactively} is an obsolete argument which is not used
+any more.
 
 See @code{documentation} in @ref{Accessing Documentation}, for a
 realistic example of using @code{commandp}.
@@ -770,9 +764,7 @@ will call @code{foo} with the region (@code{point} and 
@code{mark}) as
 the arguments.
 
 An error is signaled if @var{command} is not a function or if it
-cannot be called interactively (i.e., is not a command).  Note that
-keyboard macros (strings and vectors) are not accepted, even though
-they are considered commands, because they are not functions.  If
+cannot be called interactively (i.e., is not a command).  If
 @var{command} is a symbol, then @code{call-interactively} uses its
 function definition.
 
@@ -801,7 +793,7 @@ signaling an error.
 @cindex keyboard macro execution
 This function executes @var{command}.  The argument @var{command} must
 satisfy the @code{commandp} predicate; i.e., it must be an interactively
-callable function or a keyboard macro.
+callable function.
 
 A string or vector as @var{command} is executed with
 @code{execute-kbd-macro}.  A function is passed to
@@ -2980,7 +2972,7 @@ displays its return value in the echo area.
 @group
 ;; @r{We assume here you use @kbd{M-:} to evaluate this.}
 (symbol-function 'foo)
-     @result{} "^[:(read-char)^M1"
+     @result{} #f(kmacro "M-: ( r e a d - c h a r ) RET 1")
 @end group
 @group
 (execute-kbd-macro 'foo)
@@ -3978,8 +3970,9 @@ minibuffer, the usual minibuffer history commands are 
available.
 @section Keyboard Macros
 @cindex keyboard macros
 
-  A @dfn{keyboard macro} is a canned sequence of input events that can
-be considered a command and made the definition of a key.  The Lisp
+  A @dfn{keyboard macro} is a canned sequence of input events.  It can
+be converted into a command (with the #code{kmacro} function) and made
+the definition of a key.  The Lisp
 representation of a keyboard macro is a string or vector containing the
 events.  Don't confuse keyboard macros with Lisp macros
 (@pxref{Macros}).
@@ -4008,6 +4001,14 @@ without arguments, prior to each iteration of the macro. 
 If
 @xref{Reading One Event}, for an example of using @code{execute-kbd-macro}.
 @end defun
 
+@defun kmacro keys &optional counter format
+This function takes a vector @var{keys} of events (or a string
+satisfying @code{key-valid-p}) and returns a command that will execute
+them in sequence when called.  The optional variables @var{counter}
+and @var{format} default respectively to @code{0} and @code{"%d"} and
+are used by @code{kmacro-insert-counter} to insert numbers in sequence.
+@end defun
+
 @defvar executing-kbd-macro
 This variable contains the string or vector that defines the keyboard
 macro that is currently executing.  It is @code{nil} if no macro is
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 96fecc8c89..bb2459d4aa 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -116,8 +116,8 @@ into a command by an @code{interactive} form in the function
 definition (@pxref{Defining Commands}).  Commands that are functions
 can also be called from Lisp expressions, just like other functions.
 
-Keyboard macros (strings and vectors) are commands also, even though
-they are not functions.  @xref{Keyboard Macros}.  We say that a symbol
+Keyboard macros are commands also.  @xref{Keyboard Macros}.
+We say that a symbol
 is a command if its function cell contains a command (@pxref{Symbol
 Components}); such a @dfn{named command} can be invoked with
 @kbd{M-x}.
@@ -1442,11 +1442,11 @@ argument.
 The primary use of this function is as a subroutine by constructs that define
 or alter functions, like @code{defun} or @code{advice-add} (@pxref{Advising
 Functions}).  You can also use it to give a symbol a function definition that
-is not a function, e.g., a keyboard macro (@pxref{Keyboard Macros}):
+is a keyboard macro (@pxref{Keyboard Macros}):
 
 @example
 ;; @r{Define a named keyboard macro.}
-(fset 'kill-two-lines "\^u2\^k")
+(fset 'kill-two-lines (kmacro "C-u 2 C-k"))
      @result{} "\^u2\^k"
 @end example
 
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi
index 9d3dc8fe42..4f4308b455 100644
--- a/doc/lispref/keymaps.texi
+++ b/doc/lispref/keymaps.texi
@@ -1116,12 +1116,6 @@ for that event type.
 The events used so far in the lookup form a complete key,
 and @var{command} is its binding.  @xref{What Is a Function}.
 
-@item @var{array}
-@cindex string in keymap
-The array (either a string or a vector) is a keyboard macro.  The events
-used so far in the lookup form a complete key, and the array is its
-binding.  See @ref{Keyboard Macros}, for more information.
-
 @item @var{keymap}
 @cindex keymap in keymap
 The events used so far in the lookup form a prefix key.  The next
diff --git a/lisp/apropos.el b/lisp/apropos.el
index 6ff444f868..2d77d26ba6 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -594,7 +594,7 @@ while a list of strings is used as a word list."
                                 ;; We used to use `functionp' here, but this
                                 ;; rules out macros.  `fboundp' rules in
                                 ;; keymaps, but it seems harmless.
-                               (if do-all 'fboundp 'commandp))))
+                               (if do-all #'fboundp #'commandp))))
     (let ((tem apropos-accumulator))
       (while tem
        (if (or (get (car tem) 'apropos-inhibit)
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index 7ee73d100a..d7e76e570f 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -1727,7 +1727,7 @@ calc-kill calc-kill-region calc-yank))))
   (interactive "P")
   (let* ((prompt (concat (calc-num-prefix-name n) "M-x "))
         (cmd (intern
-               (completing-read prompt obarray 'commandp t "calc-"
+               (completing-read prompt obarray #'commandp t "calc-"
                                 'calc-extended-command-history))))
     (setq prefix-arg n)
     (command-execute cmd)))
diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el
index dc2a086bbd..a31aa9d962 100644
--- a/lisp/calc/calc-prog.el
+++ b/lisp/calc/calc-prog.el
@@ -138,7 +138,7 @@
                                                 (char-to-string key)
                                                 " to command: ")
                                         obarray
-                                        'commandp
+                                        #'commandp
                                         t
                                         "calc-"))))
       (let* ((kmap (calc-user-key-map))
diff --git a/lisp/help.el b/lisp/help.el
index 0ac5e7f9eb..b44a2072c0 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -621,7 +621,7 @@ If INSERT (the prefix arg) is non-nil, insert the message 
in the buffer."
         (enable-recursive-minibuffers t)
         val)
      (setq val (completing-read (format-prompt "Where is command" fn)
-                               obarray 'commandp t nil nil
+                               obarray #'commandp t nil nil
                                (and fn (symbol-name fn))))
      (list (unless (equal val "") (intern val))
           current-prefix-arg)))
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index e8883ad77f..af29a07147 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -825,7 +825,7 @@ If kbd macro currently being defined end it before 
activating it."
       (execute-kbd-macro keys arg #'kmacro-loop-setup-function)
       (setq counter kmacro-counter))))
 
-(cl-defmethod interactive-form ((_ kmacro)) '(interactive "p"))
+(cl-defmethod interactive-form ((_ kmacro) &optional _) '(interactive "p"))
 
 ;;;###autoload
 (defun kmacro-lambda-form (mac &optional counter format)
diff --git a/lisp/macros.el b/lisp/macros.el
index e2f5435441..3f3a9f1770 100644
--- a/lisp/macros.el
+++ b/lisp/macros.el
@@ -82,7 +82,10 @@ use this command, and then save the file."
          (setq macroname 'last-kbd-macro definition last-kbd-macro)
          (insert "(setq "))
       (setq definition (symbol-function macroname))
-      (insert "(fset '"))
+      ;; Prefer `defalias' over `fset' since it additionally keeps
+      ;; track of the file where the users added it, and it interacts
+      ;; better with `advice-add' (and hence things like ELP).
+      (insert "(defalias '"))
     (prin1 macroname (current-buffer))
     (insert "\n   ")
     (when (stringp definition)
diff --git a/lisp/repeat.el b/lisp/repeat.el
index aaccc22784..979c597e31 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -242,7 +242,7 @@ recently executed command not bound to an input event\"."
     (if (eq last-repeatable-command (caar command-history))
         (let ((repeat-command (car command-history)))
           (repeat-message "Repeating %S" repeat-command)
-          (eval repeat-command))
+          (eval repeat-command t))
       (if (null repeat-arg)
           (repeat-message "Repeating command %S" last-repeatable-command)
         (setq current-prefix-arg repeat-arg)
@@ -265,14 +265,7 @@ recently executed command not bound to an input event\"."
         ;;                     "inserted before auto-fill"
         ;;                     "clobbered it, sorry")))))
         (setq last-command-event (char-before)))
-      (let ((indirect (indirect-function last-repeatable-command)))
-        (if (or (stringp indirect)
-                (vectorp indirect))
-            ;; Bind last-repeatable-command so that executing the macro does
-            ;; not alter it.
-            (let ((last-repeatable-command last-repeatable-command))
-              (execute-kbd-macro last-repeatable-command))
-          (call-interactively last-repeatable-command))))
+      (call-interactively last-repeatable-command))
     (when repeat-repeat-char
       (set-transient-map
        (let ((map (make-sparse-keymap)))
@@ -294,7 +287,7 @@ recently executed command not bound to an input event\"."
 
 (defun repeat-message (format &rest args)
   "Like `message' but displays with `repeat-message-function' if non-nil."
-  (let ((message (apply 'format format args)))
+  (let ((message (apply #'format format args)))
     (if repeat-message-function
         (funcall repeat-message-function message)
       (message "%s" message))))
@@ -410,8 +403,8 @@ When Repeat mode is enabled, and the command symbol has the 
property named
 See `describe-repeat-maps' for a list of all repeatable commands."
   :global t :group 'convenience
   (if (not repeat-mode)
-      (remove-hook 'post-command-hook 'repeat-post-hook)
-    (add-hook 'post-command-hook 'repeat-post-hook)
+      (remove-hook 'post-command-hook #'repeat-post-hook)
+    (add-hook 'post-command-hook #'repeat-post-hook)
     (let* ((keymaps nil)
            (commands (all-completions
                       "" obarray (lambda (s)
@@ -466,7 +459,7 @@ See `describe-repeat-maps' for a list of all repeatable 
commands."
 
               ;; Adding an exit key
               (when repeat-exit-key
-                (define-key map repeat-exit-key 'ignore))
+                (define-key map repeat-exit-key #'ignore))
 
               (when (and repeat-keep-prefix (not prefix-arg))
                 (setq prefix-arg current-prefix-arg))
@@ -562,7 +555,7 @@ Used in `repeat-mode'."
           (dolist (keymap (sort keymaps (lambda (a b) (string-lessp (car a) 
(car b)))))
             (princ (format-message "`%s' keymap is repeatable by these 
commands:\n"
                                    (car keymap)))
-            (dolist (command (sort (cdr keymap) 'string-lessp))
+            (dolist (command (sort (cdr keymap) #'string-lessp))
               (let* ((info (help-fns--analyze-function command))
                      (map (list (symbol-value (car keymap))))
                      (desc (mapconcat (lambda (key)
diff --git a/lisp/replace.el b/lisp/replace.el
index 60e507c642..ff6a20db84 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -3249,7 +3249,7 @@ characters."
                         (replace-dehighlight)
                         (save-excursion (recursive-edit))
                         (setq replaced t))
-                        ((commandp def t)
+                        ((commandp def)
                          (call-interactively def))
                        ;; Note: we do not need to treat `exit-prefix'
                        ;; specially here, since we reread
diff --git a/lisp/simple.el b/lisp/simple.el
index d44f90adcb..68210f9930 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -424,8 +424,8 @@ where `next-error-function' is bound to an appropriate 
function."
                        (lambda (b) (next-error-buffer-p (cdr b)))))))
   (setq next-error-last-buffer buffer))
 
-(defalias 'goto-next-locus 'next-error)
-(defalias 'next-match 'next-error)
+(defalias 'goto-next-locus #'next-error)
+(defalias 'next-match #'next-error)
 
 (defun previous-error (&optional n)
   "Visit previous `next-error' message and corresponding source code.
@@ -479,8 +479,10 @@ When turned on, cursor motion in the compilation, grep, 
occur or diff
 buffer causes automatic display of the corresponding source code location."
   :group 'next-error :init-value nil :lighter " Fol"
   (if (not next-error-follow-minor-mode)
-      (remove-hook 'post-command-hook 
'next-error-follow-mode-post-command-hook t)
-    (add-hook 'post-command-hook 'next-error-follow-mode-post-command-hook nil 
t)
+      (remove-hook 'post-command-hook
+                   #'next-error-follow-mode-post-command-hook t)
+    (add-hook 'post-command-hook #'next-error-follow-mode-post-command-hook
+              nil t)
     (make-local-variable 'next-error-follow-last-line)))
 
 ;; Used as a `post-command-hook' by `next-error-follow-mode'
@@ -1503,7 +1505,7 @@ END, without printing any message."
             words (if (= words 1) "" "s")
             chars (if (= chars 1) "" "s"))))
 
-(define-obsolete-function-alias 'count-lines-region 'count-words-region "24.1")
+(define-obsolete-function-alias 'count-lines-region #'count-words-region 
"24.1")
 
 (defun what-line ()
   "Print the current buffer line number and narrowed line number of point."
@@ -1693,13 +1695,13 @@ in *Help* buffer.  See also the command 
`describe-char'."
 ;; Initialize read-expression-map.  It is defined at C level.
 (defvar read-expression-map
   (let ((m (make-sparse-keymap)))
-    (define-key m "\M-\t" 'completion-at-point)
+    (define-key m "\M-\t" #'completion-at-point)
     ;; Might as well bind TAB to completion, since inserting a TAB char is
     ;; much too rarely useful.
-    (define-key m "\t" 'completion-at-point)
-    (define-key m "\r" 'read--expression-try-read)
-    (define-key m "\n" 'read--expression-try-read)
-    (define-key m "\M-g\M-c" 'read-expression-switch-to-completions)
+    (define-key m "\t" #'completion-at-point)
+    (define-key m "\r" #'read--expression-try-read)
+    (define-key m "\n" #'read--expression-try-read)
+    (define-key m "\M-g\M-c" #'read-expression-switch-to-completions)
     (set-keymap-parent m minibuffer-local-map)
     m))
 
@@ -1720,7 +1722,7 @@ is a string to insert in the minibuffer before reading.
 \(INITIAL-CONTENTS can also be a cons of a string and an integer.
 Such arguments are used as in `read-from-minibuffer'.)"
   ;; Used for interactive spec `X'.
-  (eval (read--expression prompt initial-contents)))
+  (eval (read--expression prompt initial-contents) lexical-binding))
 
 (defvar minibuffer-completing-symbol nil
   "Non-nil means completing a Lisp symbol in the minibuffer.")
@@ -1933,7 +1935,7 @@ the minibuffer, then read and evaluate the result."
                (pop command-history))))))
 
     (add-to-history 'command-history command)
-    (eval command)))
+    (eval command t)))
 
 (defun repeat-complex-command (arg)
   "Edit and re-evaluate last complex command, or ARGth from last.
@@ -2200,7 +2202,7 @@ Also see `suggest-key-bindings'."
       (let ((candidate (pop candidates)))
         (when (equal name
                        (car-safe (completion-try-completion
-                                  candidate obarray 'commandp len)))
+                                  candidate obarray #'commandp len)))
           (setq binding candidate))))
     binding))
 
@@ -2408,42 +2410,32 @@ The argument SPECIAL, if non-nil, means that this 
command is
 executing a special event, so ignore the prefix argument and
 don't clear it."
   (setq debug-on-next-call nil)
-  (let ((prefixarg (unless special
-                     ;; FIXME: This should probably be done around
-                     ;; pre-command-hook rather than here!
-                     (prog1 prefix-arg
-                       (setq current-prefix-arg prefix-arg)
-                       (setq prefix-arg nil)
-                       (when current-prefix-arg
-                         (prefix-command-update))))))
-    (if (and (symbolp cmd)
-             (get cmd 'disabled)
-             disabled-command-function)
-        ;; FIXME: Weird calling convention!
-        (run-hooks 'disabled-command-function)
-      (let ((final cmd))
-        (while
-            (progn
-              (setq final (indirect-function final))
-              (if (autoloadp final)
-                  (setq final (autoload-do-load final cmd)))))
-        (cond
-         ((arrayp final)
-          ;; If requested, place the macro in the command history.  For
-          ;; other sorts of commands, call-interactively takes care of this.
-          (when record-flag
-            (add-to-history
-             'command-history `(execute-kbd-macro ,final ,prefixarg) nil t))
-          (execute-kbd-macro final prefixarg))
-         (t
-          ;; Pass `cmd' rather than `final', for the backtrace's sake.
-          (prog1 (call-interactively cmd record-flag keys)
-            (when (and (symbolp cmd)
-                       (get cmd 'byte-obsolete-info)
-                       (not (get cmd 'command-execute-obsolete-warned)))
-              (put cmd 'command-execute-obsolete-warned t)
-              (message "%s" (macroexp--obsolete-warning
-                             cmd (get cmd 'byte-obsolete-info) 
"command"))))))))))
+  (unless special
+    ;; FIXME: This should probably be done around
+    ;; pre-command-hook rather than here!
+    (setq current-prefix-arg prefix-arg)
+    (setq prefix-arg nil)
+    (when current-prefix-arg
+      (prefix-command-update)))
+  (if (and (symbolp cmd)
+           (get cmd 'disabled)
+           disabled-command-function)
+      ;; FIXME: Weird calling convention!
+      (run-hooks 'disabled-command-function)
+    (let ((final cmd))
+      (while
+          (progn
+            (setq final (indirect-function final))
+            (if (autoloadp final)
+                (setq final (autoload-do-load final cmd)))))
+      ;; Pass `cmd' rather than `final', for the backtrace's sake.
+      (prog1 (call-interactively cmd record-flag keys)
+        (when (and (symbolp cmd)
+                   (get cmd 'byte-obsolete-info)
+                   (not (get cmd 'command-execute-obsolete-warned)))
+          (put cmd 'command-execute-obsolete-warned t)
+          (message "%s" (macroexp--obsolete-warning
+                         cmd (get cmd 'byte-obsolete-info) "command")))))))
 
 (defvar minibuffer-history nil
   "Default minibuffer history list.
@@ -2467,7 +2459,7 @@ recursive uses of the minibuffer.)")
 This is nil if there have not yet been any history commands
 in this use of the minibuffer.")
 
-(add-hook 'minibuffer-setup-hook 'minibuffer-history-initialize)
+(add-hook 'minibuffer-setup-hook #'minibuffer-history-initialize)
 
 (defun minibuffer-history-initialize ()
   (setq minibuffer-text-before-history nil))
@@ -2838,7 +2830,7 @@ Return 0 if current buffer is not a minibuffer."
   (1- (minibuffer-prompt-end)))
 
 ;; isearch minibuffer history
-(add-hook 'minibuffer-setup-hook 'minibuffer-history-isearch-setup)
+(add-hook 'minibuffer-setup-hook #'minibuffer-history-isearch-setup)
 
 (defvar minibuffer-history-isearch-message-overlay)
 (make-variable-buffer-local 'minibuffer-history-isearch-message-overlay)
@@ -2854,7 +2846,7 @@ Intended to be added to `minibuffer-setup-hook'."
               #'minibuffer-history-isearch-wrap)
   (setq-local isearch-push-state-function
               #'minibuffer-history-isearch-push-state)
-  (add-hook 'isearch-mode-end-hook 'minibuffer-history-isearch-end nil t))
+  (add-hook 'isearch-mode-end-hook #'minibuffer-history-isearch-end nil t))
 
 (defun minibuffer-history-isearch-end ()
   "Clean up the minibuffer after terminating isearch in the minibuffer."
@@ -2959,11 +2951,11 @@ Go to the history element by the absolute history 
position HIST-POS."
   (goto-history-element hist-pos))
 
 
-(add-hook 'minibuffer-setup-hook 'minibuffer-error-initialize)
+(add-hook 'minibuffer-setup-hook #'minibuffer-error-initialize)
 
 (defun minibuffer-error-initialize ()
   "Set up minibuffer error processing."
-  (setq-local command-error-function 'minibuffer-error-function))
+  (setq-local command-error-function #'minibuffer-error-function))
 
 (defun minibuffer-error-function (data context caller)
   "Display error messages in the active minibuffer.
@@ -2985,9 +2977,9 @@ the minibuffer contents."
 
 
 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
-(define-obsolete-function-alias 'advertised-undo 'undo "23.2")
+(define-obsolete-function-alias 'advertised-undo #'undo "23.2")
 
-(defconst undo-equiv-table (make-hash-table :test 'eq :weakness t)
+(defconst undo-equiv-table (make-hash-table :test #'eq :weakness t)
   "Table mapping redo records to the corresponding undo one.
 A redo record for an undo in region maps to 'undo-in-region.
 A redo record for ordinary undo maps to the following (earlier) undo.
@@ -3342,7 +3334,7 @@ Return what remains of the list."
 ;; Deep copy of a list
 (defun undo-copy-list (list)
   "Make a copy of undo list LIST."
-  (mapcar 'undo-copy-list-1 list))
+  (mapcar #'undo-copy-list-1 list))
 
 (defun undo-copy-list-1 (elt)
   (if (consp elt)
@@ -3811,7 +3803,7 @@ This variable matters only if `undo-ask-before-discard' 
is non-nil.")
 ;; the undo info for the current command was discarded.  Garbage
 ;; collection is inhibited around the call, so it had better not do a
 ;; lot of consing.
-(setq undo-outer-limit-function 'undo-outer-limit-truncate)
+(setq undo-outer-limit-function #'undo-outer-limit-truncate)
 (defun undo-outer-limit-truncate (size)
   (if undo-ask-before-discard
       (when (or (null undo-extra-outer-limit)
@@ -3903,7 +3895,7 @@ to the end of the list of defaults just after the default 
value."
 (defvar minibuffer-local-shell-command-map
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
-    (define-key map "\t" 'completion-at-point)
+    (define-key map "\t" #'completion-at-point)
     map)
   "Keymap used for completing shell commands in minibuffer.")
 
@@ -4673,7 +4665,7 @@ value passed."
           (setq stderr-file (when (and (consp buffer) (stringp (cadr buffer)))
                               (make-temp-file "emacs")))
           (prog1
-              (apply 'call-process program
+              (apply #'call-process program
                      (or lc infile)
                      (if stderr-file (list (car buffer) stderr-file) buffer)
                      display args)
@@ -4725,7 +4717,7 @@ by calling `file-local-name', in case they are remote 
file names.
 File name handlers might not support pty association, if PROGRAM is nil."
   (let ((fh (find-file-name-handler default-directory 'start-file-process)))
     (if fh (apply fh 'start-file-process name buffer program program-args)
-      (apply 'start-process name buffer program program-args))))
+      (apply #'start-process name buffer program program-args))))
 
 ;;;; Process menu
 
@@ -4740,7 +4732,7 @@ File name handlers might not support pty association, if 
PROGRAM is nil."
 
 (defvar process-menu-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [?d] 'process-menu-delete-process)
+    (define-key map [?d] #'process-menu-delete-process)
     map))
 
 (define-derived-mode process-menu-mode tabulated-list-mode "Process Menu"
@@ -4756,7 +4748,7 @@ File name handlers might not support pty association, if 
PROGRAM is nil."
                               ("Command"  0 t)])
   (make-local-variable 'process-menu-query-only)
   (setq tabulated-list-sort-key (cons "Process" nil))
-  (add-hook 'tabulated-list-revert-hook 'list-processes--refresh nil t))
+  (add-hook 'tabulated-list-revert-hook #'list-processes--refresh nil t))
 
 (defun process-menu-delete-process ()
   "Kill process at point in a `list-processes' buffer."
@@ -4830,7 +4822,7 @@ Also, delete any process that is exited or signaled."
                                     (if speed
                                         (format " at %s b/s" speed)
                                       "")))))
-                    (mapconcat 'identity (process-command p) " "))))
+                    (mapconcat #'identity (process-command p) " "))))
             (push (list p (vector name pid status buf-label tty thread cmd))
                   tabulated-list-entries)))))
   (tabulated-list-init-header))
@@ -4943,28 +4935,28 @@ Runs `prefix-command-preserve-state-hook'."
     (define-key map [switch-frame]
       (lambda (e) (interactive "e")
         (handle-switch-frame e) (universal-argument--mode)))
-    (define-key map [?\C-u] 'universal-argument-more)
+    (define-key map [?\C-u] #'universal-argument-more)
     (define-key map [?-] universal-argument-minus)
-    (define-key map [?0] 'digit-argument)
-    (define-key map [?1] 'digit-argument)
-    (define-key map [?2] 'digit-argument)
-    (define-key map [?3] 'digit-argument)
-    (define-key map [?4] 'digit-argument)
-    (define-key map [?5] 'digit-argument)
-    (define-key map [?6] 'digit-argument)
-    (define-key map [?7] 'digit-argument)
-    (define-key map [?8] 'digit-argument)
-    (define-key map [?9] 'digit-argument)
-    (define-key map [kp-0] 'digit-argument)
-    (define-key map [kp-1] 'digit-argument)
-    (define-key map [kp-2] 'digit-argument)
-    (define-key map [kp-3] 'digit-argument)
-    (define-key map [kp-4] 'digit-argument)
-    (define-key map [kp-5] 'digit-argument)
-    (define-key map [kp-6] 'digit-argument)
-    (define-key map [kp-7] 'digit-argument)
-    (define-key map [kp-8] 'digit-argument)
-    (define-key map [kp-9] 'digit-argument)
+    (define-key map [?0] #'digit-argument)
+    (define-key map [?1] #'digit-argument)
+    (define-key map [?2] #'digit-argument)
+    (define-key map [?3] #'digit-argument)
+    (define-key map [?4] #'digit-argument)
+    (define-key map [?5] #'digit-argument)
+    (define-key map [?6] #'digit-argument)
+    (define-key map [?7] #'digit-argument)
+    (define-key map [?8] #'digit-argument)
+    (define-key map [?9] #'digit-argument)
+    (define-key map [kp-0] #'digit-argument)
+    (define-key map [kp-1] #'digit-argument)
+    (define-key map [kp-2] #'digit-argument)
+    (define-key map [kp-3] #'digit-argument)
+    (define-key map [kp-4] #'digit-argument)
+    (define-key map [kp-5] #'digit-argument)
+    (define-key map [kp-6] #'digit-argument)
+    (define-key map [kp-7] #'digit-argument)
+    (define-key map [kp-8] #'digit-argument)
+    (define-key map [kp-9] #'digit-argument)
     (define-key map [kp-subtract] universal-argument-minus)
     map)
   "Keymap used while processing \\[universal-argument].")
@@ -7822,13 +7814,13 @@ the variable `line-move-visual'."
 
 (defvar visual-line-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [remap kill-line] 'kill-visual-line)
-    (define-key map [remap move-beginning-of-line] 'beginning-of-visual-line)
-    (define-key map [remap move-end-of-line]  'end-of-visual-line)
+    (define-key map [remap kill-line] #'kill-visual-line)
+    (define-key map [remap move-beginning-of-line] #'beginning-of-visual-line)
+    (define-key map [remap move-end-of-line]  #'end-of-visual-line)
     ;; These keybindings interfere with xterm function keys.  Are
     ;; there any other suitable bindings?
-    ;; (define-key map "\M-[" 'previous-logical-line)
-    ;; (define-key map "\M-]" 'next-logical-line)
+    ;; (define-key map "\M-[" #'previous-logical-line)
+    ;; (define-key map "\M-]" #'next-logical-line)
     map))
 
 (defcustom visual-line-fringe-indicators '(nil nil)
@@ -8154,7 +8146,7 @@ constitute a word."
                 string)
   :group 'fill)
 (make-variable-buffer-local 'fill-prefix)
-(put 'fill-prefix 'safe-local-variable 'string-or-null-p)
+(put 'fill-prefix 'safe-local-variable #'string-or-null-p)
 
 (defcustom auto-fill-inhibit-regexp nil
   "Regexp to match lines that should not be auto-filled."
@@ -8248,7 +8240,7 @@ Returns t if it really did any work."
       (justify-current-line justify t t)
       t)))
 
-(defvar comment-line-break-function 'comment-indent-new-line
+(defvar comment-line-break-function #'comment-indent-new-line
   "Mode-specific function that line breaks and continues a comment.
 This function is called during auto-filling when a comment syntax
 is defined.
@@ -8296,15 +8288,15 @@ unless optional argument SOFT is non-nil."
             (nth 4 (syntax-ppss)))
     (funcall auto-fill-function)))
 
-(defvar normal-auto-fill-function 'do-auto-fill
+(defvar normal-auto-fill-function #'do-auto-fill
   "The function to use for `auto-fill-function' if Auto Fill mode is turned on.
 Some major modes set this.")
 
-(put 'auto-fill-function :minor-mode-function 'auto-fill-mode)
+(put 'auto-fill-function :minor-mode-function #'auto-fill-mode)
 ;; `functions' and `hooks' are usually unsafe to set, but setting
 ;; auto-fill-function to nil in a file-local setting is safe and
 ;; can be useful to prevent auto-filling.
-(put 'auto-fill-function 'safe-local-variable 'null)
+(put 'auto-fill-function 'safe-local-variable #'null)
 
 (define-minor-mode auto-fill-mode
   "Toggle automatic line breaking (Auto Fill mode).
@@ -8925,7 +8917,7 @@ You have the following Mail mode variable%s customized:
 \n  %s\n\nTo use Mail mode, set `mail-user-agent' to sendmail-user-agent.
 To disable this warning, set `compose-mail-user-agent-warnings' to nil."
                                    (if (> (length warn-vars) 1) "s" "")
-                                   (mapconcat 'symbol-name
+                                   (mapconcat #'symbol-name
                                               warn-vars " "))))))
 
   (let ((function (get mail-user-agent 'composefunc)))
@@ -9044,20 +9036,20 @@ makes it easier to edit it."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map special-mode-map)
     (define-key map "g" nil) ;; There's nothing to revert from.
-    (define-key map [mouse-2] 'choose-completion)
+    (define-key map [mouse-2]  #'choose-completion)
     (define-key map [follow-link] 'mouse-face)
     (define-key map [down-mouse-2] nil)
-    (define-key map "\C-m" 'choose-completion)
-    (define-key map "\e\e\e" 'delete-completion-window)
+    (define-key map "\C-m"     #'choose-completion)
+    (define-key map "\e\e\e"   #'delete-completion-window)
     (define-key map [remap keyboard-quit] #'delete-completion-window)
-    (define-key map [left] 'previous-completion)
-    (define-key map [right] 'next-completion)
-    (define-key map [?\t] 'next-completion)
-    (define-key map [backtab] 'previous-completion)
-    (define-key map "z" 'kill-current-buffer)
-    (define-key map "n" 'next-completion)
-    (define-key map "p" 'previous-completion)
-    (define-key map "\M-g\M-c" 'switch-to-minibuffer)
+    (define-key map [left]     #'previous-completion)
+    (define-key map [right]    #'next-completion)
+    (define-key map [?\t]      #'next-completion)
+    (define-key map [backtab]  #'previous-completion)
+    (define-key map "z"        #'kill-current-buffer)
+    (define-key map "n"        #'next-completion)
+    (define-key map "p"        #'previous-completion)
+    (define-key map "\M-g\M-c" #'switch-to-minibuffer)
     map)
   "Local map for completion list buffers.")
 
@@ -9315,7 +9307,7 @@ Called from `temp-buffer-show-hook'."
   (when (eq major-mode 'completion-list-mode)
     (setq buffer-read-only t)))
 
-(add-hook 'temp-buffer-show-hook 'completion-list-mode-finish)
+(add-hook 'temp-buffer-show-hook #'completion-list-mode-finish)
 
 
 ;; Variables and faces used in `completion-setup-function'.
@@ -9463,12 +9455,12 @@ PREFIX is the string that represents this modifier in 
an event type symbol."
            event-type
          (cons event-type (cdr event)))))))
 
-(define-key function-key-map [?\C-x ?@ ?h] 'event-apply-hyper-modifier)
-(define-key function-key-map [?\C-x ?@ ?s] 'event-apply-super-modifier)
-(define-key function-key-map [?\C-x ?@ ?m] 'event-apply-meta-modifier)
-(define-key function-key-map [?\C-x ?@ ?a] 'event-apply-alt-modifier)
-(define-key function-key-map [?\C-x ?@ ?S] 'event-apply-shift-modifier)
-(define-key function-key-map [?\C-x ?@ ?c] 'event-apply-control-modifier)
+(define-key function-key-map [?\C-x ?@ ?h] #'event-apply-hyper-modifier)
+(define-key function-key-map [?\C-x ?@ ?s] #'event-apply-super-modifier)
+(define-key function-key-map [?\C-x ?@ ?m] #'event-apply-meta-modifier)
+(define-key function-key-map [?\C-x ?@ ?a] #'event-apply-alt-modifier)
+(define-key function-key-map [?\C-x ?@ ?S] #'event-apply-shift-modifier)
+(define-key function-key-map [?\C-x ?@ ?c] #'event-apply-control-modifier)
 
 ;;;; Keypad support.
 
@@ -9530,8 +9522,8 @@ Returns nil if PROCESS has already terminated."
                  (setq args (plist-put args :buffer
                                        (if (process-buffer process)
                                            (current-buffer))))
-                 (apply 'make-network-process args))
-             (apply 'start-process newname
+                 (apply #'make-network-process args))
+             (apply #'start-process newname
                     (if (process-buffer process) (current-buffer))
                     (process-command process)))))
       (set-process-query-on-exit-flag
@@ -9923,7 +9915,7 @@ warning using STRING as the message.")
         (and list
              (boundp symbol)
              (or (eq symbol t)
-                 (and (stringp (setq symbol (eval symbol)))
+                 (and (stringp (setq symbol (symbol-value symbol)))
                       (string-match-p (nth 2 list) symbol)))
              (display-warning package (nth 3 list) :warning)))
     (error nil)))
diff --git a/lisp/subr.el b/lisp/subr.el
index 7906324f80..52611240a1 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1781,6 +1781,7 @@ be a list of the form returned by `event-start' and 
`event-end'."
 (set-advertised-calling-convention
  'all-completions '(string collection &optional predicate) "23.1")
 (set-advertised-calling-convention 'unintern '(name obarray) "23.3")
+(set-advertised-calling-convention 'commandp '(function) "29.1")
 (set-advertised-calling-convention 'indirect-function '(object) "25.1")
 (set-advertised-calling-convention 'redirect-frame-focus '(frame focus-frame) 
"24.3")
 (set-advertised-calling-convention 'libxml-parse-xml-region '(start end 
&optional base-url) "27.1")
diff --git a/lisp/vc/emerge.el b/lisp/vc/emerge.el
index b2fdb07d5f..3cc243222a 100644
--- a/lisp/vc/emerge.el
+++ b/lisp/vc/emerge.el
@@ -2551,7 +2551,7 @@ Override any change that the mode might make to the mode 
line or
 local keymap.  Leave merge in fast mode."
   (interactive
    (list (intern (completing-read "New major mode for merge buffer: "
-                                 obarray 'commandp t nil))))
+                                 obarray #'commandp t nil))))
   (funcall mode)
   (emerge-refresh-mode-line)
   (if emerge-fast-mode
diff --git a/src/eval.c b/src/eval.c
index 8eccba9a11..e15c9bd56b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2159,15 +2159,10 @@ This means it contains a description for how to read 
arguments to give it.
 The value is nil for an invalid function or a symbol with no function
 definition.
 
-Interactively callable functions include strings and vectors (treated
-as keyboard macros), lambda-expressions that contain a top-level call
-to `interactive', autoload definitions made by `autoload' with non-nil
-fourth argument, and some of the built-in functions of Lisp.
+Interactively callable functions include lambda-expressions that contain a 
top-level call to `interactive', autoload definitions made by `autoload' with
+non-nil fourth argument, and some of the built-in functions of Lisp.
 
-Also, a symbol satisfies `commandp' if its function definition does so.
-
-If the optional argument FOR-CALL-INTERACTIVELY is non-nil,
-then strings and vectors are not accepted.  */)
+Also, a symbol satisfies `commandp' if its function definition does so.  */)
   (Lisp_Object function, Lisp_Object for_call_interactively)
 {
   register Lisp_Object fun;
@@ -2207,10 +2202,6 @@ then strings and vectors are not accepted.  */)
     }
 #endif
 
-  /* Strings and vectors are keyboard macros.  */
-  else if (STRINGP (fun) || VECTORP (fun))
-    return (NILP (for_call_interactively) ? Qt : Qnil);
-
   /* Lists may represent commands.  */
   else if (!CONSP (fun))
     return Qnil;
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 6350bebeee..85657ffc20 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -787,7 +787,7 @@ See Bug#21722."
   (let ((history-length 1)
         (command-history ()))
     (dotimes (_ (1+ history-length))
-      (command-execute "" t))
+      (command-execute (kmacro "") t))
     (should (= (length command-history) history-length))))
 
 



reply via email to

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