* repeatable vs. non-repeatable commands
@ 2017-06-24 6:17 Michael Heerdegen
2017-06-24 10:01 ` Emanuel Berg
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Michael Heerdegen @ 2017-06-24 6:17 UTC (permalink / raw)
To: Emacs mailing list
Hi,
in el-search, the default key bindings are all of the form
control-shift-letter, like C-S (search-forward), C-R (search-backward),
C-A (go to the first match) etc.
Since these bindings are not available in a console, I want to provide
another configurable binding-scheme of the form prefix+letter, where
"prefix" is a prefix key the user can choose. In this case, I want to
equip the commands with a transient map so that the prefix has to be
given only the first time one of the commands is invoked. For example,
if the prefix is meta-s e,
meta-s e s s a
should invoke a forward search, then go to the next match, and then to
the first.
The transient map is the same for all prefixes, but in the shift-letter
case, it's wrong to use the transient map; it would be surprising when
C-S followed by r would search backward instead of stopping the search
and invoking the self-insert-command.
My question is: is there a way I'm not seeing to achieve this without
defining two sets of commands (one set establishing the transient map,
another without)?
FWIW, my idea was consulting `this-command-keys', but due to bug#27470,
I can't use it in my case.
Any ideas?
Thanks,
Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: repeatable vs. non-repeatable commands
2017-06-24 6:17 repeatable vs. non-repeatable commands Michael Heerdegen
@ 2017-06-24 10:01 ` Emanuel Berg
2017-06-25 4:56 ` Michael Heerdegen
2017-06-24 10:22 ` Emanuel Berg
2017-06-24 13:23 ` Stefan Monnier
2 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2017-06-24 10:01 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen wrote:
> I want to provide another configurable
> binding-scheme of the form prefix+letter,
> where "prefix" is a prefix key the user
> can choose.
(define-prefix-command 'C-o-prefix)
(global-set-key "\C-o" 'C-o-prefix)
(global-set-key "\C-od" (lambda () (interactive) (message "d")))
(global-set-key "\C-oD" (lambda () (interactive) (message "D")))
... no?
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: repeatable vs. non-repeatable commands
2017-06-24 10:01 ` Emanuel Berg
@ 2017-06-25 4:56 ` Michael Heerdegen
2017-06-25 15:53 ` Emanuel Berg
0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2017-06-25 4:56 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <moasen@zoho.com> writes:
> (define-prefix-command 'C-o-prefix)
> (global-set-key "\C-o" 'C-o-prefix)
>
> (global-set-key "\C-od" (lambda () (interactive) (message "d")))
> (global-set-key "\C-oD" (lambda () (interactive) (message "D")))
>
> ... no?
That only solves the easy part (defining a prefix key), but not the
hard. The heard part is:
(global-set-key "\C-od" #'the-function)
should make C-o d d message "d" two times. But with the same named
command, binding
(global-set-key "\C-D" #'the-function)
(that is, control-shift-d) should not make typing C-D d message "d" two
times. Instead, only C-D should call the command, and the following d
is not special (i.e. calls self-insert-command). That means, I need to
decide whether I have to establish a transient map in the body of
`the-function' base on the keys hit, and how I can do that correctly is
my question.
Thanks,
Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: repeatable vs. non-repeatable commands
2017-06-24 6:17 repeatable vs. non-repeatable commands Michael Heerdegen
2017-06-24 10:01 ` Emanuel Berg
@ 2017-06-24 10:22 ` Emanuel Berg
2017-06-25 4:59 ` Michael Heerdegen
2017-06-24 13:23 ` Stefan Monnier
2 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2017-06-24 10:22 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen wrote:
> C-A [...] Since these bindings are not
> available in a console
In a way they are, with the familiar
workaround. I suppose it doesn't count as user
configurable tho. Well, it depends who the user
is...
In /etc/console-setup/remap.inc
# C-a and C-A
# a/A is 30; use showkey(1)
# C-a already works
# use the ""Private Use Area": U+E000 up to and including U+F8FF
control shift keycode 30 = U+E000
then with 'sudo' or possibly first 'chmod +s /bin/loadkeys'
loadkeys -q -c -s /etc/console-setup/remap.inc
in Emacs
(define-key input-decode-map [?\uE000] [C-A])
(global-set-key [C-A] (lambda () (interactive) (message "A")))
(global-set-key "\C-a" (lambda () (interactive) (message "a")))
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: repeatable vs. non-repeatable commands
2017-06-24 10:22 ` Emanuel Berg
@ 2017-06-25 4:59 ` Michael Heerdegen
2017-06-25 16:22 ` Emanuel Berg
0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2017-06-25 4:59 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <moasen@zoho.com> writes:
> In a way they are, with the familiar workaround. I suppose it doesn't
> count as user configurable tho. Well, it depends who the user is...
>
> In /etc/console-setup/remap.inc
>
> # C-a and C-A
> # a/A is 30; use showkey(1)
> # C-a already works
> # use the ""Private Use Area": U+E000 up to and including U+F8FF
> control shift keycode 30 = U+E000
>
> then with 'sudo' or possibly first 'chmod +s /bin/loadkeys'
>
> loadkeys -q -c -s /etc/console-setup/remap.inc
>
> in Emacs
>
> (define-key input-decode-map [?\uE000] [C-A])
> (global-set-key [C-A] (lambda () (interactive) (message "A")))
> (global-set-key "\C-a" (lambda () (interactive) (message "a")))
Interesting! I'm not really a console user myself, but it's good to
have your explanation in this thread.
Thanks,
Michael.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: repeatable vs. non-repeatable commands
2017-06-24 6:17 repeatable vs. non-repeatable commands Michael Heerdegen
2017-06-24 10:01 ` Emanuel Berg
2017-06-24 10:22 ` Emanuel Berg
@ 2017-06-24 13:23 ` Stefan Monnier
2017-06-26 15:31 ` Michael Heerdegen
2 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2017-06-24 13:23 UTC (permalink / raw)
To: help-gnu-emacs
> FWIW, my idea was consulting `this-command-keys', but due to bug#27470,
> I can't use it in my case.
I just sent a workaround for bug#27470 that you might be able to use
(i.e. call this-command-keys(-vector) at the very beginning).
E.g.
(defun el-search--repeatable-binding-p ()
"Return non-nil if the last command's binding should be repeatable.
Beware: this should be called before any other user-interaction."
(let ((keys (this-command-keys-vector)))
(> (length keys)
;; Meta is often turned into a separate ESC byte in
;; terminal emulators.
(if (eq ?\e (aref keys 0)) 2 1))))
(defun my-el-search-foo (arg1 arg &optional repeat)
(interactive
(let ((repeat (el-search--repeatable-binding-p)))
...
(list ... repeat)))
[...]
(when repeat
(set-transient-map ...)))
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-06-26 15:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-24 6:17 repeatable vs. non-repeatable commands Michael Heerdegen
2017-06-24 10:01 ` Emanuel Berg
2017-06-25 4:56 ` Michael Heerdegen
2017-06-25 15:53 ` Emanuel Berg
2017-06-26 13:49 ` Michael Heerdegen
2017-06-24 10:22 ` Emanuel Berg
2017-06-25 4:59 ` Michael Heerdegen
2017-06-25 16:22 ` Emanuel Berg
2017-06-24 13:23 ` Stefan Monnier
2017-06-26 15:31 ` Michael Heerdegen
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.