unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim Johnson <tim@akwebsoft.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Trapping prefixes with universal argument component [solved]T
Date: Sun, 22 Aug 2021 10:14:43 -0800	[thread overview]
Message-ID: <73381b1f-c3ea-946d-12ce-b1339ec5a79d@akwebsoft.com> (raw)
In-Reply-To: <CAP_d_8VB3ubu+M9F5nMxS6OBywnrRA0wN+QCF+LqAzZYiF2gyw@mail.gmail.com>

See bottom:

On 8/22/21 12:13 AM, Yuri Khan wrote:
> On Sun, 22 Aug 2021 at 06:30, Emanuel Berg via Users list for the GNU
> Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
>> Try this then ... should work
>>
>>    (global-set-key [M-kp-0] nil)
> Binding the offending key to nil isn’t going to help because when
> Emacs sees this (lack of) binding it will just proceed to key
> translation. And kp-0 translates to 0 and M-0 is bound to
> universal-argument.
>
> Instead:
>
>      (global-set-key (kbd "<M-kp-0>") 'ignore)
>      (global-set-key (kbd "<M-kp-1>") 'ignore)
>      (global-set-key (kbd "<M-kp-4>") 'ignore)
>      (global-set-key (kbd "<M-kp-6>") 'ignore)
>
> Alternatively:
>
>      (defun my-insert-open-paren ()
>        (interactive)
>        (let ((last-command-event ?\())
>          (call-interactively 'self-insert-command)))
>      (defun my-insert-close-paren ()
>        (interactive)
>        (let ((last-command-event ?\)))
>          (call-interactively 'self-insert-command)))
>      (defun my-insert-equal ()
>        (interactive)
>        (let ((last-command-event ?=))
>          (call-interactively 'self-insert-command)))
>
>      (global-set-key (kbd "<M-kp-0> <M-kp-4> <M-kp-0>") 'my-insert-open-paren)
>      (global-set-key (kbd "<M-kp-0> <M-kp-4> <M-kp-1>") 'my-insert-close-paren)
>      (global-set-key (kbd "<M-kp-0> <M-kp-6> <M-kp-1>") 'my-insert-equal)
Dang Dude! You nailed it. Those assignments all work.
Thanks very much. I'm marking this solved and ripping off the duct tape.

Thanks also to Drew, Emanuel and all else who chimed in.
Good work. :)
>
> (Why not (insert "(")? Because self-insert-command also handles the
> numeric prefix argument, is affected by overwrite-mode, expands
> abbreviations, and does a lot of other things.)
>
>
> The “correct” solution, of course, would be to reprogram the keypad so
> it sends different key codes, such as Shift+9, Shift+0, and = (or
> whatever is appropriate for one’s national keyboard layout), or if the
> device does not allow reprogramming, then harvest key switches and
> build one that does ;) Plenty of macropad kits on the market right
> now, some based on Free firmwares such as TMK or QMK.
This is a mechanical keypad but it is not programmable. I've used xmodmap
a lot in the past but from inspecting xev output, I'm afraid that any 
reassignment
through xmodmap might also effect the keyboard too.
cheers ...

-- 
Tim
tj49.com




  parent reply	other threads:[~2021-08-22 18:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 21:15 Trapping prefixes with universal argument component Tim Johnson
2021-08-20 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-20 22:37   ` Tim Johnson
2021-08-21  5:08     ` Yuri Khan
2021-08-21  5:22       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-21  5:39         ` Yuri Khan
2021-08-21 15:18           ` Tim Johnson
2021-08-21 19:31             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-21 19:38               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-21 20:08               ` [External] : " Drew Adams
2021-08-21 21:03                 ` Drew Adams
2021-08-21 21:30                 ` Tim Johnson
2021-08-21 23:21                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-22  1:43                   ` Drew Adams
2021-08-22  2:51                     ` Arthur Miller
2021-08-21 23:19                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-22  1:46                   ` Drew Adams
2021-08-21 21:23               ` Tim Johnson
2021-08-21 23:25                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-22  0:42                   ` Tim Johnson
2021-08-22  0:51                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-22  8:13                   ` Yuri Khan
2021-08-22  8:25                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-22 18:14                     ` Tim Johnson [this message]
2021-08-21 19:42           ` Emanuel Berg via Users list for the GNU Emacs text editor

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=73381b1f-c3ea-946d-12ce-b1339ec5a79d@akwebsoft.com \
    --to=tim@akwebsoft.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).