From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marius Hofert Newsgroups: gmane.emacs.help Subject: Re: Why is TAB-completion in shell not working for some commands? Date: Wed, 9 Nov 2011 22:19:30 +0100 Message-ID: References: <8BF2824B-97AC-4722-8F2C-C572C5F558FF@gmail.com> <1E4EE682-3100-41C9-A4C5-1E537BF01647@math.ethz.ch> <1979BC10-E138-4B26-83BD-CBBBEC6F09CC@gmail.com> <0FFA3486-2A4A-4F10-8564-A9C5E176A756@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1320873587 21668 80.91.229.12 (9 Nov 2011 21:19:47 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Nov 2011 21:19:47 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Jonathan Oddie Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 09 22:19:43 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ROFYb-0000YV-Py for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 22:19:42 +0100 Original-Received: from localhost ([::1]:43128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROFYb-00082f-4v for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 16:19:41 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:55597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROFYW-00082P-LI for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 16:19:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROFYV-0001Fl-7Z for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 16:19:36 -0500 Original-Received: from edge20.ethz.ch ([82.130.99.26]:13974) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROFYU-0001FW-QI for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 16:19:35 -0500 Original-Received: from CAS11.d.ethz.ch (172.31.38.211) by edge20.ethz.ch (82.130.99.26) with Microsoft SMTP Server (TLS) id 14.1.339.1; Wed, 9 Nov 2011 22:19:30 +0100 Original-Received: from 77-58-145-155.dclient.hispeed.ch (77.58.145.155) by CAS11.d.ethz.ch (172.31.38.211) with Microsoft SMTP Server (TLS) id 14.1.339.1; Wed, 9 Nov 2011 22:19:31 +0100 In-Reply-To: <0FFA3486-2A4A-4F10-8564-A9C5E176A756@gmail.com> X-Mailer: Apple Mail (2.1251.1) X-Originating-IP: [77.58.145.155] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.130.99.26 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:82836 Archived-At: Dear Jonathan, thank you very much, it works *perfectly*!!! I have the same PATH *and* a2ps is properly TAB-completed. *Brilliant* :-) Cheers, Marius On 2011-11-09, at 19:05 , Jonathan Oddie wrote: > Hi Marius, >=20 > I did a couple of experiments and I think the below works better than > my previous code: >=20 > (let ((path (shell-command-to-string ". ~/.profile; echo -n $PATH"))) > (setenv "PATH" path) > (setq exec-path=20 > (append > (split-string-and-unquote path ":") > exec-path))) >=20 > This makes sure to read your bash startup before echoing the PATH env > variable; I hadn't thought of that before. >=20 > Also, I'm pretty sure now it really is `exec-path' that makes the > difference, not the PATH environment variable itself. Here's the > docstring for `shell-dynamic-complete-command': >=20 >> This function is similar to `comint-dynamic-complete-filename', = except that it >> searches `exec-path' (minus the trailing Emacs library path) for = completion >> candidates. Note that this may not be the same as the shell's idea = of the >> path. >=20 > So as long as `exec-path' gets set correctly it *ought* to work. Let > me know if that helps, I think we must be close to the solution now! >=20 > cheers, > Jonathan >=20 >=20 >=20 > On 9 Nov 2011, at 17:51, Marius Hofert wrote: >=20 >>=20 >> On 2011-11-09, at 18:38 , Jonathan Oddie wrote: >>=20 >>>=20 >>> Hi Marius, >>>=20 >>>> 1) If I start emacs from the terminal, TAB-completion works (as = reported earlier). Now the emacs I start from the terminal is actally = (output of "which emacs"): >>>> /Applications/Emacs.app/Contents/MacOS//emacs >>>> and not the /Applications/Emacs.app (the GUI version one clicks on = in the dock). So when I started emacs from the terminal, I used Options = -> Keep in Dock to keep that in the dock instead of = /Applications/Emacs.app. Starting the former, I again did not have = TAB-completion, so it only works when (really) starting emacs from the = terminal (which is funny cause I thought I can get rid of the Mac's = terminal since I have a shell in emacs...) >>>> Don't know if that makes sense to the experts, I just wanted to = report on this. >>>=20 >>> Those two are actually the same >>> thing. /Applications/Emacs.app/Contents/MacOS/emacs is just the >>> executable file hidden inside the Emacs.app bundle. So it really = does >>> depend on starting from the Terminal and picking up your PATH >>> settings. >>=20 >> okay >>=20 >>>=20 >>>> [snip] >>>=20 >>>>=20 >>>> =3D> Clearly, the /opt-directories are missing. I haven't tried but = one might just add all directories from PATH to exec-path, but whenever = I change PATH, I have to remember to do the same for exec-path. Is there = a nicer way? >>>=20 >>> Yes, I'd try adding your /opt directories to `exec-path' first and = see if that fixes >>> the problem. You can either something like the (setq exec-path = (append ... )) solution in my last email, or the following: >>>=20 >>> (add-to-list 'exec-path "/some/path/here") >>>=20 >>> Note that you might *also* need to set the environment PATH variable >>> from within Emacs; that's the line with `mapconcat' in my prev >>> email. As I said, I forget exactly how each of these things = interacts >>> with shell-mode's tab-completion. >>>=20 >>> If that works, the nicer solution would probably involve having your >>> .emacs run a short shell script to print out and parse the value of >>> PATH set in your .bashrc (or wherever), and set PATH and `exec-path' >>> based on that. I'll try and work out a quick hack for this later = this >>> evening, if someone doesn't beat me to it ;-) >>>=20 >>> cheers, >>> Jonathan >>=20 >>=20 >> Okay, in the meantime, I tried something like: >> (setq exec-path (getenv "PATH")) >> but that of course failed. >>=20 >> I then put in: >> (setq exec-path (append exec-path '("/opt/local/bin"))); set = exec-path >> (setenv "PATH" (mapconcat 'identity exec-path ":")); set PATH >> and restarted emacs. Still no TAB-completion :-( >>=20 >> If that helps, I originally had the following to get the same PATH as = in the terminal: >> (setq explicit-bash-args (list "--login" "-i")) >> (that with the seq exec-path command above also did not work, though) >>=20 >> I'll try what you suggested in your recent mail, soon. >>=20 >>=20 >>=20 >=20