From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: Re: Convert a keyboard macro to equivalent Lisp code
Date: Mon, 07 Jun 2010 21:35:57 +0300 [thread overview]
Message-ID: <87bpbn55au.fsf@mail.jurta.org> (raw)
In-Reply-To: <87fx11mfd3.fsf@mail.jurta.org> (Juri Linkov's message of "Sat, 05 Jun 2010 22:57:04 +0300")
To get useful results, some commands should provide their arguments
explicitly in the interactive spec instead of relying on global
variables. So instead of useless `(self-insert-command 1)' typing `A'
will record `(self-insert-command 1 65)' with the following patch.
The same is for isearch.
=== modified file 'src/cmds.c'
--- src/cmds.c 2010-05-25 09:36:21 +0000
+++ src/cmds.c 2010-06-07 18:34:33 +0000
@@ -331,19 +331,23 @@
/* Note that there's code in command_loop_1 which typically avoids
calling this. */
-DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p",
+DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 2,
+ "(list (prefix-numeric-value current-prefix-arg) last-command-event)",
doc: /* Insert the character you type.
Whichever character you type to run this command is inserted.
Before insertion, `expand-abbrev' is executed if the inserted character does
not have word syntax and the previous character in the buffer does.
After insertion, the value of `auto-fill-function' is called if the
`auto-fill-chars' table has a non-nil value for the inserted character. */)
- (n)
- Lisp_Object n;
+ (n, last_char)
+ Lisp_Object n, last_char;
{
int remove_boundary = 1;
CHECK_NUMBER (n);
+ if (NILP (last_char))
+ last_char = last_command_event;
+
if (!EQ (Vthis_command, current_kboard->Vlast_command))
nonundocount = 0;
@@ -365,11 +369,11 @@ (at your option) any later version.
current_buffer->undo_list = XCDR (current_buffer->undo_list);
/* Barf if the key that invoked this was not a character. */
- if (!CHARACTERP (last_command_event))
+ if (!CHARACTERP (last_char))
bitch_at_user ();
{
int character = translate_char (Vtranslation_table_for_input,
- XINT (last_command_event));
+ XINT (last_char));
if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode))
{
XSETFASTINT (n, XFASTINT (n) - 2);
=== modified file 'lisp/isearch.el'
--- lisp/isearch.el 2010-05-20 23:16:04 +0000
+++ lisp/isearch.el 2010-06-06 18:30:52 +0000
@@ -1995,10 +1995,10 @@ (defun isearch-return-char ()
(isearch-process-search-char ?\n))
(make-obsolete 'isearch-return-char 'isearch-printing-char "19.7")
-(defun isearch-printing-char ()
+(defun isearch-printing-char (&optional char)
"Add this ordinary printing character to the search string and search."
- (interactive)
- (let ((char last-command-event))
+ (interactive (list last-command-event))
+ (let ((char (or char last-command-event)))
(if (= char ?\S-\ )
(setq char ?\s))
(if current-input-method
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2010-06-07 18:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-05 19:57 Convert a keyboard macro to equivalent Lisp code Juri Linkov
2010-06-07 9:27 ` Richard Stallman
2010-06-07 9:27 ` Richard Stallman
2010-06-07 13:36 ` Stefan Monnier
2010-06-07 18:33 ` Juri Linkov
2010-06-07 18:35 ` Juri Linkov [this message]
2010-06-07 20:11 ` Stefan Monnier
2010-06-08 8:05 ` Juri Linkov
2010-06-09 1:36 ` Stefan Monnier
2010-06-09 8:34 ` Juri Linkov
2010-06-09 14:17 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bpbn55au.fsf@mail.jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.