all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Patch for broken `insert-kbd-macro'.
@ 2004-11-28  3:34 Luc Teirlinck
  2004-11-29  0:08 ` Kim F. Storm
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Teirlinck @ 2004-11-28  3:34 UTC (permalink / raw)


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
============================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Patch for broken `insert-kbd-macro'.
  2004-11-28  3:34 Patch for broken `insert-kbd-macro' Luc Teirlinck
@ 2004-11-29  0:08 ` Kim F. Storm
  0 siblings, 0 replies; 2+ messages in thread
From: Kim F. Storm @ 2004-11-29  0:08 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> 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.

Thanks for investigating this.

However, there is an easier way -- just check for a kmacro property on
the symbol.  I installed a fix.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-29  0:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-28  3:34 Patch for broken `insert-kbd-macro' Luc Teirlinck
2004-11-29  0:08 ` Kim F. Storm

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.