From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tim Johnson Newsgroups: gmane.emacs.help Subject: Keystrokes sending digit prefixes Date: Wed, 28 Sep 2016 16:11:28 -0800 Organization: AkWebsoft Message-ID: <20160929001128.GA2607@mail.akwebsoft.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1475107938 7912 195.159.176.226 (29 Sep 2016 00:12:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 29 Sep 2016 00:12:18 +0000 (UTC) User-Agent: Mutt/1.7.0 (2016-08-17) To: Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 29 02:12:13 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpOxK-0000X0-Vd for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Sep 2016 02:12:07 +0200 Original-Received: from localhost ([::1]:33916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpOxH-0000SS-Pz for geh-help-gnu-emacs@m.gmane.org; Wed, 28 Sep 2016 20:12:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpOwr-0000RW-Ex for Help-gnu-emacs@gnu.org; Wed, 28 Sep 2016 20:11:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpOwn-0001c0-U4 for Help-gnu-emacs@gnu.org; Wed, 28 Sep 2016 20:11:37 -0400 Original-Received: from tjohnson.mtaonline.net ([64.4.232.191]:38512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpOwn-0001bM-Kj for Help-gnu-emacs@gnu.org; Wed, 28 Sep 2016 20:11:33 -0400 Original-Received: by linus.johnson.com (Postfix, from userid 1000) id 2A23D200536; Wed, 28 Sep 2016 16:11:28 -0800 (AKDT) Mail-Followup-To: Emacs Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.4.232.191 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111416 Archived-At: 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