all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Keystrokes sending digit prefixes
@ 2016-09-29  0:11 Tim Johnson
  2016-09-29  5:49 ` Yuri Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Tim Johnson @ 2016-09-29  0:11 UTC (permalink / raw)
  To: Emacs

This is less of a problem than (perhaps) an interesting
opportunity.

I'm using emacs 25.1.1 on ubuntu 14.04

I just got a Jelly Comb Keypad. My prefered means of input is a small
footprint "60%" keyboard like a HHK Lite2 (which I've used for
decades) or a qisan mechanical keyboard which I use now -  with a
trackball on the right and a keypad on the left.

The Jelly Comb has three "non-typical" keys: left parens, right
parens and equals.

These keys are not being translated as characters by linux. At the
gnome console, '(' prints 040, ')' prints 041, and '=' prints 061
The python interpreter acts the same way.

xev reads multiple keysyms and keycodes from each press.

Emacs (in Gui mode) handles these keys in an interesting fashion -
at least interesting to me.

On emacs, these three keys produce digit prefixes: 40, 41 and 60
respectively.

Speaking as an emacs noob (always, and forever a noob), it seems to
me that these keys can function like an escape prefix or as ersatz
modifiers.

The following test function produced which I expected :

(defun test-kp (arg)
  "Test the value of an universal digit argument"
  (interactive "P")
  (if arg
      (cond
       ((= arg 40)
        (message "kp_leftparen"))
       ((= arg 41)
        (message "kp_rightparen"))
       ((= arg 61)
        (message "kp_equal"))
       (t (message "invalid argument")))
    (message "no arg")))

Next is an example of a lisp function which could be bound
to the backspace key. The code is untested:

(defun tj-backspace (arg)
  "Combine backspace with digit prefixes sent by
  the keypad ( and ) and = keys"
  (interactive "P")
  (if arg
      (cond
       ((= arg 40) ;; sent by keypad (
        (tj-strip-all-trailing-whitespace))
       ((= arg 41) ;; sent by keypad )
        (tj-fixup-whitespace-in-line))
       ((= arg 61) ;; sent by keypad =
        (tj-reduce-indentation))
       (t (error "invalid argument")))
    (delete-char -1))) ;; No argument, destructive backspace

(global-set-key (kbd "DEL") 'tj-backspace)

I repeat, untested code, but I'm interested in any comments or
observations.

Any ideas or remarks about the utilization of this? Obviously, it's not portable ...

thanks
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



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

* Re: Keystrokes sending digit prefixes
  2016-09-29  0:11 Keystrokes sending digit prefixes Tim Johnson
@ 2016-09-29  5:49 ` Yuri Khan
  2016-09-29 15:11   ` Tim Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: Yuri Khan @ 2016-09-29  5:49 UTC (permalink / raw)
  To: Emacs

On Thu, Sep 29, 2016 at 7:11 AM, Tim Johnson <tim@akwebsoft.com> wrote:

> The Jelly Comb has three "non-typical" keys: left parens, right
> parens and equals.
>
> These keys are not being translated as characters by linux. At the
> gnome console, '(' prints 040, ')' prints 041, and '=' prints 061
> The python interpreter acts the same way.
>
> xev reads multiple keysyms and keycodes from each press.
>
> Emacs (in Gui mode) handles these keys in an interesting fashion -
> at least interesting to me.
>
> On emacs, these three keys produce digit prefixes: 40, 41 and 60
> respectively.

My crystal ball says they imitate the Windows way of entering
characters by code where you turn on Num Lock, hold down Alt, then
enter the character code on the numeric keypad and finally release
Alt.



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

* Re: Keystrokes sending digit prefixes
  2016-09-29  5:49 ` Yuri Khan
@ 2016-09-29 15:11   ` Tim Johnson
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Johnson @ 2016-09-29 15:11 UTC (permalink / raw)
  To: help-gnu-emacs

* Yuri Khan <yuri.v.khan@gmail.com> [160929 02:37]:
> On Thu, Sep 29, 2016 at 7:11 AM, Tim Johnson <tim@akwebsoft.com> wrote:
> 
> > The Jelly Comb has three "non-typical" keys: left parens, right
> > parens and equals.
> >
> > These keys are not being translated as characters by linux. At the
> > gnome console, '(' prints 040, ')' prints 041, and '=' prints 061
> > The python interpreter acts the same way.
> >
> > xev reads multiple keysyms and keycodes from each press.
> >
> > Emacs (in Gui mode) handles these keys in an interesting fashion -
> > at least interesting to me.
> >
> > On emacs, these three keys produce digit prefixes: 40, 41 and 60
> > respectively.
> 
> My crystal ball says they imitate the Windows way of entering
> characters by code where you turn on Num Lock, hold down Alt, then
> enter the character code on the numeric keypad and finally release
> Alt.
  Pretty much, yes. 

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



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

end of thread, other threads:[~2016-09-29 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29  0:11 Keystrokes sending digit prefixes Tim Johnson
2016-09-29  5:49 ` Yuri Khan
2016-09-29 15:11   ` Tim Johnson

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.