[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 81f0e05: * src/cmds.c (Fself_insert_command): Get l
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 81f0e05: * src/cmds.c (Fself_insert_command): Get last-command-event via (new) arg. |
Date: |
Sat, 17 Nov 2018 10:47:55 -0500 (EST) |
branch: master
commit 81f0e05a02013bd1c9ea177e234561348b108578
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* src/cmds.c (Fself_insert_command): Get last-command-event via (new) arg.
---
doc/lispref/text.texi | 12 ++++++------
etc/NEWS | 3 +++
src/cmds.c | 17 ++++++++++-------
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 6c38d8e..51d2753 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -500,14 +500,14 @@ after point. It leaves the mark after the inserted text.
The value
is @code{nil}.
@end deffn
address@hidden Command self-insert-command count
address@hidden Command self-insert-command count &optional char
@cindex character insertion
@cindex self-insertion
-This command inserts the last character typed; it does so @var{count}
-times, before point, and returns @code{nil}. Most printing characters
-are bound to this command. In routine use, @code{self-insert-command}
-is the most frequently called function in Emacs, but programs rarely use
-it except to install it on a keymap.
+This command inserts the character @var{char} (the last character typed);
+it does so @var{count} times, before point, and returns @code{nil}.
+Most printing characters are bound to this command. In routine use,
address@hidden is the most frequently called function in Emacs,
+but programs rarely use it except to install it on a keymap.
In an interactive call, @var{count} is the numeric prefix argument.
diff --git a/etc/NEWS b/etc/NEWS
index 92b20c7..1382b4d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1065,6 +1065,9 @@ removed.
* Lisp Changes in Emacs 27.1
++++
+** self-insert-command takes the char to insert as (optional) argument
+
** 'lookup-key' can take a list of keymaps as argument.
+++
diff --git a/src/cmds.c b/src/cmds.c
index 1616efb..f6803f4 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -260,11 +260,10 @@ because it respects values of `delete-active-region' and
`overwrite-mode'. */)
return Qnil;
}
-/* 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.
+Whichever character C you type to run this command is inserted.
The numeric prefix argument N says how many times to repeat the insertion.
Before insertion, `expand-abbrev' is executed if the inserted character does
not have word syntax and the previous character in the buffer does.
@@ -272,10 +271,14 @@ After insertion, `internal-auto-fill' is called if
`auto-fill-function' is non-nil and if the `auto-fill-chars' table has
a non-nil value for the inserted character. At the end, it runs
`post-self-insert-hook'. */)
- (Lisp_Object n)
+ (Lisp_Object n, Lisp_Object c)
{
CHECK_FIXNUM (n);
+ /* Backward compatibility. */
+ if (NILP (c))
+ c = last_command_event;
+
if (XFIXNUM (n) < 0)
error ("Negative repetition argument %"pI"d", XFIXNUM (n));
@@ -283,11 +286,11 @@ a non-nil value for the inserted character. At the end,
it runs
call0 (Qundo_auto_amalgamate);
/* Barf if the key that invoked this was not a character. */
- if (!CHARACTERP (last_command_event))
+ if (!CHARACTERP (c))
bitch_at_user ();
else {
int character = translate_char (Vtranslation_table_for_input,
- XFIXNUM (last_command_event));
+ XFIXNUM (c));
int val = internal_self_insert (character, XFIXNAT (n));
if (val == 2)
Fset (Qundo_auto__this_command_amalgamating, Qnil);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 81f0e05: * src/cmds.c (Fself_insert_command): Get last-command-event via (new) arg.,
Stefan Monnier <=