From: "Andrés Ramírez" <rrandresf@hotmail.com>
To: help-gnu-emacs@gnu.org
Subject: how to genererate 'C-x @ c' from within a custom keymap
Date: Thu, 21 Jul 2022 18:51:56 +0000 [thread overview]
Message-ID: <DM6PR03MB3803C8B3DC8392FB867AF38CA6919@DM6PR03MB3803.namprd03.prod.outlook.com> (raw)
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)
next reply other threads:[~2022-07-21 18:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 18:51 Andrés Ramírez [this message]
2022-07-22 5:35 ` how to genererate 'C-x @ c' from within a custom keymap 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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DM6PR03MB3803C8B3DC8392FB867AF38CA6919@DM6PR03MB3803.namprd03.prod.outlook.com \
--to=rrandresf@hotmail.com \
--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.
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).