all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jonathan Oddie <j.j.oddie@gmail.com>
To: Marius Hofert <marius.hofert@math.ethz.ch>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Why is TAB-completion in shell not working for some 	commands?
Date: Wed, 9 Nov 2011 17:46:46 +0000	[thread overview]
Message-ID: <339B0948-7579-4391-950F-CF33FC6CEBA6@gmail.com> (raw)
In-Reply-To: <1E4EE682-3100-41C9-A4C5-1E537BF01647@math.ethz.ch>

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:

> 
>> 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:
>> 
>> ;; 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/")))
>> 
>> (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 
> ("/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.
> 
> => 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
> 
> 




  parent reply	other threads:[~2011-11-09 17:46 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2976.1320857313.797.help-gnu-emacs@gnu.org>
2011-11-09 17:06 ` Why is TAB-completion in shell not working for some commands? Jonathan Oddie
2011-11-09 17:28   ` Marius Hofert
2011-11-09 17:38     ` Jonathan Oddie
2011-11-09 17:51       ` Marius Hofert
2011-11-09 18:05         ` Jonathan Oddie
2011-11-09 18:49           ` Jonathan Oddie
2011-11-09 18:52             ` Jonathan Oddie
2011-11-09 21:19           ` Marius Hofert
2011-11-09 17:46     ` Jonathan Oddie [this message]
     [not found] <mailman.9.1320780886.798.help-gnu-emacs@gnu.org>
2011-11-09  1:34 ` Stefan Monnier
2011-11-08 19:34 Marius Hofert
2011-11-09  6:43 ` Andreas Röhler
2011-11-09  6:48   ` Marius Hofert
2011-11-09  6:53     ` Andreas Röhler
2011-11-09  6:56       ` Marius Hofert
2011-11-09  7:09         ` Andreas Röhler
2011-11-09  7:13           ` Marius Hofert
2011-11-09  7:26             ` Andreas Röhler
2011-11-09  7:45               ` Marius Hofert
2011-11-09  7:54                 ` Marius Hofert
2011-11-09  8:29                   ` Andreas Röhler
2011-11-09  8:34                     ` Marius Hofert
2011-11-09  8:41                       ` Andreas Röhler
2011-11-09  8:59                         ` Marius Hofert
2011-11-09  9:05                           ` Marius Hofert
2011-11-11  3:03                             ` Kevin Rodgers
2011-11-09  9:23                           ` Andreas Röhler
2011-11-09 11:10                             ` Marius Hofert
2011-11-09 13:29                               ` Andreas Röhler
2011-11-09 15:28                   ` PJ Weisberg
2011-11-09 17:02                     ` Marius Hofert
2011-11-09  6:56       ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=339B0948-7579-4391-950F-CF33FC6CEBA6@gmail.com \
    --to=j.j.oddie@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=marius.hofert@math.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.