* how to genererate 'C-x @ c' from within a custom keymap
@ 2022-07-21 18:51 Andrés Ramírez
2022-07-22 5:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-22 5:39 ` Yuri Khan
0 siblings, 2 replies; 5+ messages in thread
From: Andrés Ramírez @ 2022-07-21 18:51 UTC (permalink / raw)
To: help-gnu-emacs
Hi. Sometimes I should use a bluetooth keyboard without the Right
control key (cos it is absent on this model).
So. When I need to press the Right Control key for doing C-a or C-e.
I end doing 'C-x @ c'. So far so good.
Pressing C-x is very difficult. So that should be fixed.
Trying to fix it. Ended with this:
--8<---------------cut here---------------start------------->8---
(global-set-key (kbd "M-h") (lambda () (interactive) (emacsstacko/call-keymap ik-launch-keymap "*Your-key*?:")))
--8<---------------cut here---------------end--------------->8---
JIC. I am not the author of this function.
,---- [ ]
| (defun emacsstacko/call-keymap (map &optional prompt)
| "Read a key sequence and call the command it's bound to in MAP."
| ;; Note: MAP must be a symbol so we can trick `describe-bindings' into giving
| ;; us a nice help text.
| (let* ((overriding-local-map `(keymap (,map . ,map)))
| ;(help-form `(describe-bindings ,(vector map))) ; conflicts with C-h
| (key (read-key-sequence prompt))
| (cmd (lookup-key map key t)))
| (if (functionp cmd) (call-interactively cmd)
| (user-error "%s is undefined" key))))
|
`----
And I also have this:
--8<---------------cut here---------------start------------->8---
(defvar ik-launch-keymap (make-sparse-keymap))
;;; below works. But needs xdotool
(define-key ik-launch-keymap "c" (lambda () (interactive) (shell-command-to-string "xdotool key ctrl+x; xdotool type @c")))
(define-key ik-launch-keymap "o" 'other-window)
(define-key ik-launch-keymap "x" (lambda () (interactive) (run-at-time nil nil #'call-interactively 'execute-extended-command)))
--8<---------------cut here---------------end--------------->8---
I want to replace the use of xdotool.
How I should I emulate the pressing of 'C-x @ c'. From within this
custom keymap?.
I have tried a couple of things without success.
(define-key ik-launch-keymap "c" 'event-apply-control-modifier)
And Also I have wrapped 'event-apply-control-modifier within an
interactive function.
Best Regards
ps: btw this one works. But very difficult to press.
(define-key key-translation-map (kbd "M-i") 'event-apply-control-modifier)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to genererate 'C-x @ c' from within a custom keymap
2022-07-21 18:51 how to genererate 'C-x @ c' from within a custom keymap Andrés Ramírez
@ 2022-07-22 5:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-26 15:47 ` andrés ramírez
2022-07-22 5:39 ` Yuri Khan
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-07-22 5:35 UTC (permalink / raw)
To: help-gnu-emacs
> I have tried a couple of things without success.
> (define-key ik-launch-keymap "c" 'event-apply-control-modifier)
`event-apply-control-modifier` has to be used within a *remapping*
keymap, i.e. one of `input-decode-map`, `(local-)function-key-map`,
or `key-translation-map`.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to genererate 'C-x @ c' from within a custom keymap
2022-07-22 5:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-07-26 15:47 ` andrés ramírez
0 siblings, 0 replies; 5+ messages in thread
From: andrés ramírez @ 2022-07-26 15:47 UTC (permalink / raw)
To: Stefan Monnier; +Cc: help-gnu-emacs
Hi. Stefan.
My comments below.
>>>>> "Stefan" == Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> writes:
Stefan> `event-apply-control-modifier` has to be used within a *remapping* keymap, i.e. one of
Stefan> `input-decode-map`, `(local-)function-key-map`, or `key-translation-map`.
That comment lead me to the documentation of
--8<---------------cut here---------------start------------->8---
(info "(elisp) Translation Keymaps")
--8<---------------cut here---------------end--------------->8---
There. hyperify was found.
After reading it I ended with this:
--8<---------------cut here---------------start------------->8---
(define-key ik-launch-keymap "c" 'launch-keymap/controlrify)
(defun launch-keymap/metarify () (interactive) (execute-kbd-macro (event-apply-control-modifier nil)))
--8<---------------cut here---------------end--------------->8---
It works (half way). C-a C-e are posible. But not C-x.
Perhaps execute-kbd-macro is not the right function.
Best Regards
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to genererate 'C-x @ c' from within a custom keymap
2022-07-21 18:51 how to genererate 'C-x @ c' from within a custom keymap Andrés Ramírez
2022-07-22 5:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-07-22 5:39 ` Yuri Khan
2022-07-26 15:51 ` andrés ramírez
1 sibling, 1 reply; 5+ messages in thread
From: Yuri Khan @ 2022-07-22 5:39 UTC (permalink / raw)
To: Andrés Ramírez; +Cc: help-gnu-emacs
On Fri, 22 Jul 2022 at 11:22, Andrés Ramírez <rrandresf@hotmail.com> wrote:
>
> Hi. Sometimes I should use a bluetooth keyboard without the Right
> control key (cos it is absent on this model).
>
> So. When I need to press the Right Control key for doing C-a or C-e.
Why do you need to do that?
* Your keyboard might have Home and End keys that might be easier to
press than anything else you can come up with.
* Or it might have Fn+Left/Fn+Right.
* Or you could use the left Ctrl.
* Or you could rebind move-beginning-of-line and move-end-of-line to other keys.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to genererate 'C-x @ c' from within a custom keymap
2022-07-22 5:39 ` Yuri Khan
@ 2022-07-26 15:51 ` andrés ramírez
0 siblings, 0 replies; 5+ messages in thread
From: andrés ramírez @ 2022-07-26 15:51 UTC (permalink / raw)
To: Yuri Khan; +Cc: help-gnu-emacs
Hi. Yuri.
>>>>> "Yuri" == Yuri Khan <yuri.v.khan@gmail.com> writes:
Yuri> Why do you need to do that?
Because. I am trying not to alter to much my tempo. M-h is very easy to
type when You use the dvorak layout.
Yuri> * Your keyboard might have Home and End keys that might be easier to press than anything
Yuri> else you can come up with. * Or it might have Fn+Left/Fn+Right. * Or you could use the
Yuri> left Ctrl. * Or you could rebind move-beginning-of-line and move-end-of-line to other
Yuri> keys.
Yes. Those are alternatives too.
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-26 15:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-21 18:51 how to genererate 'C-x @ c' from within a custom keymap Andrés Ramírez
2022-07-22 5:35 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-07-26 15:47 ` andrés ramírez
2022-07-22 5:39 ` Yuri Khan
2022-07-26 15:51 ` andrés ramírez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).