[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert a keyboard macro to equivalent Lisp code
From: |
Juri Linkov |
Subject: |
Re: Convert a keyboard macro to equivalent Lisp code |
Date: |
Mon, 07 Jun 2010 21:35:57 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) |
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/