From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Patch for broken `insert-kbd-macro'. Date: Sat, 27 Nov 2004 21:34:37 -0600 (CST) Message-ID: <200411280334.iAS3Yb512065@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1101613007 30364 80.91.229.6 (28 Nov 2004 03:36:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 28 Nov 2004 03:36:47 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 28 04:36:43 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CYFrf-0002lt-00 for ; Sun, 28 Nov 2004 04:36:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYG0z-0007K1-Kd for ged-emacs-devel@m.gmane.org; Sat, 27 Nov 2004 22:46:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CYG0h-0007Jk-Sr for emacs-devel@gnu.org; Sat, 27 Nov 2004 22:46:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CYG0h-0007JV-C2 for emacs-devel@gnu.org; Sat, 27 Nov 2004 22:46:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYG0h-0007JS-A7 for emacs-devel@gnu.org; Sat, 27 Nov 2004 22:46:03 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CYFqw-0005ad-Lu for emacs-devel@gnu.org; Sat, 27 Nov 2004 22:35:58 -0500 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id iAS3ZwFu010233 for ; Sat, 27 Nov 2004 21:35:58 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id iAS3Yb512065; Sat, 27 Nov 2004 21:34:37 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:30447 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30447 The minibuffer completion for `insert-kbd-macro' is broken, because it assumes that keyboard macros are always strings or vectors, which is no longer true. As a result `insert-kbd-macro' _always_ claims that there are no completions, whenever the keyboard macro is given by a lambda expression, as is true for nearly all newly defined keyboard macros. The patch below fixes this. If you look at a lambda expression corresponding to a keyboard macro, as inserted by `insert-kbd-macro' (once you take care of the completion problem): (fset 'a1 (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([97 98 99 return] 0 "%d")) arg))) then I do not want to rely on the docstring "Keyboard macro.", because even a user unfamiliar with Elisp may realize that he can provide an individualized docstring by straightforwardly hand editing that string in his .emacs and might actually do so. So the patch below relies on the `kmacro-exec-ring-item' instead. Maybe some functions that are not keyboard macros may have, by some incredible coincidence, `kmacro-exec-ring-item' in the same position. But the only negative from such a very improbable occurrence would be that the user _might_ have to type a few extra characters to get a unique completion. (Remember, all we are talking about is minibuffer completion.) I could install the patch below, if desired. ===File ~/macros.el-diff==================================== *** macros.el 06 Nov 2004 09:06:27 -0600 1.43 --- macros.el 27 Nov 2004 21:18:57 -0600 *************** *** 63,76 **** To save a kbd macro, visit a file of Lisp code such as your `~/.emacs', use this command, and then save the file." ! (interactive (list (intern (completing-read "Insert kbd macro (name): " ! obarray ! (lambda (elt) ! (and (fboundp elt) ! (or (stringp (symbol-function elt)) ! (vectorp (symbol-function elt))))) ! t)) ! current-prefix-arg)) (let (definition) (if (string= (symbol-name macroname) "") (progn --- 63,86 ---- To save a kbd macro, visit a file of Lisp code such as your `~/.emacs', use this command, and then save the file." ! (interactive ! (list ! (intern ! (completing-read "Insert kbd macro (name): " ! obarray ! (lambda (elt) ! (and (fboundp elt) ! (let ((macr (symbol-function elt))) ! (or (stringp macr) ! (vectorp macr) ! ;; the call to `safe-length' is to ! ;; avoid errors of the type ! ;; (nth 4 '(1 . 2)) ! (and (>= (safe-length macr) 5) ! (eq (car (nth 4 macr)) ! 'kmacro-exec-ring-item)))))) ! t)) ! current-prefix-arg)) (let (definition) (if (string= (symbol-name macroname) "") (progn ============================================================