* Modified keypad keys
@ 2012-09-28 6:40 Per Starbäck
2012-09-28 8:23 ` Stefan Monnier
0 siblings, 1 reply; 23+ messages in thread
From: Per Starbäck @ 2012-09-28 6:40 UTC (permalink / raw)
To: emacs-devel
"(emacs) Function Keys" says:
> By default, Emacs translates these keys to the corresponding keys in
> the main keyboard. [...] Note that the modified keys are not
> translated: for instance, if you hold down the <META> key while
> pressing the `8' key on the numeric keypad, that generates `M-<kp-8>'.
I wonder what the rationale for that is? Would there be drawbacks in letting
<M-kp-8> behave as M-8 as long as there is no explicit binding for <M-kp-8>?
The reason I wonder this is because I recently watched a student of mine trying
C-x <C-kp-add> after reading about C-x C-+.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-28 6:40 Modified keypad keys Per Starbäck
@ 2012-09-28 8:23 ` Stefan Monnier
2012-09-28 15:29 ` Juri Linkov
0 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2012-09-28 8:23 UTC (permalink / raw)
To: Per Starbäck; +Cc: emacs-devel
> I wonder what the rationale for that is?
No good reason, AFAIK.
> Would there be drawbacks in letting <M-kp-8> behave as M-8 as long as
> there is no explicit binding for <M-kp-8>?
No, other than the fact that doing it for all combinations of modifiers
leads to adding lots and lots of entries to function-key-map.
Stefan
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-28 8:23 ` Stefan Monnier
@ 2012-09-28 15:29 ` Juri Linkov
2012-09-28 20:16 ` Stefan Monnier
0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2012-09-28 15:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Per Starbäck, emacs-devel
>> I wonder what the rationale for that is?
>
> No good reason, AFAIK.
>
>> Would there be drawbacks in letting <M-kp-8> behave as M-8 as long as
>> there is no explicit binding for <M-kp-8>?
>
> No, other than the fact that doing it for all combinations of modifiers
> leads to adding lots and lots of entries to function-key-map.
Had the same problem and here is what I got so far.
Don't know if it's good to install something like this?
=== modified file 'lisp/bindings.el'
--- lisp/bindings.el 2012-09-23 10:21:34 +0000
+++ lisp/bindings.el 2012-09-28 15:27:42 +0000
@@ -1039,36 +1039,31 @@
;; FIXME: rather than list such mappings for every modifier-combination,
;; we should come up with a way to do it generically, something like
;; (define-key function-key-map [*-kp-home] [*-home])
-(define-key function-key-map [kp-home] [home])
-(define-key function-key-map [kp-left] [left])
-(define-key function-key-map [kp-up] [up])
-(define-key function-key-map [kp-right] [right])
-(define-key function-key-map [kp-down] [down])
-(define-key function-key-map [kp-prior] [prior])
-(define-key function-key-map [kp-next] [next])
-(define-key function-key-map [M-kp-next] [M-next])
-(define-key function-key-map [kp-end] [end])
-(define-key function-key-map [kp-begin] [begin])
-(define-key function-key-map [kp-insert] [insert])
+
+(defun powerset (list)
+ (if (null list)
+ '(nil)
+ (let ((ps (powerset (cdr list))))
+ (append ps (mapcar (lambda (e) (cons (car list) e)) ps)))))
+
+(let ((modifiers (powerset '(control meta super hyper)))
+ (keys '((kp-end . end) (kp-down . down) (kp-next . next)
+ (kp-left . left) (kp-begin . begin) (kp-right . right)
+ (kp-home . home) (kp-up . up) (kp-prior . prior)
+ (kp-insert . insert) (kp-delete . delete) (kp-enter . enter)
+ (kp-add . +) (kp-subtract . -) (kp-multiply . *) (kp-divide . /)
+ (kp-1 . ?1) (kp-2 . ?2) (kp-3 . ?3) (kp-4 . ?4) (kp-5 . ?5)
+ (kp-6 . ?6) (kp-7 . ?7) (kp-8 . ?8) (kp-9 . ?9) (kp-0 . ?0)
+ (kp-decimal . .))))
+ (dolist (pair keys)
+ (dolist (mod modifiers)
+ (define-key function-key-map
+ (vector (append mod (list (car pair))))
+ (vector (append mod (list (cdr pair))))))))
+
(define-key function-key-map [backspace] [?\C-?])
(define-key function-key-map [delete] [?\C-?])
(define-key function-key-map [kp-delete] [?\C-?])
-(define-key function-key-map [S-kp-end] [S-end])
-(define-key function-key-map [S-kp-down] [S-down])
-(define-key function-key-map [S-kp-next] [S-next])
-(define-key function-key-map [S-kp-left] [S-left])
-(define-key function-key-map [S-kp-right] [S-right])
-(define-key function-key-map [S-kp-home] [S-home])
-(define-key function-key-map [S-kp-up] [S-up])
-(define-key function-key-map [S-kp-prior] [S-prior])
-(define-key function-key-map [C-S-kp-end] [C-S-end])
-(define-key function-key-map [C-S-kp-down] [C-S-down])
-(define-key function-key-map [C-S-kp-next] [C-S-next])
-(define-key function-key-map [C-S-kp-left] [C-S-left])
-(define-key function-key-map [C-S-kp-right] [C-S-right])
-(define-key function-key-map [C-S-kp-home] [C-S-home])
-(define-key function-key-map [C-S-kp-up] [C-S-up])
-(define-key function-key-map [C-S-kp-prior] [C-S-prior])
;; Don't bind shifted keypad numeric keys, they reportedly
;; interfere with the feature of some keyboards to produce
;; numbers when NumLock is off.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-28 15:29 ` Juri Linkov
@ 2012-09-28 20:16 ` Stefan Monnier
2012-09-29 2:14 ` Stefan Monnier
2012-09-29 19:19 ` Juri Linkov
0 siblings, 2 replies; 23+ messages in thread
From: Stefan Monnier @ 2012-09-28 20:16 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, emacs-devel
> +(defun powerset (list)
> + (if (null list)
> + '(nil)
> + (let ((ps (powerset (cdr list))))
> + (append ps (mapcar (lambda (e) (cons (car list) e)) ps)))))
I'm not sure I want `powerset' without some "<prefix>-".
> +(let ((modifiers (powerset '(control meta super hyper)))
You forgot shift.
So that's a total of 27 * 32 entries. Makes this function-key-map alist
pretty, if you ask me.
Stefan
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-28 20:16 ` Stefan Monnier
@ 2012-09-29 2:14 ` Stefan Monnier
2012-09-29 19:19 ` Juri Linkov
1 sibling, 0 replies; 23+ messages in thread
From: Stefan Monnier @ 2012-09-29 2:14 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, emacs-devel
> So that's a total of 27 * 32 entries. Makes this function-key-map alist
> pretty, if you ask me.
^^
long
-- Stefan
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-28 20:16 ` Stefan Monnier
2012-09-29 2:14 ` Stefan Monnier
@ 2012-09-29 19:19 ` Juri Linkov
2012-09-30 1:41 ` Stefan Monnier
2012-10-01 8:02 ` power set (Re: Modified keypad keys) Stephen Berman
1 sibling, 2 replies; 23+ messages in thread
From: Juri Linkov @ 2012-09-29 19:19 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Per Starbäck, emacs-devel
>> +(defun powerset (list)
>> + (if (null list)
>> + '(nil)
>> + (let ((ps (powerset (cdr list))))
>> + (append ps (mapcar (lambda (e) (cons (car list) e)) ps)))))
>
> I'm not sure I want `powerset' without some "<prefix>-".
Maybe `cl-powerset', to be added to cl-seq.el.
>> +(let ((modifiers (powerset '(control meta super hyper)))
>
> You forgot shift.
Not sure about shift. It's used to toggle the layout of the keypad
at the system level. Also `shift-select-mode' comes into play.
So without adding `shift' to these remappings, when e.g.
`kp-7' self-inserts `7', `S-kp-7' selects the region
to the beginning of the line.
> So that's a total of 27 * 32 entries. Makes this function-key-map alist
> pretty long, if you ask me.
An alternative is to do as suggested in the comments:
;; X11R6 distinguishes these keys from the non-kp keys.
;; Make them behave like the non-kp keys unless otherwise bound.
;; FIXME: rather than list such mappings for every modifier-combination,
;; we should come up with a way to do it generically, something like
;; (define-key function-key-map [*-kp-home] [*-home])
I guess `*' should be a symbol like `shift', so it would be possible
also use this notation:
(define-key function-key-map [(* kp-home)] [(* home)])
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-29 19:19 ` Juri Linkov
@ 2012-09-30 1:41 ` Stefan Monnier
2012-09-30 9:56 ` Juri Linkov
2012-10-01 8:02 ` power set (Re: Modified keypad keys) Stephen Berman
1 sibling, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2012-09-30 1:41 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, emacs-devel
> Not sure about shift. It's used to toggle the layout of the keypad
> at the system level. Also `shift-select-mode' comes into play.
> So without adding `shift' to these remappings, when e.g.
> `kp-7' self-inserts `7', `S-kp-7' selects the region
> to the beginning of the line.
I'm not sure I understand. By `S-kp-7' do you mean "Emacs sees the
event S-kp-7" or "I press the key 7 on the numeric keypad while pressing
shift at the same time"?
I can't see why Emacs would move to the beginning of line in response to
the S-kp-7 event, unless you've added bindings on your own, but I can
imagine that pressing that numeric-keypad-7 with shift might end up
sending to Emacs some different event such as `S-home', which would
behave like you describe. If that's the case then adding shift among
the modifiers in your code would simply not affect your case (but it
would still be useful for other keyboards).
>> So that's a total of 27 * 32 entries. Makes this function-key-map alist
>> pretty long, if you ask me.
> An alternative is to do as suggested in the comments:
> ;; X11R6 distinguishes these keys from the non-kp keys.
> ;; Make them behave like the non-kp keys unless otherwise bound.
> ;; FIXME: rather than list such mappings for every modifier-combination,
> ;; we should come up with a way to do it generically, something like
> ;; (define-key function-key-map [*-kp-home] [*-home])
> I guess `*' should be a symbol like `shift', so it would be possible
> also use this notation:
> (define-key function-key-map [(* kp-home)] [(* home)])
The XEmacs [(foo bar)] notation is turned internally into the [foo-bar]
notation, so once we support [*-kp-home], we can extend that rewrite to
also support [(* kp-home)].
BTW, my current take on how to do the above, is to add "functional
keymaps", i.e. keymaps that are described by a function. That function
would probably take 2 args: the first being the method invoked and the
second being the method's arg(s). One of the methods would be `lookup',
another would be `map' (for map-keymap), not sure what else would
be needed.
And so far the best representation I could come up with is (keymap . FUN).
Such keymaps would be very useful for function-key-map, especially if we
change function-key-map to apply itself repeatedly (i.e. to re-apply
function-key-map to the key sequence after applying function-key-map).
With this, it should be possible to move many of the hardcoded
remappings ("remap `S-key' to `key' if `S-key' is unbound", "drop
down-mouse-N if unbound", ...) from the read_key_sequence monster to
simple function-key-map entries.
Stefan
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-30 1:41 ` Stefan Monnier
@ 2012-09-30 9:56 ` Juri Linkov
2012-09-30 19:45 ` Stefan Monnier
0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2012-09-30 9:56 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Per Starbäck, emacs-devel
>> Not sure about shift. It's used to toggle the layout of the keypad
>> at the system level. Also `shift-select-mode' comes into play.
>> So without adding `shift' to these remappings, when e.g.
>> `kp-7' self-inserts `7', `S-kp-7' selects the region
>> to the beginning of the line.
>
> I'm not sure I understand. By `S-kp-7' do you mean "Emacs sees the
> event S-kp-7" or "I press the key 7 on the numeric keypad while pressing
> shift at the same time"?
> I can't see why Emacs would move to the beginning of line in response to
> the S-kp-7 event, unless you've added bindings on your own, but I can
> imagine that pressing that numeric-keypad-7 with shift might end up
> sending to Emacs some different event such as `S-home', which would
> behave like you describe. If that's the case then adding shift among
> the modifiers in your code would simply not affect your case (but it
> would still be useful for other keyboards).
In the current trunk's `emacs -Q' when NumLock is off, `C-h k' for
pressing the key 7 on the numeric keypad displays:
<home> (translated from <kp-home>) runs the command move-beginning-of-line
pressing the key 7 while pressing shift at the same time:
7 (translated from <S-kp-7>) runs the command self-insert-command
When NumLock is on, pressing the key 7 on the numeric keypad:
7 (translated from <kp-7>) runs the command self-insert-command
pressing the key 7 while pressing shift at the same time:
<home> (translated from <S-kp-home>) runs the command move-beginning-of-line
and selects the region to the beginning of the line
when `shift-select-mode' is t.
`xev' displays for the key 7 when NumLock is off:
state 0x0, keycode 79 (keysym 0xff95, KP_Home), same_screen YES,
and while pressing shift at the same time:
state 0x1, keycode 79 (keysym 0xffb7, KP_7), same_screen YES,
When NumLock is on, `xev' displays for the key 7:
state 0x110, keycode 79 (keysym 0xffb7, KP_7), same_screen YES,
and while pressing shift at the same time:
state 0x11, keycode 79 (keysym 0xff95, KP_Home), same_screen YES,
In the trunk's bindings.el shift key bindings are commented out
with the following comment:
;; Don't bind shifted keypad numeric keys, they reportedly
;; interfere with the feature of some keyboards to produce
;; numbers when NumLock is off.
;(define-key function-key-map [S-kp-1] [S-end])
;(define-key function-key-map [S-kp-2] [S-down])
;(define-key function-key-map [S-kp-3] [S-next])
;(define-key function-key-map [S-kp-4] [S-left])
;(define-key function-key-map [S-kp-6] [S-right])
;(define-key function-key-map [S-kp-7] [S-home])
;(define-key function-key-map [S-kp-8] [S-up])
;(define-key function-key-map [S-kp-9] [S-prior])
(define-key function-key-map [C-S-kp-1] [C-S-end])
(define-key function-key-map [C-S-kp-2] [C-S-down])
(define-key function-key-map [C-S-kp-3] [C-S-next])
(define-key function-key-map [C-S-kp-4] [C-S-left])
(define-key function-key-map [C-S-kp-6] [C-S-right])
(define-key function-key-map [C-S-kp-7] [C-S-home])
(define-key function-key-map [C-S-kp-8] [C-S-up])
(define-key function-key-map [C-S-kp-9] [C-S-prior])
Perhaps the bottom part for C-S- should be commented out as well
for the same reason as explained in the comment above.
So the remaining controversial question is whether pressing
the key 7 while pressing shift at the same time when NumLock is on
should select the region or not. There are equally good reasons
for both of these variants.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-30 9:56 ` Juri Linkov
@ 2012-09-30 19:45 ` Stefan Monnier
2012-10-01 9:29 ` Juri Linkov
0 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2012-09-30 19:45 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, emacs-devel
> In the current trunk's `emacs -Q' when NumLock is off, `C-h k' for
> pressing the key 7 on the numeric keypad displays:
[...]
So the kp-7 vs kp-home choice is done at a low-level, as expected.
So adding remappings like S-kp-home => S-home to function-key-map is
a good idea.
[ Of course there's the question whether S-kp-home should be turned
into `home' via `kp-home' or via `S-home'. ]
> In the trunk's bindings.el shift key bindings are commented out
> with the following comment:
These are very different remappings, which seemed to be aimed at
reimplementing what your low-level keyboard code already provides.
> ;; Don't bind shifted keypad numeric keys, they reportedly
> ;; interfere with the feature of some keyboards to produce
> ;; numbers when NumLock is off.
> ;(define-key function-key-map [S-kp-1] [S-end])
> ;(define-key function-key-map [S-kp-2] [S-down])
> ;(define-key function-key-map [S-kp-3] [S-next])
> ;(define-key function-key-map [S-kp-4] [S-left])
> ;(define-key function-key-map [S-kp-6] [S-right])
> ;(define-key function-key-map [S-kp-7] [S-home])
> ;(define-key function-key-map [S-kp-8] [S-up])
> ;(define-key function-key-map [S-kp-9] [S-prior])
> (define-key function-key-map [C-S-kp-1] [C-S-end])
> (define-key function-key-map [C-S-kp-2] [C-S-down])
> (define-key function-key-map [C-S-kp-3] [C-S-next])
> (define-key function-key-map [C-S-kp-4] [C-S-left])
> (define-key function-key-map [C-S-kp-6] [C-S-right])
> (define-key function-key-map [C-S-kp-7] [C-S-home])
> (define-key function-key-map [C-S-kp-8] [C-S-up])
> (define-key function-key-map [C-S-kp-9] [C-S-prior])
> Perhaps the bottom part for C-S- should be commented out as well
> for the same reason as explained in the comment above.
Yes, probably.
Stefan
^ permalink raw reply [flat|nested] 23+ messages in thread
* power set (Re: Modified keypad keys)
2012-09-29 19:19 ` Juri Linkov
2012-09-30 1:41 ` Stefan Monnier
@ 2012-10-01 8:02 ` Stephen Berman
2012-10-01 8:35 ` Christopher Monsanto
2012-10-01 9:27 ` Juri Linkov
1 sibling, 2 replies; 23+ messages in thread
From: Stephen Berman @ 2012-10-01 8:02 UTC (permalink / raw)
To: Juri Linkov; +Cc: Stefan Monnier, emacs-devel
On Sat, 29 Sep 2012 22:19:35 +0300 Juri Linkov <juri@jurta.org> wrote:
>>> +(defun powerset (list)
>>> + (if (null list)
>>> + '(nil)
>>> + (let ((ps (powerset (cdr list))))
>>> + (append ps (mapcar (lambda (e) (cons (car list) e)) ps)))))
>>
>> I'm not sure I want `powerset' without some "<prefix>-".
>
> Maybe `cl-powerset', to be added to cl-seq.el.
I would like to have a power set function in Emacs. But why do you use
'(nil) for the empty set instead of '() or nil? I use nil in a variant
of the above in a program I'm working on. As an alternative to the
recursive definition, I've also been using this iterative bitwise
version (which I translated into Elisp from the C program at
http://rosettacode.org/wiki/Power_set#C):
(defun powerset-bitwise (l)
(let ((binnum (lsh 1 (length l)))
pset elt)
(dotimes (i binnum)
(let ((bits i)
(ll l))
(while (not (zerop bits))
(let ((arg (pop ll)))
(unless (zerop (logand bits 1))
(setq elt (append elt (list arg))))
(setq bits (lsh bits -1))))
(setq pset (append pset (list elt)))
(setq elt nil)))
pset))
In my use case the cardinality of the power set is small and there's no
noticeable difference in speed between the recursive and the iterative
versions, but maybe it makes a difference for large sets.
Steve Berman
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: power set (Re: Modified keypad keys)
2012-10-01 8:02 ` power set (Re: Modified keypad keys) Stephen Berman
@ 2012-10-01 8:35 ` Christopher Monsanto
2012-10-01 9:07 ` Stephen Berman
2012-10-01 9:27 ` Juri Linkov
1 sibling, 1 reply; 23+ messages in thread
From: Christopher Monsanto @ 2012-10-01 8:35 UTC (permalink / raw)
To: Stephen Berman; +Cc: Juri Linkov, Stefan Monnier, emacs-devel
The powerset is a set of sets. The empty set is always a member of the
powerset, as the empty set is a subset of any other set. Or in other
words, if (length (powerset ...)) is ever zero, you have a bug. Using
'() or nil is incorrect.
Christopher Monsanto
chris@monsan.to -- http://monsan.to/
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: power set (Re: Modified keypad keys)
2012-10-01 8:35 ` Christopher Monsanto
@ 2012-10-01 9:07 ` Stephen Berman
2012-10-01 12:42 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 23+ messages in thread
From: Stephen Berman @ 2012-10-01 9:07 UTC (permalink / raw)
To: Christopher Monsanto; +Cc: Juri Linkov, Stefan Monnier, emacs-devel
On Mon, 1 Oct 2012 04:35:42 -0400 Christopher Monsanto <chris@monsan.to> wrote:
> The powerset is a set of sets. The empty set is always a member of the
> powerset, as the empty set is a subset of any other set. Or in other
> words, if (length (powerset ...)) is ever zero, you have a bug. Using
> '() or nil is incorrect.
Of course you're right, and in fact I don't use nil, but (list nil) (as
the iterative version I gave entails), which is here the same as '(). I
don't know why I wrote that I use nil, brain fart I guess.
Steve Berman
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: power set (Re: Modified keypad keys)
2012-10-01 8:02 ` power set (Re: Modified keypad keys) Stephen Berman
2012-10-01 8:35 ` Christopher Monsanto
@ 2012-10-01 9:27 ` Juri Linkov
1 sibling, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2012-10-01 9:27 UTC (permalink / raw)
To: Stephen Berman; +Cc: Stefan Monnier, emacs-devel
> As an alternative to the recursive definition, I've also been using
> this iterative bitwise version (which I translated into Elisp from the
> C program at http://rosettacode.org/wiki/Power_set#C):
Often a C version doesn't translate nicely to Lisp when translated
literally. If you prefer an iterative version instead of recursive,
you could look at the Common Lisp section of
http://rosettacode.org/wiki/Power_set#Common_Lisp
and find the following short iterative version:
(defun powerset (xs)
(loop for i below (expt 2 (length xs)) collect
(loop for j below i for x in xs if (logbitp j i) collect x)))
There is no `logbitp' function in Emacs, but you could use a replacement
like this:
(defun logbitp (j i) (> (logand i (lsh 1 j)) 0))
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-09-30 19:45 ` Stefan Monnier
@ 2012-10-01 9:29 ` Juri Linkov
2012-10-01 15:03 ` Stefan Monnier
0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2012-10-01 9:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Per Starbäck, emacs-devel
> So the kp-7 vs kp-home choice is done at a low-level, as expected.
> So adding remappings like S-kp-home => S-home to function-key-map is
> a good idea.
Yes, I guess S-kp-home => S-home could be added since it does no harm
when it is already translated at a low-level.
> [ Of course there's the question whether S-kp-home should be turned
> into `home' via `kp-home' or via `S-home'. ]
When simply adding `shift' to the list of modifiers in
(let ((modifiers (cl-powerset '(control meta shift super hyper)))
(keys '((kp-end . end) (kp-down . down) (kp-next . next)
(kp-left . left) (kp-begin . begin) (kp-right . right)
(kp-home . home) (kp-up . up) (kp-prior . prior)
(kp-insert . insert) (kp-delete . delete) (kp-enter . enter)
(kp-add . +) (kp-subtract . -) (kp-multiply . *) (kp-divide . /)
(kp-1 . ?1) (kp-2 . ?2) (kp-3 . ?3) (kp-4 . ?4) (kp-5 . ?5)
(kp-6 . ?6) (kp-7 . ?7) (kp-8 . ?8) (kp-9 . ?9) (kp-0 . ?0)
(kp-decimal . .))))
(dolist (pair keys)
(dolist (mod modifiers)
(define-key function-key-map
(vector (append mod (list (car pair))))
(vector (append mod (list (cdr pair))))))))
it will turn `S-kp-home' into `home' via `S-home'.
>> ;; Don't bind shifted keypad numeric keys, they reportedly
>> ;; interfere with the feature of some keyboards to produce
>> ;; numbers when NumLock is off.
>> ...
>> ;(define-key function-key-map [S-kp-7] [S-home])
>> ...
>> (define-key function-key-map [C-S-kp-7] [C-S-home])
>
> These are very different remappings, which seemed to be aimed at
> reimplementing what your low-level keyboard code already provides.
So remappings like S-kp-7 => S-home should be still used
when low-level keyboard code doesn't translate them?
But I don't know how to detect this configuration when
low-level keyboard code doesn't supports such translation.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: power set (Re: Modified keypad keys)
2012-10-01 9:07 ` Stephen Berman
@ 2012-10-01 12:42 ` Lars Magne Ingebrigtsen
2012-10-01 13:06 ` Stephen Berman
0 siblings, 1 reply; 23+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-10-01 12:42 UTC (permalink / raw)
To: Stephen Berman; +Cc: Juri Linkov, Stefan Monnier, emacs-devel
Stephen Berman <stephen.berman@gmx.net> writes:
> Of course you're right, and in fact I don't use nil, but (list nil) (as
> the iterative version I gave entails), which is here the same as '(). I
> don't know why I wrote that I use nil, brain fart I guess.
'()
=> nil
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: power set (Re: Modified keypad keys)
2012-10-01 12:42 ` Lars Magne Ingebrigtsen
@ 2012-10-01 13:06 ` Stephen Berman
0 siblings, 0 replies; 23+ messages in thread
From: Stephen Berman @ 2012-10-01 13:06 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: Juri Linkov, Stefan Monnier, emacs-devel
On Mon, 01 Oct 2012 14:42:56 +0200 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote:
> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> Of course you're right, and in fact I don't use nil, but (list nil) (as
>> the iterative version I gave entails), which is here the same as '(). I
>> don't know why I wrote that I use nil, brain fart I guess.
>
> '()
> => nil
Oops, that wasn't another brain fart, just a typo, honest ;-)
Steve Berman
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-01 9:29 ` Juri Linkov
@ 2012-10-01 15:03 ` Stefan Monnier
2012-10-04 18:41 ` Juri Linkov
0 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2012-10-01 15:03 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, emacs-devel
> When simply adding `shift' to the list of modifiers in
[...]
> it will turn `S-kp-home' into `home' via `S-home'.
Yup. The only way to really get it right is to decide dynamically
whether to turn S-kp-home into S-home or kp-home, based on whether
there is an S-home or a kp-home binding.
>> These are very different remappings, which seemed to be aimed at
>> reimplementing what your low-level keyboard code already provides.
> So remappings like S-kp-7 => S-home should be still used
> when low-level keyboard code doesn't translate them?
Not sure, but that was the intention of the code, it seems.
> But I don't know how to detect this configuration when
> low-level keyboard code doesn't supports such translation.
I think we don't need to provide this feature anymore and can simply
expect that if the user wants it, he'll have to rely on his OS to do it.
Stefan
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-01 15:03 ` Stefan Monnier
@ 2012-10-04 18:41 ` Juri Linkov
2012-10-04 23:26 ` Andreas Schwab
0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2012-10-04 18:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Per Starbäck, emacs-devel
> I think we don't need to provide this feature anymore and can simply
> expect that if the user wants it, he'll have to rely on his OS to do it.
I don't know whether something in this area could be fixed for 24.3,
or should be postponed to the release after the next one,
but there is one strange phenomenon that looks like a bug:
With "emacs -Q -nw" in xterm most shifted arrow keys `S-left',
`S-right', `S-down' work normally and select a region
while moving point in corresponding directions.
But one key `S-up' fails and displays in the echo area:
<select> is undefined
`C-q S-up' inserts to the buffer "^[[1;2A" and there exist
a keybinding for this sequence in lisp/term/xterm.el:
(define-key map "\e[1;2A" [S-up])
I don't understand why it has no effect.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-04 18:41 ` Juri Linkov
@ 2012-10-04 23:26 ` Andreas Schwab
2012-10-05 14:41 ` Andreas Schwab
0 siblings, 1 reply; 23+ messages in thread
From: Andreas Schwab @ 2012-10-04 23:26 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, Stefan Monnier, emacs-devel
Juri Linkov <juri@jurta.org> writes:
> But one key `S-up' fails and displays in the echo area:
>
> <select> is undefined
>
> `C-q S-up' inserts to the buffer "^[[1;2A" and there exist
> a keybinding for this sequence in lisp/term/xterm.el:
>
> (define-key map "\e[1;2A" [S-up])
>
> I don't understand why it has no effect.
ELISP> (lookup-key input-decode-map "\e[1;2A")
[select]
$ infocmp xterm | grep '1;2A'
kpp=\E[5~, kri=\E[1;2A, kslt=\E[4~, mc0=\E[i, mc4=\E[4i,
I think that's a tgetstr bug, it returns the sequence for the S-up key
when looking for the kU capability (the termcap name for kri is actually
kR).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-04 23:26 ` Andreas Schwab
@ 2012-10-05 14:41 ` Andreas Schwab
2012-10-05 16:43 ` Juri Linkov
0 siblings, 1 reply; 23+ messages in thread
From: Andreas Schwab @ 2012-10-05 14:41 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, Stefan Monnier, emacs-devel
Andreas Schwab <schwab@linux-m68k.org> writes:
> Juri Linkov <juri@jurta.org> writes:
>
>> But one key `S-up' fails and displays in the echo area:
>>
>> <select> is undefined
>>
>> `C-q S-up' inserts to the buffer "^[[1;2A" and there exist
>> a keybinding for this sequence in lisp/term/xterm.el:
>>
>> (define-key map "\e[1;2A" [S-up])
>>
>> I don't understand why it has no effect.
>
> ELISP> (lookup-key input-decode-map "\e[1;2A")
> [select]
>
> $ infocmp xterm | grep '1;2A'
> kpp=\E[5~, kri=\E[1;2A, kslt=\E[4~, mc0=\E[i, mc4=\E[4i,
>
> I think that's a tgetstr bug, it returns the sequence for the S-up key
> when looking for the kU capability (the termcap name for kri is actually
> kR).
From tgetstr(3):
Only the first two characters of the id parameter of tgetflag, tgetnum
and tgetstr are compared in lookups.
$ infocmp -a xterm | grep '1;2A'
kpp=\E[5~, kri=\E[1;2A, kslt=\E[4~, mc0=\E[i, mc4=\E[4i,
kRIT6=\E[1;6C, kRIT7=\E[1;7C, kUP=\E[1;2A, kUP3=\E[1;3A,
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-05 14:41 ` Andreas Schwab
@ 2012-10-05 16:43 ` Juri Linkov
2012-10-05 16:55 ` Andreas Schwab
0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2012-10-05 16:43 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Per Starbäck, Stefan Monnier, emacs-devel
> From tgetstr(3):
>
> Only the first two characters of the id parameter of tgetflag, tgetnum
> and tgetstr are compared in lookups.
As I see in src/term.c, it uses two characters when calls `tgetstr',
but when I tried this patch:
=== modified file 'src/term.c'
--- src/term.c 2012-09-23 08:44:20 +0000
+++ src/term.c 2012-10-05 16:35:42 +0000
@@ -1275,6 +1275,8 @@ (at your option) any later version.
{"k8", "f8"},
{"k9", "f9"},
+ {"kF", "S-down"}, /*shifted down-arrow key*/
+ {"kR", "S-up"}, /*shifted up-arrow key*/
{"&0", "S-cancel"}, /*shifted cancel key*/
{"&9", "S-begin"}, /*shifted begin key*/
{"*0", "S-find"}, /*shifted find key*/
it doesn't seem to help. `S-up' still displays "<select> is undefined".
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-05 16:43 ` Juri Linkov
@ 2012-10-05 16:55 ` Andreas Schwab
2012-10-05 17:05 ` Juri Linkov
0 siblings, 1 reply; 23+ messages in thread
From: Andreas Schwab @ 2012-10-05 16:55 UTC (permalink / raw)
To: Juri Linkov; +Cc: Per Starbäck, Stefan Monnier, emacs-devel
Juri Linkov <juri@jurta.org> writes:
> `S-up' still displays "<select> is undefined".
Here:
CONDITIONAL_REASSIGN ("*6", "kU", "select");
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: Modified keypad keys
2012-10-05 16:55 ` Andreas Schwab
@ 2012-10-05 17:05 ` Juri Linkov
0 siblings, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2012-10-05 17:05 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Per Starbäck, Stefan Monnier, emacs-devel
>> `S-up' still displays "<select> is undefined".
>
> Here:
>
> CONDITIONAL_REASSIGN ("*6", "kU", "select");
Thanks, it helps when I remove this line. Its comment says:
/* IBM has their own non-standard dialect of terminfo.
If the standard name isn't found, try the IBM name. */
Shouldn't some #ifdef hide this code block when terminfo is non-IBM?
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2012-10-05 17:05 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-28 6:40 Modified keypad keys Per Starbäck
2012-09-28 8:23 ` Stefan Monnier
2012-09-28 15:29 ` Juri Linkov
2012-09-28 20:16 ` Stefan Monnier
2012-09-29 2:14 ` Stefan Monnier
2012-09-29 19:19 ` Juri Linkov
2012-09-30 1:41 ` Stefan Monnier
2012-09-30 9:56 ` Juri Linkov
2012-09-30 19:45 ` Stefan Monnier
2012-10-01 9:29 ` Juri Linkov
2012-10-01 15:03 ` Stefan Monnier
2012-10-04 18:41 ` Juri Linkov
2012-10-04 23:26 ` Andreas Schwab
2012-10-05 14:41 ` Andreas Schwab
2012-10-05 16:43 ` Juri Linkov
2012-10-05 16:55 ` Andreas Schwab
2012-10-05 17:05 ` Juri Linkov
2012-10-01 8:02 ` power set (Re: Modified keypad keys) Stephen Berman
2012-10-01 8:35 ` Christopher Monsanto
2012-10-01 9:07 ` Stephen Berman
2012-10-01 12:42 ` Lars Magne Ingebrigtsen
2012-10-01 13:06 ` Stephen Berman
2012-10-01 9:27 ` Juri Linkov
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).