unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* 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

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).