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 18:05:40 +0000	[thread overview]
Message-ID: <0FFA3486-2A4A-4F10-8564-A9C5E176A756@gmail.com> (raw)
In-Reply-To: <A4609C86-0DD2-4532-ACDC-93EFCF123CDD@math.ethz.ch>

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 
	(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:

> 
> On 2011-11-09, at 18:38 , Jonathan Oddie wrote:
> 
>> 
>> Hi Marius,
>> 
>>> 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.
>> 
>> 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.
> 
> okay
> 
>> 
>>> [snip]
>> 
>>> 
>>> => 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?
>> 
>> 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:
>> 
>> (add-to-list 'exec-path "/some/path/here")
>> 
>> 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.
>> 
>> 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 ;-)
>> 
>> cheers,
>> Jonathan
> 
> 
> Okay, in the meantime, I tried something like:
> (setq exec-path (getenv "PATH"))
> but that of course failed.
> 
> 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 :-(
> 
> 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)
> 
> I'll try what you suggested in your recent mail, soon.
> 
> 
> 




  reply	other threads:[~2011-11-09 18:05 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 [this message]
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
     [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=0FFA3486-2A4A-4F10-8564-A9C5E176A756@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.