From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jonathan Oddie Newsgroups: gmane.emacs.help Subject: Re: Why is TAB-completion in shell not working for some commands? Date: Wed, 9 Nov 2011 18:05:40 +0000 Message-ID: <0FFA3486-2A4A-4F10-8564-A9C5E176A756@gmail.com> References: <8BF2824B-97AC-4722-8F2C-C572C5F558FF@gmail.com> <1E4EE682-3100-41C9-A4C5-1E537BF01647@math.ethz.ch> <1979BC10-E138-4B26-83BD-CBBBEC6F09CC@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1320861961 29160 80.91.229.12 (9 Nov 2011 18:06:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Nov 2011 18:06:01 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Marius Hofert Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 09 19:05:58 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 1ROCX6-0006bz-Nn for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 19:05:56 +0100 Original-Received: from localhost ([::1]:52681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROCX6-0002eX-4R for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 13:05:56 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:35908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROCX1-0002eQ-5M for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 13:05:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROCWv-0005rG-7j for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 13:05:51 -0500 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:41814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROCWu-0005r3-RT for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 13:05:45 -0500 Original-Received: by wyg24 with SMTP id 24so2280676wyg.0 for ; Wed, 09 Nov 2011 10:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=iYWg3o1gfI+J5X12iyHK4A0qKDMi8Xahi9aF7SPOAJM=; b=BbGrRenoKJ2FqYESTct6mRUoA8Ag7gvQ2+1T9TTK4hwNyYCUGoHfNjiaVIL+yQ6+NI 566Jnu3zik/vhatTcUcx0eyC/YV9FDch12YriUE2d80gS1iLObxP9BXBA/Im47aM5+FX YY6BiT6VBmjalakCejVvSyCR5Yf5XGr08tHTA= Original-Received: by 10.181.13.82 with SMTP id ew18mr4086375wid.16.1320861943984; Wed, 09 Nov 2011 10:05:43 -0800 (PST) Original-Received: from stu-40-200.magd.ox.ac.uk (stu-40-200.magd.ox.ac.uk. [129.67.40.200]) by mx.google.com with ESMTPS id x8sm3345203wix.17.2011.11.09.10.05.41 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Nov 2011 10:05:42 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.169 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:82829 Archived-At: Hi Marius, I did a couple of experiments and I think the below works better than my previous code: (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))) This makes sure to read your bash startup before echoing the PATH env variable; I hadn't thought of that before. 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': > 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. 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! cheers, Jonathan On 9 Nov 2011, at 17:51, Marius Hofert wrote: >=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