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 17:46:46 +0000 Message-ID: <339B0948-7579-4391-950F-CF33FC6CEBA6@gmail.com> References: <8BF2824B-97AC-4722-8F2C-C572C5F558FF@gmail.com> <1E4EE682-3100-41C9-A4C5-1E537BF01647@math.ethz.ch> 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 1320860823 20517 80.91.229.12 (9 Nov 2011 17:47:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Nov 2011 17:47:03 +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 18:46:59 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 1ROCEk-0004qE-KI for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 18:46:58 +0100 Original-Received: from localhost ([::1]:39758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROCEk-00069h-0c for geh-help-gnu-emacs@m.gmane.org; Wed, 09 Nov 2011 12:46:58 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:46823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROCEe-00069c-Vo for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 12:46:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROCEd-0001bY-NR for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 12:46:52 -0500 Original-Received: from mail-ey0-f169.google.com ([209.85.215.169]:61443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROCEd-0001bI-GA for help-gnu-emacs@gnu.org; Wed, 09 Nov 2011 12:46:51 -0500 Original-Received: by eye4 with SMTP id 4so1921819eye.0 for ; Wed, 09 Nov 2011 09:46:50 -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=gjwVzpozbwgWTjRZ4xBfOW4CRzAxELGW3uyC5hANcGs=; b=MQkY+2dyu18yZS63YZSVb43vXYkKMhHa9I4Bm99dM9LyRuqNc8exjxgfdr6opP3U+B 3Dx4wmPneeSyvGdD2cPx5GEYaGOS+TVRYiENGh9WpBdHahcuRgpfIX7aU87z84G47F0K xNvOu6XA95Bl76+6D0RZG+iV0rpXqjKbXGfko= Original-Received: by 10.180.103.170 with SMTP id fx10mr3875144wib.56.1320860810468; Wed, 09 Nov 2011 09:46:50 -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 m7sm3317050wiz.6.2011.11.09.09.46.47 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Nov 2011 09:46:48 -0800 (PST) In-Reply-To: <1E4EE682-3100-41C9-A4C5-1E537BF01647@math.ethz.ch> X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.215.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:82826 Archived-At: That took less time than I thought it might. See if this helps you: (let ((path (shell-command-to-string "echo $PATH"))) (setenv "PATH" path) (setq exec-path (append (split-string-and-unquote path ":") exec-path))) (In case you're not used to evaluating bits of Lisp code in Emacs: paste that into your *scratch* buffer, put point somewhere in the middle and type C-M-x or M-x eval-defun) You would have to kill any existing shell-mode buffers and start over for this to do anything, I think. Does that fix it? cheers, Jonathan On 9 Nov 2011, at 17:28, Marius Hofert wrote: >=20 >> 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 ":")) >=20 > I just tried out something: >=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 > 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. >=20 > 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") >=20 > 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") >=20 >=20 > This variable is potentially risky when used as a file local = variable. >=20 > Documentation: > *List of directories to search programs to run in subprocesses. > Each element is a string (directory name) or nil (try default = directory). >=20 > You can customize this variable. >=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 > Cheers, >=20 > Marius >=20 >=20