Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!border2.nntp.ams1.giganews.com!nntp.giganews.com!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'configure': 0.04; 'bytes.': 0.07; 'clause': 0.07; 'subject:both': 0.07; 'subject:same': 0.07; 'issue?': 0.09; 'tab': 0.09; 'cc:addr :python-list': 0.10; 'python': 0.11; 'obviously': 0.15; '>on': 0.16; '\\n\\': 0.16; 'answers:': 0.16; 'backspace': 0.16; 'bindings.': 0.16; 'commented': 0.16; 'consulted': 0.16; 'emulator': 0.16; 'experiments': 0.16; 'file;': 0.16; 'frankly': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'old-style': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'sequence.': 0.16; 'simpson': 0.16; 'threw': 0.16; 'using,': 0.16; 'wrote:': 0.16; 'config': 0.18; 'skip:i 40': 0.18; 'gui': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; '(the': 0.22; 'am,': 0.23; 'code.': 0.23; 'decide': 0.23; '2015': 0.23; 'this:': 0.23; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'example': 0.25; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'wonder': 0.27; 'defining': 0.27; 'issue,': 0.27; 'subject: -- ': 0.27; 'rest': 0.28; 'behaviour': 0.29; 'readline': 0.29; "we're": 0.30; 'subject:time': 0.31; 'anyone': 0.32; 'probably': 0.32; 'possibly': 0.32; 'problem': 0.33; "d'aprano": 0.33; 'done,': 0.33; 'received:com.au': 0.33; 'shift': 0.33; 'steven': 0.33; '(for': 0.34; 'definition': 0.34; 'subject:?': 0.34; 'this?': 0.34; 'previous': 0.34; 'could': 0.35; 'next': 0.35; 'configured': 0.35; 'there': 0.36; '(and': 0.36; 'subject:: ': 0.37; 'charset :us-ascii': 0.37; 'instead': 0.38; 'stuff': 0.38; 'express': 0.38; 'end': 0.39; 'expect': 0.39; 'system.': 0.39; 'subject:-': 0.39; 'subject:the': 0.40; 'yes': 0.60; 'content-disposition:inline': 0.60; 'your': 0.60; 'back': 0.61; "you'll": 0.61; 'per': 0.61; 'leading': 0.62; 'different': 0.64; 'cameron': 0.66; 'hour': 0.69; '3.6': 0.84; '4:55': 0.84; 'distinguish': 0.84; 'fire!': 0.84; 'replicate': 0.84; 'want:': 0.84 Date: Tue, 30 Jun 2015 10:25:05 +1000 From: Cameron Simpson To: Chris Angelico Cc: "python-list@python.org" Subject: Re: Readline -- cannot bind to both Ctrl-tab and tab at the same time? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=ItbjC+Lg c=1 sm=1 tr=0 a=rgDbx50tNA2z7xLXQOoruw==:117 a=rgDbx50tNA2z7xLXQOoruw==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=vrnE16BAAAAA:8 a=yEdEr6MRgwAA:10 a=kj9zAlcOel0A:10 a=XAFQembCKUMA:10 a=pGLkceISAAAA:8 a=kZ7UWmmPAAAA:8 a=uPZiAMpXAAAA:8 a=FC8VUaWo9L2TS08yamcA:9 a=CjuIK1q_8ugA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 83 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435623926 news.xs4all.nl 2944 [2001:888:2000:d::a6]:51473 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 8147 X-Received-Body-CRC: 1206137745 Xref: csiph.com comp.lang.python:93303 On 29Jun2015 11:36, Chris Angelico wrote: >On Mon, Jun 29, 2015 at 4:55 AM, Steven D'Aprano wrote: >> Try Ctrl-TAB again, and you'll get "raise" instead of "import". >> >> Can anyone else replicate this issue? >> >> Is this a Python issue, a problem with the terminal I am using, or readline >> in general? > >Confirmed with Python 3.6 on Debian Jessie. Delving into Laura's >suggestion that it's a readline problem, I came across this: > >http://stackoverflow.com/questions/12044574/getting-complete-and-menu-complete-to-work-together > >Testing with "showkey -a" suggests that tab and ctrl-tab indeed send >the same bytes. I wonder if there's a way to change terminal type or >fiddle with terminfo to change this? GUI programs obviously don't have >this conflation. Yes, this was my surmise (and expectation, frankly - what did you expect ctrl-TAB to send?) So there is no way for the program in the terminal to distinguish one from the other; you will always only get one of your bindings. I would not expect terminfo to get you anything on its own - it is consulted by the receiving program. The sending program (the terminal emulator) needs to be configured to send different sequences for TAB and ctrl-TAB. Once that is done, _then_ you may be able to augument your terminfo to express this behaviour and have readline honour the change. 1: Work backward from the readline internals to find out if it consults a terminfo property to find out what ctrl-TAB might be. 2: Decide on what you want ctrl-TAB to send instead of the TAB code. 3: Make a new terminfo clause defining that (for readline's use) and hooking onto your old terminfo definition for the rest (tc=other_terminal in termcap, possibly the same in terminfo). 4: Configure your terminal emulator to send that sequence. Regarding 4, with proper old-style X11 terminals you could control all this directly with the VT100.Translations properties. Example from my xterm Xdefaults file; the leading F1 definition is probably what you want: XTerm*.VT100.Translations: #override \n\ F1 : string(0x1b) \n \ F10 : secure() \n \ KP_End : scroll-forw(100,page) \n \ KP_Prior : scroll-back(1,halfpage) \n \ KP_Next : scroll-forw(1,halfpage) \n\ End : scroll-forw(100,page) \n \ CtrlUp : scroll-back(1,line) \n \ CtrlDown : scroll-forw(1,line) \n\ Prior : scroll-back(1,halfpage) \n \ Next : scroll-forw(1,halfpage) \n\ Meta : string(0x1b) insert() \n\ Alt : string(0x1b) insert() \n\ BackSpace : string(0x08) \n \ Shift : ignore() \n\ Shift : insert-selection(PRIMARY,CUT_BUFFER0)\n\ : ignore() \n\ : insert-selection(PRIMARY,CUT_BUFFER0)\n\ Shift : ignore() \n\ Shift : string("us ") insert-selection(PRIMARY,CUT_BUFFER0) string("\n") \n\ ~Ctrl ~Meta : ignore()\n\ ~Ctrl ~Meta : ignore()\n ! commented out, previous experiments ! XTerm*VT100.translations: #override Shift'F1':insert("hi guys") ! XTerm*VT100.translations: #override Ctrl'U':uphalfscreen()\nCtrl'D'downhalfscreen() The new fangled terminals like gnome-terminal or Konsole probably threw that stuff out as they threw out all the other normal X11 config hooks, and doubtless use their own arcane system. Enjoy. Cheers, Cameron Simpson The top three answers: Yes I *am* going to a fire! Oh! We're using *kilometers* per hour now. I have to go that fast to get back to my own time. - Peter Harper