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 18:28:23 +0100 Message-ID: <1E4EE682-3100-41C9-A4C5-1E537BF01647@math.ethz.ch> References: <8BF2824B-97AC-4722-8F2C-C572C5F558FF@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 1320859726 11806 80.91.229.12 (9 Nov 2011 17:28:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Nov 2011 17:28:46 +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 18:28:39 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 1ROBx0-0004HC-Ui for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 18:28:39 +0100 Original-Received: from localhost ([::1]:36410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROBx0-0004f9-58 for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 12:28:38 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:38643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROBws-0004ep-Tu for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 12:28:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROBwp-00064b-08 for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 12:28:30 -0500 Original-Received: from edge20.ethz.ch ([82.130.99.26]:25380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROBwo-00064A-NE for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 12:28:26 -0500 Original-Received: from CAS10.d.ethz.ch (172.31.38.210) by edge20.ethz.ch (82.130.99.26) with Microsoft SMTP Server (TLS) id 14.1.339.1; Wed, 9 Nov 2011 18:28:23 +0100 Original-Received: from 77-58-145-155.dclient.hispeed.ch (77.58.145.155) by cas10.d.ethz.ch (172.31.38.210) with Microsoft SMTP Server (TLS) id 14.1.339.1; Wed, 9 Nov 2011 18:28:23 +0100 In-Reply-To: <8BF2824B-97AC-4722-8F2C-C572C5F558FF@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:82823 Archived-At: > This rang a bell for me. When launching anything from the Finder the > PATH is not set correctly (since the Finder is not itself run from > your shell). I am a bit fuzzy now on the details of how `exec-path', > the PATH variable and tab-completion in shell-mode interact, but I > would suggest putting something in your .emacs or init.el file that > (1) sets the emacs variable `exec-path' to the sequence of directories > you expect to find in PATH, and (2) sets the environment variable PATH > based on that. Here's what I have, just as an example: >=20 > ;; Exec-path and env variable > (setq exec-path > (append '("/opt/local/bin" "/opt/local/sbin" = "/opt/local/libexec/gnubin/" > "/usr/local/mysql/bin/" "/usr/local/share/rhino" = "~/bin") > exec-path > '("/Applications/LilyPond.app/Contents/Resources/bin/" > "/Applications/Racket v5.1.3/bin/"))) >=20 > (setenv "PATH" (mapconcat 'identity exec-path ":")) I just tried out something: 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. 2) Jonathan, your hint led me to a search which brought up this: = http://stackoverflow.com/questions/930439/using-git-with-emacs So that seems to be related to the fact that emacs started from the dock = does not get the same initialization as emacs started from the terminal = (the latter having environment variables set up correctly). The only = thing I'm wondering about is, if I set up the path to a2ps in .emacs and = it finally works, what about all other not TAB-completed commands? What = is a *general* solution to this problem (not depending on adding = specific paths)? The bottom line is: I want to have exactly the same = behavior for the emacs started from the dock as from the one started = from the terminal. 3) There's a hint on the bottom of the above linked page. I executed C-h = v exec-path and obtained: exec-path is a variable defined in `C source code'. Its value is ("/usr/bin" "/bin" "/usr/sbin" "/sbin" "/usr/local/bin" "/usr/X11/bin" = "/usr/texbin" "/Applications/Emacs.app/Contents/MacOS/bin") Original value was=20 ("/usr/bin" "/bin" "/usr/sbin" "/sbin" "/usr/local/bin" "/usr/X11/bin" = "/Users/david/src/emacs-dev/ftp-versions/emacs-24.0.91/lib-src" = "/Users/david/src/emacs-dev/ftp-versions/emacs-24.0.91/nextstep/Emacs.app/= Contents/MacOS//libexec/emacs/24.0.91/x86_64-apple-darwin") This variable is potentially risky when used as a file local variable. Documentation: *List of directories to search programs to run in subprocesses. Each element is a string (directory name) or nil (try default = directory). You can customize this variable. =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? Cheers, Marius