From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@newcastle.ac.uk (Phillip Lord) Newsgroups: gmane.emacs.help Subject: Re: Key-binding without minor mode! Date: Fri, 12 Sep 2014 10:50:59 +0100 Message-ID: <877g19xj3w.fsf@newcastle.ac.uk> References: <87mwa6crac.fsf@newcastle.ac.uk> <87wq9ab5k8.fsf@newcastle.ac.uk> <87sijyb43f.fsf@newcastle.ac.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1410515786 31119 80.91.229.3 (12 Sep 2014 09:56:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Sep 2014 09:56:26 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 12 11:56:19 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XSNaS-0007sT-EK for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Sep 2014 11:56:16 +0200 Original-Received: from localhost ([::1]:43836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSNaS-0002aT-59 for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Sep 2014 05:56:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSNVS-0002pO-Vt for help-gnu-emacs@gnu.org; Fri, 12 Sep 2014 05:51:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSNVO-0007e4-65 for help-gnu-emacs@gnu.org; Fri, 12 Sep 2014 05:51:06 -0400 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:60268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSNVN-0007dy-WA for help-gnu-emacs@gnu.org; Fri, 12 Sep 2014 05:51:02 -0400 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1XSNVM-0000aS-DB; Fri, 12 Sep 2014 10:51:00 +0100 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1XSNVL-0008FM-Nc; Fri, 12 Sep 2014 10:50:59 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 11 Sep 2014 14:46:31 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.22 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:99851 Archived-At: Stefan Monnier writes: >> But if the major-mode defines binds to [tab] then it will override the >> minor mode. > > Indeed. It might be a bug in the major-mode, tho (which manifests > for example under ttys where the TAB key sends a \t rather than a `tab'). Oh, dear, yes. So binding to [tab] in my minor mode is a mistake. I need to bind to both \t and [tab]. If I bind to just \t then a major mode can override this by binding [tab]. If I bind, though, to just [tab] then I have no binding in tty. > >> I think I have no choice but to handle tab explicitly. Is [tab] the only >> key that works like this? > > No. What you're trying to do is inherently tricky/fiddly/unreliable > because Emacs's key-binding infrastructure is not designed for that. > Yep. I've ended up with this. I've had to do something similar for return which does the same thing. (defun pabbrev-get-previous-binding () "Show the binding of tab if pabbrev were not active. The command `pabbrev-show-previous-binding' prints this out." (let ((pabbrev-mode nil)) (let ((tckv (if pabbrev-xemacs-p (this-command-keys) (this-command-keys-vector)))) (cond ((or (equal tckv [tab]) (equal tckv [9])) (or (key-binding [tab]) (key-binding "\t"))) ((or (equal tckv [return]) (equal tckv [32])) (or (key-binding [return]) (key-binding "\n"))) (t (key-binding tckv)))))) > You might want to report a bug asking for some feature that lets you do > what you want (which I suspect is something like "let my command > delegate to the next command bound to this key"). Will do! Phil