From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: Ctrl-[ ?
Date: Fri, 07 Jun 2019 18:04:11 -0400 [thread overview]
Message-ID: <jwv8sudjbrh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: jwvk1dyequd.fsf-monnier+emacs@gnu.org
> See also https://emacs.stackexchange.com/questions/17509 where I show
> some other possibility (tho in the context of `tab` vs `C-i` vs TAB, but
> which is exactly the same problem).
FWIW, the patch below introduces a much more clear separation between
C-i and TAB and other such things, by distinguishing "control modifier
plus a char" events from the 32 "ASCII control chars".
It introduces various questions about how to print and read
those control thingies in Elisp and in user interactions.
But at least, for a quick 30 seconds test, it seems to handle the
simple cases.
Stefan
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 36044ab65d..22af38aeef 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -822,7 +822,7 @@ right-char
see."
(interactive "^p")
(if visual-order-cursor-movement
- (dotimes (i (if (numberp n) (abs n) 1))
+ (dotimes (_ (if (numberp n) (abs n) 1))
(move-point-visually (if (and (numberp n) (< n 0)) -1 1)))
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(forward-char n)
@@ -840,7 +840,7 @@ left-char
see."
(interactive "^p")
(if visual-order-cursor-movement
- (dotimes (i (if (numberp n) (abs n) 1))
+ (dotimes (_ (if (numberp n) (abs n) 1))
(move-point-visually (if (and (numberp n) (< n 0)) 1 -1)))
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(backward-char n)
@@ -1430,6 +1430,14 @@ ctl-x-4-map
(define-key special-event-map [sigusr1] 'ignore)
(define-key special-event-map [sigusr2] 'ignore)
+;;;; For merge-ASCII-control-and-CTRL-modifier
+(dotimes (ascii-ctrl 32)
+ (let* ((PLAIN-ctrl (+ 64 ascii-ctrl (ash 1 26))))
+ (dolist (mod (list 0 (ash 1 27))) ;With or without meta
+ (dolist (off (list 0 32)) ;Upper and lowercase
+ (define-key function-key-map (vector (+ PLAIN-ctrl off mod))
+ (vector (+ ascii-ctrl mod)))))))
+
;; Don't look for autoload cookies in this file.
;; Local Variables:
;; no-update-autoloads: t
diff --git a/lisp/simple.el b/lisp/simple.el
index 35022efdf4..184927c928 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8817,7 +8817,7 @@ event-apply-modifier
LSHIFTBY is the numeric value of this modifier, in keyboard events.
PREFIX is the string that represents this modifier in an event type symbol."
(if (numberp event)
- (cond ((eq symbol 'control)
+ (cond ((and (eq symbol 'control) merge-ASCII-control-and-CTRL-modifier)
(if (<= 64 (upcase event) 95)
(- (upcase event) 64)
(logior (ash 1 lshiftby) event)))
diff --git a/src/keyboard.c b/src/keyboard.c
index 35557e226c..9c92a7ccfd 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2009,7 +2009,7 @@ make_ctrl_char (int c)
/* Save the upper bits here. */
int upper = c & ~0177;
- if (! ASCII_CHAR_P (c))
+ if (! ASCII_CHAR_P (c) || !merge_ascii_control_and_ctrl_modifier)
return c |= ctrl_modifier;
c &= 0177;
@@ -11811,6 +11811,11 @@ This inhibits recording input events for the purposes of keyboard
macros, dribble file, and `recent-keys'.
Internal use only. */);
+ DEFVAR_BOOL ("merge-ASCII-control-and-CTRL-modifier",
+ merge_ascii_control_and_ctrl_modifier,
+ doc: /* When non-nil, C-i is the same as TAB. */);
+ merge_ascii_control_and_ctrl_modifier = false;
+
pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper);
}
diff --git a/src/keymap.c b/src/keymap.c
index 78cd7d2990..16afdefab0 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -2130,8 +2130,9 @@ push_key_description (EMACS_INT ch, char *p)
c -= alt_modifier;
}
if ((c & ctrl_modifier) != 0
- || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))
- || tab_as_ci)
+ || (merge_ascii_control_and_ctrl_modifier
+ && ((c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M'))
+ || tab_as_ci)))
{
*p++ = 'C';
*p++ = '-';
@@ -2169,11 +2170,7 @@ push_key_description (EMACS_INT ch, char *p)
*p++ = 'S';
*p++ = 'C';
}
- else if (tab_as_ci)
- {
- *p++ = 'i';
- }
- else if (c == '\t')
+ else if (c == '\t' && merge_ascii_control_and_ctrl_modifier)
{
*p++ = 'T';
*p++ = 'A';
@@ -2187,7 +2184,11 @@ push_key_description (EMACS_INT ch, char *p)
}
else
{
- /* `C-' already added above. */
+ if (!merge_ascii_control_and_ctrl_modifier)
+ {
+ *p++ = '\\';
+ *p++ = '^';
+ }
if (c > 0 && c <= Ctl ('Z'))
*p++ = c + 0140;
else
next prev parent reply other threads:[~2019-06-07 22:04 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-06 4:49 Ctrl-[ ? Jean-Christophe Helary
2019-06-06 7:26 ` Jean-Christophe Helary
2019-06-06 8:13 ` Andreas Schwab
2019-06-06 10:12 ` Eli Zaretskii
2019-06-06 12:37 ` Jean-Christophe Helary
2019-06-06 13:02 ` Eli Zaretskii
2019-06-06 13:28 ` Jean-Christophe Helary
2019-06-06 12:44 ` Mattias Engdegård
2019-06-06 13:01 ` Eli Zaretskii
2019-06-06 13:25 ` Jean-Christophe Helary
2019-06-06 14:35 ` Eli Zaretskii
2019-06-07 6:21 ` Marcin Borkowski
2019-06-07 8:34 ` joakim
2019-06-06 13:26 ` Clément Pit-Claudel
2019-06-06 13:32 ` Juanma Barranquero
2019-06-06 14:37 ` Eli Zaretskii
2019-06-06 15:01 ` Jean-Christophe Helary
2019-06-06 15:33 ` Clément Pit-Claudel
2019-06-06 17:28 ` Eli Zaretskii
2019-06-06 17:33 ` Clément Pit-Claudel
2019-06-06 17:48 ` Eli Zaretskii
2019-06-06 18:34 ` Eli Zaretskii
2019-06-06 18:48 ` Clément Pit-Claudel
2019-06-06 19:18 ` Eli Zaretskii
2019-06-07 15:02 ` Clément Pit-Claudel
2019-06-07 19:44 ` Eli Zaretskii
2019-06-07 21:01 ` Clément Pit-Claudel
2019-06-07 23:48 ` Jean-Christophe Helary
2019-06-08 6:23 ` Eli Zaretskii
2019-06-12 8:08 ` Søren Pilgård
2019-06-12 8:56 ` Ergus
2019-06-06 18:55 ` Noam Postavsky
2019-06-10 0:23 ` Stefan Kangas
2019-06-10 0:42 ` Jean-Christophe Helary
2019-06-10 16:42 ` Eli Zaretskii
2019-06-11 15:36 ` Michael Welsh Duggan
2019-06-11 15:55 ` Eli Zaretskii
2019-06-11 16:31 ` Yuri Khan
2019-06-12 12:22 ` Stefan Kangas
2019-06-12 12:14 ` Stefan Kangas
2019-06-12 13:12 ` Alan Mackenzie
2019-06-12 13:38 ` Óscar Fuentes
2019-06-06 13:28 ` Óscar Fuentes
2019-06-06 14:00 ` Drew Adams
2019-06-06 12:58 ` Stefan Monnier
2019-06-06 12:58 ` Ralph Seichter
2019-06-06 13:42 ` tomas
2019-06-06 14:08 ` Jean-Christophe Helary
2019-06-06 14:25 ` Stefan Monnier
2019-06-06 15:27 ` Jean-Christophe Helary
2019-06-06 18:29 ` Noam Postavsky
2019-06-06 23:08 ` Jean-Christophe Helary
2019-06-06 23:26 ` Noam Postavsky
2019-06-06 23:35 ` Jean-Christophe Helary
2019-06-07 6:24 ` Eli Zaretskii
2019-06-07 11:43 ` Noam Postavsky
2019-06-07 13:16 ` Jean-Christophe Helary
2019-06-07 22:04 ` Stefan Monnier [this message]
2019-06-08 6:22 ` Eli Zaretskii
2019-06-08 14:14 ` Stefan Monnier
2019-06-07 3:36 ` Emanuel Berg via help-gnu-emacs
2019-06-07 4:30 ` Jean-Christophe Helary
2019-06-07 4:43 ` Emanuel Berg via help-gnu-emacs
2019-06-07 5:04 ` Jean-Christophe Helary
2019-06-07 6:15 ` Eli Zaretskii
2019-06-07 8:04 ` Óscar Fuentes
2019-06-07 8:44 ` Eli Zaretskii
2019-06-07 13:19 ` Jean-Christophe Helary
2019-06-07 13:54 ` Noam Postavsky
2019-06-07 14:23 ` Jean-Christophe Helary
2019-06-07 15:17 ` Noam Postavsky
2019-06-07 13:45 ` Óscar Fuentes
2019-06-07 14:20 ` Eli Zaretskii
2019-06-07 18:20 ` Óscar Fuentes
2019-06-07 20:16 ` Eli Zaretskii
2019-06-07 16:30 ` tomas
2019-06-08 0:05 ` Francis Belliveau
2019-06-08 0:31 ` Óscar Fuentes
2019-06-08 8:44 ` tomas
2019-06-08 11:48 ` 조성빈 via help-gnu-emacs
2019-06-08 11:56 ` tomas
2019-06-08 13:06 ` Óscar Fuentes
2019-06-08 13:30 ` Eli Zaretskii
2019-06-08 13:54 ` Jean-Christophe Helary
2019-06-08 14:03 ` tomas
2019-06-08 14:22 ` Jean-Christophe Helary
2019-06-08 15:42 ` Eli Zaretskii
2019-06-09 0:52 ` Jean-Christophe Helary
2019-06-09 6:19 ` Eli Zaretskii
2019-06-09 6:51 ` Jean-Christophe Helary
2019-06-08 13:58 ` tomas
2019-06-08 19:40 ` Óscar Fuentes
2019-06-08 20:09 ` Eli Zaretskii
2019-06-08 20:28 ` tomas
2019-06-08 21:03 ` Francis Belliveau
2019-06-08 21:38 ` Óscar Fuentes
2019-06-09 0:25 ` Stefan Monnier
2019-06-09 1:24 ` Óscar Fuentes
2019-06-18 22:25 ` Stefan Monnier
2019-06-11 23:05 ` Francis Belliveau
2019-06-14 6:51 ` Stefan Monnier
2019-06-14 12:06 ` [offtopic] " Van L
2019-06-14 12:24 ` tomas
2019-06-15 9:12 ` Van L
2019-06-15 9:44 ` tomas
2019-06-15 12:38 ` Van L
2019-06-09 6:37 ` Eli Zaretskii
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=jwv8sudjbrh.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=help-gnu-emacs@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.