all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Trapping prefixes with universal argument component
@ 2021-08-20 21:15 Tim Johnson
  2021-08-20 21:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 25+ messages in thread
From: Tim Johnson @ 2021-08-20 21:15 UTC (permalink / raw)
  To: MLEmacs

GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, 
cairo version 1.16.0)
  of 2021-06-04 on Ubuntu/Mate 20.04

I have a keypad that does not appear to be doing on linux what it is 
designed to.
The keypad has three keys with the following legends: "[", "]", and "=".
Used at the bash command line in an emulator those keys emit the following:
040, 041, and 061.

Xev results are available in anyone is interested.

On emacs, pressing these keys results in emacs reading the following
C-u 40-, C-u 41-, and C-u 61-

since these are universal argument sequences, the possibility is that if 
I were
to press one of these keys by mistake and subsequently invoke an emacs 
command,
that command would be executed  as per the prefix and likely to raise 
havoc or
overload the emacs stack.

It is possible to trap these sequences into something harmless?
(It really is a nice keypad except for these nasty little farts.)

thanks

Tim
tj49.com




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-20 21:56 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson wrote:

> On emacs, pressing these keys results in emacs reading the
> following C-u 40-, C-u 41-, and C-u 61-

Can't you `C-h k KEY', find out their names, and rebind them?

If not, you can perhaps remap/redefine/advice
`universal-argument' (or what comes after it; use the source,
Luke) so that 40, 41 and 61 are dropped.

Because you don't use them anywhere else, do you? ;)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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
  0 siblings, 1 reply; 25+ messages in thread
From: Tim Johnson @ 2021-08-20 22:37 UTC (permalink / raw)
  To: help-gnu-emacs



On 8/20/21 1:56 PM, Emanuel Berg via Users list for the GNU Emacs text 
editor wrote:
> Tim Johnson wrote:
>
>> On emacs, pressing these keys results in emacs reading the
>> following C-u 40-, C-u 41-, and C-u 61-
> Can't you `C-h k KEY', find out their names, and rebind them?
I hadn't thought of that: It turns out that all three keys send <M-kp-0> 
to C-h k KEY
I will try writing a simple defun to see if a second sequence is trapped 
by elisp.
If so, I could just bind them to the printed legends or something else.
>
> If not, you can perhaps remap/redefine/advice
> `universal-argument' (or what comes after it; use the source,
> Luke) so that 40, 41 and 61 are dropped.
(universal-argument) runs deep as it dispatches further defuns:
(prefix-command-preserve-state)
   (setq prefix-arg (list 4))
   (universal-argument--mode)

>
> Because you don't use them anywhere else, do you? ;)
Heavens no!
>

-- 
Tim
tj49.com




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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
  0 siblings, 1 reply; 25+ messages in thread
From: Yuri Khan @ 2021-08-21  5:08 UTC (permalink / raw)
  To: Tim Johnson; +Cc: help-gnu-emacs

On Sat, 21 Aug 2021 at 05:38, Tim Johnson <tim@akwebsoft.com> wrote:
> On 8/20/21 1:56 PM, Emanuel Berg wrote:
> > Tim Johnson wrote:
> >
> >> On emacs, pressing these keys results in emacs reading the
> >> following C-u 40-, C-u 41-, and C-u 61-
> > Can't you `C-h k KEY', find out their names, and rebind them?
> I hadn't thought of that: It turns out that all three keys send <M-kp-0>

This seems to be the Windows-specific way to enter characters by
holding down Alt and typing the decimal character code. 40 is U+0028
‘(’, 41 is U+0029 ‘)’ and 61 is U+003D ‘=’.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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
  0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21  5:22 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>>> Can't you `C-h k KEY', find out their names, and
>>> rebind them?
>>
>> I hadn't thought of that: It turns out that all three keys
>> send <M-kp-0>
>
> This seems to be the Windows-specific way to enter
> characters by holding down Alt and typing the decimal
> character code. 40 is U+0028 ‘(’, 41 is U+0029 ‘)’ and 61 is
> U+003D ‘=’.

Great, then you (the OP) can disable with, e.g.,

  (define-key input-decode-map [?\u0028] nil)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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:42           ` Trapping prefixes with universal argument component Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 2 replies; 25+ messages in thread
From: Yuri Khan @ 2021-08-21  5:39 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

On Sat, 21 Aug 2021 at 12:22, Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Great, then you (the OP) can disable with, e.g.,
>
>   (define-key input-decode-map [?\u0028] nil)

I think this will disable the open parenthesis almost completely. Not
a good idea for a lisper ;)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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:42           ` Trapping prefixes with universal argument component Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 1 reply; 25+ messages in thread
From: Tim Johnson @ 2021-08-21 15:18 UTC (permalink / raw)
  To: help-gnu-emacs



On 8/20/21 9:39 PM, Yuri Khan wrote:
> On Sat, 21 Aug 2021 at 12:22, Emanuel Berg via Users list for the GNU
> Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
>> Great, then you (the OP) can disable with, e.g.,
>>
>>    (define-key input-decode-map [?\u0028] nil)
> I think this will disable the open parenthesis almost completely. Not
> a good idea for a lisper ;)

(define-key input-decode-map [?\u0028] nil) did not work.
Neither did reassigning M-kp-0
As for lisping, I've got brackets on my keyboard and defuns for balanced pairs.
It is probably a non-issue. Since the keys are removable, I'll just pull the
offending ones off if they give me grief.

Thank you folks!

-- 
Tim
tj49.com




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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
                                 ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21 19:31 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson wrote:

> Neither did reassigning M-kp-0

Hm, maybe it should be put like this: M-<kp-0> ?

  (define-key input-decode-map [M-<kp-0>] nil)

I have a tenkeyless keyboard so I can't try. But it works, it
is even mentioned here (search for "kp-")
  
(info "(Emacs)Function keys")
https://www.gnu.org/software/emacs/manual/html_node/emacs/Function-Keys.html

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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:23               ` Tim Johnson
  2 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21 19:38 UTC (permalink / raw)
  To: help-gnu-emacs

> Hm, maybe it should be put like this ...

It should be put like this

  [M-kp-0]

or

  (kbd "M-<kp-0>")

which evaluates to the same thing (the vector).

<M-kp-0> is the "pretty description", see

  (key-description (kbd "M-<kp-0>"))

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  2021-08-21  5:39         ` Yuri Khan
  2021-08-21 15:18           ` Tim Johnson
@ 2021-08-21 19:42           ` Emanuel Berg via Users list for the GNU Emacs text editor
  1 sibling, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21 19:42 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

>> Great, then you (the OP) can disable with, e.g.,
>>
>>   (define-key input-decode-map [?\u0028] nil)
>
> I think this will disable the open parenthesis almost
> completely. Not a good idea for a lisper ;)

Oh, so that wasn't the key!

... or was it?

*confused*

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Trapping prefixes with universal argument component
  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               ` Drew Adams
  2021-08-21 21:03                 ` Drew Adams
                                   ` (2 more replies)
  2021-08-21 21:23               ` Tim Johnson
  2 siblings, 3 replies; 25+ messages in thread
From: Drew Adams @ 2021-08-21 20:08 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

> > Neither did reassigning M-kp-0
> Hm, maybe it should be put like this: M-<kp-0> ?
>   (define-key input-decode-map [M-<kp-0>] nil)

The way to get such things right, assuming that your
keyboard and Emacs can effect the key, is to do this:

1. Use `C-h k' to find out how Emacs itself describes
   (names) the key sequence.  This tells me:

   M-0 (translated from <M-kp-0>) runs the command...

2. Change that to a string by wrapping with "...":
   "<M-kp-0>".

3. Pass that to `kbd': (kbd "<M-kp-0>")

That's your answer.  And if you want to see what
that ends up being (but you [M-kp-0]don't need to), eval
it: the result is [M-kp-0].

So you can use either (kbd "<M-kp-0>") or [M-kp-0].

Moral: Ask Emacs.  Emacs will tell you what to call
any key sequence.  Then feed that to `kbd'.  CQFD.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13841 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Trapping prefixes with universal argument component
  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:19                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2021-08-21 21:03 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

> what that ends up being (but you [M-kp-0]don't need to),
                                   ^^^^^^^^

Typo - extra [M-kp-0] inserted there. Shoulda just been:

  what that ends up being (but you don't need to),



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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:23               ` Tim Johnson
  2021-08-21 23:25                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 1 reply; 25+ messages in thread
From: Tim Johnson @ 2021-08-21 21:23 UTC (permalink / raw)
  To: help-gnu-emacs



On 8/21/21 11:31 AM, Emanuel Berg via Users list for the GNU Emacs text 
editor wrote:
> Tim Johnson wrote:
>
>> Neither did reassigning M-kp-0
> Hm, maybe it should be put like this: M-<kp-0> ?
>
>    (define-key input-decode-map [M-<kp-0>] nil)
Thanks again Emanuel :
I get no result using the code above. The universal arguments as
described in the opening of this post are still there and c-h k M-kp-0 
stills gives the
documentation for:
M-0 (translated from <M-kp-0>) runs the command digit-argument (found
in global-map), which is an interactive compiled Lisp function in ...
>
> I have a tenkeyless keyboard so I can't try. But it works, it
> is even mentioned here (search for "kp-")
>    
> (info "(Emacs)Function keys")
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Function-Keys.html
>

-- 
Tim
tj49.com




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Trapping prefixes with universal argument component
  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-21 23:19                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2 siblings, 2 replies; 25+ messages in thread
From: Tim Johnson @ 2021-08-21 21:30 UTC (permalink / raw)
  To: help-gnu-emacs



On 8/21/21 12:08 PM, Drew Adams wrote:
>>> Neither did reassigning M-kp-0
>> Hm, maybe it should be put like this: M-<kp-0> ?
>>    (define-key input-decode-map [M-<kp-0>] nil)
> The way to get such things right, assuming that your
> keyboard and Emacs can effect the key, is to do this:
>
> 1. Use `C-h k' to find out how Emacs itself describes
>     (names) the key sequence.  This tells me:
>
>     M-0 (translated from <M-kp-0>) runs the command...
>
> 2. Change that to a string by wrapping with "...":
>     "<M-kp-0>".
>
> 3. Pass that to `kbd': (kbd "<M-kp-0>")
>
> That's your answer.  And if you want to see what
> that ends up being (but you [M-kp-0]don't need to), eval
> it: the result is [M-kp-0].
>
> So you can use either (kbd "<M-kp-0>") or [M-kp-0].
Thanks Drew: I always using the kbd method and that is what I originally 
used to reassign.
It just did not work. The other side of this is that these three keys 
are effectively leaders
and I have used them as such in the past. But I'm now retired and just 
want to make things
simple. I think I will just pull the keycaps and wrap some duct tape 
over the switches.

After all, if duct tape is good enough for Red Green, it's good enough 
for me ... :)

-- 
Tim
tj49.com




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Trapping prefixes with universal argument component
  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:19                 ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-08-22  1:46                   ` Drew Adams
  2 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21 23:19 UTC (permalink / raw)
  To: help-gnu-emacs

Drew Adams wrote:

> Moral: Ask Emacs ...
> CQFD

Can I ask Emacs what that means as well?

Well, Emacs-w3m, if that counts, tells me it is the French
counterpart of the Swedish VSB, "vilket skulle bevisas" (or
the Swedish VSB is the counterpart of the French CQFD, "ce
qu'il fallait démontrer", if you'd like).

In English it is in Latin, QED for "quod erat demonstrandum".
<https://en.wikipedia.org/wiki/Q.E.D.>

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Trapping prefixes with universal argument component
  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
  1 sibling, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21 23:21 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson wrote:

>> So you can use either (kbd "<M-kp-0>") or [M-kp-0].
>
> Thanks Drew: I always using the kbd method and that is what
> I originally used to reassign. It just did not work.

Uhm ... "It" = ?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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  8:13                   ` Yuri Khan
  0 siblings, 2 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-21 23:25 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson wrote:

> I get no result using the code above.

Try this then ... should work

  (global-set-key [M-kp-0] nil)

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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
  1 sibling, 1 reply; 25+ messages in thread
From: Tim Johnson @ 2021-08-22  0:42 UTC (permalink / raw)
  To: help-gnu-emacs



On 8/21/21 3:25 PM, Emanuel Berg via Users list for the GNU Emacs text 
editor wrote:
> (global-set-key [M-kp-0] nil)
Thanks again Emanuel, but still no joy. Baffling, huh?

-- 
Tim
tj49.com




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  2021-08-22  0:42                   ` Tim Johnson
@ 2021-08-22  0:51                     ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-22  0:51 UTC (permalink / raw)
  To: help-gnu-emacs

Tim Johnson wrote:

>> (global-set-key [M-kp-0] nil)
>
> Thanks again Emanuel, but still no joy. Baffling, huh?

Heh, yes, because if it registers the key and the key can be
expressed then it should be possible to disable! But OK,
it isn't for whatever reason ...

Okay then, only one thing left to do. Make a small
semi-transparent box in neon green plastic, with a little
hinge - when you use Emacs, put it down so you can't reach the
keys by accident ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Trapping prefixes with universal argument component
  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
  1 sibling, 1 reply; 25+ messages in thread
From: Drew Adams @ 2021-08-22  1:43 UTC (permalink / raw)
  To: Tim Johnson, help-gnu-emacs@gnu.org

> After all, if duct tape is good enough for Red Green,
> it's good enough for me ... :)

An Emacs fan of the Red & Green Show.  And knows
how to spell "duct" tape"?  Will wonders never cease?
Hang in there - and happy retirement too!



^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [External] : Re: Trapping prefixes with universal argument component
  2021-08-21 23:19                 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-08-22  1:46                   ` Drew Adams
  0 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2021-08-22  1:46 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

> > CQFD
> 
> Can I ask Emacs what that means as well?

Should be able to.  May need some more matchin learnin...
> 
> Well, Emacs-w3m, if that counts, tells me it is the French
> counterpart of the Swedish VSB, "vilket skulle bevisas" (or
> the Swedish VSB is the counterpart of the French CQFD, "ce
> qu'il fallait démontrer", if you'd like).
> 
> In English it is in Latin, QED for "quod erat demonstrandum".

Bingo!

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13801 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [External] : Re: Trapping prefixes with universal argument component
  2021-08-22  1:43                   ` Drew Adams
@ 2021-08-22  2:51                     ` Arthur Miller
  0 siblings, 0 replies; 25+ messages in thread
From: Arthur Miller @ 2021-08-22  2:51 UTC (permalink / raw)
  To: Drew Adams; +Cc: Tim Johnson, help-gnu-emacs@gnu.org

Drew Adams <drew.adams@oracle.com> writes:

>> After all, if duct tape is good enough for Red Green,
>> it's good enough for me ... :)
>
> An Emacs fan of the Red & Green Show.  And knows
> how to spell "duct" tape"?
Duct tape a man's true best friend: there is no appliance a little bit of
duct tape and a handy man can't fix! :)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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  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                     ` Trapping prefixes with universal argument component [solved]T Tim Johnson
  1 sibling, 2 replies; 25+ messages in thread
From: Yuri Khan @ 2021-08-22  8:13 UTC (permalink / raw)
  To: Emanuel Berg, help-gnu-emacs

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)

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



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component
  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                     ` Trapping prefixes with universal argument component [solved]T Tim Johnson
  1 sibling, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-22  8:25 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan wrote:

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

Really? I have disabled a lot of keys with nil, maybe they
didn't get translated, that's why ... Should change them to
'ignore then, thanks.

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Trapping prefixes with universal argument component [solved]T
  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
  1 sibling, 0 replies; 25+ messages in thread
From: Tim Johnson @ 2021-08-22 18:14 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2021-08-22 18:14 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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                     ` Trapping prefixes with universal argument component [solved]T Tim Johnson
2021-08-21 19:42           ` Trapping prefixes with universal argument component Emanuel Berg via Users list for the GNU Emacs text editor

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.