all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Why is TAB-completion in shell not working for some commands?
@ 2011-11-08 19:34 Marius Hofert
  2011-11-09  6:43 ` Andreas Röhler
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-08 19:34 UTC (permalink / raw)
  To: Emacs help

Hi,

I have a strange problem with OS: Mac OS X 10.7.2 and Emacs: GNU Emacs 24.0.91.1.

If I open a shell with M-x shell, I can TAB-complete several commands, such as ps2pdf and many others. However, I can't seem to TAB-complete all commands. One exception is a2ps. I installed it, it works perfectly fine, I can TAB-complete it from the Mac's terminal, however, I can't TAB-complete it from the shell opened with M-x shell. The simple question is: Why?

Note that if I type "echo $PATH", I get:
a) from the Mac's terminal: 
/Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin
b) from the emacs shell: 
/Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin
=> exactly the same. 

If I type "which a2ps" from the emacs shell, I get: /opt/local/bin/a2ps so the correct place is found, but why is there no TAB-completion?

Cheers,

Marius




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
       [not found] <mailman.9.1320780886.798.help-gnu-emacs@gnu.org>
@ 2011-11-09  1:34 ` Stefan Monnier
  0 siblings, 0 replies; 32+ messages in thread
From: Stefan Monnier @ 2011-11-09  1:34 UTC (permalink / raw)
  To: help-gnu-emacs

> If I type "which a2ps" from the emacs shell, I get: /opt/local/bin/a2ps so
> the correct place is found, but why is there no TAB-completion?

Probably because you set $PATH from your shell initialization files, but
those aren't run before running Emacs.  So the $PATH that your shell
uses is different from the one Emacs uses (and the tab completion in
M-x shell is performed by Emacs, not by the shell).


        Stefan


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-08 19:34 Marius Hofert
@ 2011-11-09  6:43 ` Andreas Röhler
  2011-11-09  6:48   ` Marius Hofert
  0 siblings, 1 reply; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  6:43 UTC (permalink / raw)
  To: help-gnu-emacs

Am 08.11.2011 20:34, schrieb Marius Hofert:
> Hi,
>
> I have a strange problem with OS: Mac OS X 10.7.2 and Emacs: GNU Emacs 24.0.91.1.
>
> If I open a shell with M-x shell, I can TAB-complete several commands, such as ps2pdf and many others. However, I can't seem to TAB-complete all commands. One exception is a2ps. I installed it, it works perfectly fine, I can TAB-complete it from the Mac's terminal, however, I can't TAB-complete it from the shell opened with M-x shell. The simple question is: Why?
>
> Note that if I type "echo $PATH", I get:
> a) from the Mac's terminal:
> /Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin
> b) from the emacs shell:
> /Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin
> =>  exactly the same.
>
> If I type "which a2ps" from the emacs shell, I get: /opt/local/bin/a2ps so the correct place is found, but why is there no TAB-completion?
>
> Cheers,
>
> Marius
>
>
>

AFAIU it might matter, wherefrom you open the shell. It may or will have 
it's own (minor-)mode, where TAB completion is provided or not. In 
different available python-shells for example, TAB completion might be 
performed by different functions.

Call M-x describe-mode from inside shell, to get info which mode is 
behind, which keys are set etc,

Cheers,

Andreas







^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  6:43 ` Andreas Röhler
@ 2011-11-09  6:48   ` Marius Hofert
  2011-11-09  6:53     ` Andreas Röhler
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  6:48 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

> AFAIU it might matter, wherefrom you open the shell. It may or will have it's own (minor-)mode, where TAB completion is provided or not. In different available python-shells for example, TAB completion might be performed by different functions.
> 
> Call M-x describe-mode from inside shell, to get info which mode is behind, which keys are set etc,
> 
> Cheers,
> 
> Andreas

Hi Andreas,

thanks a lot for helping. Here is the output of M-x describe-mode:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption Autopair
Autopair-Global Blink-Cursor Column-Number Delete-Selection Desktop-Save
Diff-Auto-Refine File-Name-Shadow Font-Lock Global-Font-Lock Global-Visual-Line
Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack Show-Paren Tooltip
Transient-Mark Visual-Line Yas/Global

Cheers,

Marius


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  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  6:56       ` Andreas Röhler
  0 siblings, 2 replies; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  6:53 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 07:48, schrieb Marius Hofert:
>> AFAIU it might matter, wherefrom you open the shell. It may or will have it's own (minor-)mode, where TAB completion is provided or not. In different available python-shells for example, TAB completion might be performed by different functions.
>>
>> Call M-x describe-mode from inside shell, to get info which mode is behind, which keys are set etc,
>>
>> Cheers,
>>
>> Andreas
>
> Hi Andreas,
>
> thanks a lot for helping. Here is the output of M-x describe-mode:
>
> Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption Autopair
> Autopair-Global Blink-Cursor Column-Number Delete-Selection Desktop-Save
> Diff-Auto-Refine File-Name-Shadow Font-Lock Global-Font-Lock Global-Visual-Line
> Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack Show-Paren Tooltip
> Transient-Mark Visual-Line Yas/Global
>
> Cheers,
>
> Marius

what says M-s describe-key TAB




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  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  6:56       ` Andreas Röhler
  1 sibling, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  6:56 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

Do you mean M-x describe-key TAB? It says:

Click <mouse-2> on a completion to select it.
In this buffer, type M-x choose-completion to select the completion near point.

Possible completions are:
describe-key
describe-key-briefly

On 2011-11-09, at 07:53 , Andreas Röhler wrote:

> Am 09.11.2011 07:48, schrieb Marius Hofert:
>>> AFAIU it might matter, wherefrom you open the shell. It may or will have it's own (minor-)mode, where TAB completion is provided or not. In different available python-shells for example, TAB completion might be performed by different functions.
>>> 
>>> Call M-x describe-mode from inside shell, to get info which mode is behind, which keys are set etc,
>>> 
>>> Cheers,
>>> 
>>> Andreas
>> 
>> Hi Andreas,
>> 
>> thanks a lot for helping. Here is the output of M-x describe-mode:
>> 
>> Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption Autopair
>> Autopair-Global Blink-Cursor Column-Number Delete-Selection Desktop-Save
>> Diff-Auto-Refine File-Name-Shadow Font-Lock Global-Font-Lock Global-Visual-Line
>> Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack Show-Paren Tooltip
>> Transient-Mark Visual-Line Yas/Global
>> 
>> Cheers,
>> 
>> Marius
> 
> what says M-s describe-key TAB
> 





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  6:53     ` Andreas Röhler
  2011-11-09  6:56       ` Marius Hofert
@ 2011-11-09  6:56       ` Andreas Röhler
  1 sibling, 0 replies; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  6:56 UTC (permalink / raw)
  To: help-gnu-emacs

Am 09.11.2011 07:53, schrieb Andreas Röhler:
> Am 09.11.2011 07:48, schrieb Marius Hofert:
>>> AFAIU it might matter, wherefrom you open the shell. It may or will
>>> have it's own (minor-)mode, where TAB completion is provided or not.
>>> In different available python-shells for example, TAB completion
>>> might be performed by different functions.
>>>
>>> Call M-x describe-mode from inside shell, to get info which mode is
>>> behind, which keys are set etc,
>>>
>>> Cheers,
>>>
>>> Andreas
>>
>> Hi Andreas,
>>
>> thanks a lot for helping. Here is the output of M-x describe-mode:
>>
>> Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
>> Autopair
>> Autopair-Global Blink-Cursor Column-Number Delete-Selection Desktop-Save
>> Diff-Auto-Refine File-Name-Shadow Font-Lock Global-Font-Lock
>> Global-Visual-Line
>> Line-Number Menu-Bar Mouse-Wheel Shell-Dirtrack Show-Paren Tooltip
>> Transient-Mark Visual-Line Yas/Global
>>
>> Cheers,
>>
>> Marius
>
> what says M-s describe-key TAB
>
>
>

typo, right is:

M-x describe-key TAB



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  6:56       ` Marius Hofert
@ 2011-11-09  7:09         ` Andreas Röhler
  2011-11-09  7:13           ` Marius Hofert
  0 siblings, 1 reply; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  7:09 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 07:56, schrieb Marius Hofert:
> Do you mean M-x describe-key TAB? It says:
>

Sorry, mean

M-x describe-key RET TAB




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  7:09         ` Andreas Röhler
@ 2011-11-09  7:13           ` Marius Hofert
  2011-11-09  7:26             ` Andreas Röhler
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  7:13 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

Ahh, okay :-) Here's the output:

TAB (translated from <tab>) runs the command completion-at-point, which is an
interactive compiled Lisp function in `minibuffer.el'.

It is bound to TAB, <menu-bar> <completion> <complete>.

(completion-at-point)

Perform completion on the text around point.
The completion method is determined by `completion-at-point-functions'.


On 2011-11-09, at 08:09 , Andreas Röhler wrote:

> Am 09.11.2011 07:56, schrieb Marius Hofert:
>> Do you mean M-x describe-key TAB? It says:
>> 
> 
> Sorry, mean
> 
> M-x describe-key RET TAB
> 




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  7:13           ` Marius Hofert
@ 2011-11-09  7:26             ` Andreas Röhler
  2011-11-09  7:45               ` Marius Hofert
  0 siblings, 1 reply; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  7:26 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 08:13, schrieb Marius Hofert:
> Ahh, okay :-) Here's the output:
>
> TAB (translated from<tab>) runs the command completion-at-point, which is an
> interactive compiled Lisp function in `minibuffer.el'.
>
> It is bound to TAB,<menu-bar>  <completion>  <complete>.
>
> (completion-at-point)
>
> Perform completion on the text around point.
> The completion method is determined by `completion-at-point-functions'.
>
>

so you have completion at least in this shell (?)







^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  7:26             ` Andreas Röhler
@ 2011-11-09  7:45               ` Marius Hofert
  2011-11-09  7:54                 ` Marius Hofert
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  7:45 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

> 
> so you have completion at least in this shell (?)
> 

Not for a2ps for example, only for other commands (as I wrote in the beginning). 

If I type a2p + TAB in the Mac's terminal, I get:
a2p       a2p-5.12  a2p5.10   a2p5.12   a2ping    a2ps 

The same in the emacs shell:
Possible completions are:
a2p 	a2p5.10
a2p5.12 	a2ping

=> a2p-5.12 and a2ps are missing [although I can execute, e.g., a2ps].
I can also use which a2ps in the emacs shell and correctly obtain:
/opt/local/bin/a2ps
Also, both PATHs are the same (in the terminal and in the emacs shell).

I installed a2ps via Macports (package manager) and it correctly put in the /opt/local/bin path to PATH.

echo $PATH
/Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin 

The only thing I did was:

Macports defines the following line in .profile:
export PATH=$PATH:/opt/local/bin:/opt/local/sbin

I just added the following to .profile:
export PATH=/Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:$PATH
The reason for this is that with /Applications/Emacs.app... in the beginning of PATH, I can type "emacs" in the terminal and start the same emacs as I installed (the GUI version), not the very old emacs that natively comes with Mac OS and that is /user/bin/emacs

The main problem is that I can't figure out which commands work with TAB completion and which don't. If not all work as in the terminal and if I don't know which work, this is quite tedious to work with (because one assumes that the command one is trying to complete is not installed etc.)

Cheers,

Marius




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  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 15:28                   ` PJ Weisberg
  0 siblings, 2 replies; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  7:54 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

I just figured out that if I start emacs from the Mac's terminal (via "emacs" which starts /Applications/Emacs.app/Contents/MacOS/Emacs) and open an emacs shell with M-x shell, I can tab-complete a2ps. 

Hmmm... so the GUI version seems to act weird...
 

On 2011-11-09, at 08:45 , Marius Hofert wrote:

>> 
>> so you have completion at least in this shell (?)
>> 
> 
> Not for a2ps for example, only for other commands (as I wrote in the beginning). 
> 
> If I type a2p + TAB in the Mac's terminal, I get:
> a2p       a2p-5.12  a2p5.10   a2p5.12   a2ping    a2ps 
> 
> The same in the emacs shell:
> Possible completions are:
> a2p 	a2p5.10
> a2p5.12 	a2ping
> 
> => a2p-5.12 and a2ps are missing [although I can execute, e.g., a2ps].
> I can also use which a2ps in the emacs shell and correctly obtain:
> /opt/local/bin/a2ps
> Also, both PATHs are the same (in the terminal and in the emacs shell).
> 
> I installed a2ps via Macports (package manager) and it correctly put in the /opt/local/bin path to PATH.
> 
> echo $PATH
> /Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin 
> 
> The only thing I did was:
> 
> Macports defines the following line in .profile:
> export PATH=$PATH:/opt/local/bin:/opt/local/sbin
> 
> I just added the following to .profile:
> export PATH=/Applications/Emacs.app/Contents/MacOS/:/Applications/Emacs.app/Contents/MacOS/bin/:$PATH
> The reason for this is that with /Applications/Emacs.app... in the beginning of PATH, I can type "emacs" in the terminal and start the same emacs as I installed (the GUI version), not the very old emacs that natively comes with Mac OS and that is /user/bin/emacs
> 
> The main problem is that I can't figure out which commands work with TAB completion and which don't. If not all work as in the terminal and if I don't know which work, this is quite tedious to work with (because one assumes that the command one is trying to complete is not installed etc.)
> 
> Cheers,
> 
> Marius
> 




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  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 15:28                   ` PJ Weisberg
  1 sibling, 1 reply; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  8:29 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 08:54, schrieb Marius Hofert:
> I just figured out that if I start emacs from the Mac's terminal (via "emacs" which starts /Applications/Emacs.app/Contents/MacOS/Emacs) and open an emacs shell with M-x shell, I can tab-complete a2ps.
>
> Hmmm... so the GUI version seems to act weird...
>

If you do after shell prompt

M-x describe-variable RET completion-at-point-functions

what are the results, differ it in your environments?



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  8:29                   ` Andreas Röhler
@ 2011-11-09  8:34                     ` Marius Hofert
  2011-11-09  8:41                       ` Andreas Röhler
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  8:34 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs


On 2011-11-09, at 09:29 , Andreas Röhler wrote:

> Am 09.11.2011 08:54, schrieb Marius Hofert:
>> I just figured out that if I start emacs from the Mac's terminal (via "emacs" which starts /Applications/Emacs.app/Contents/MacOS/Emacs) and open an emacs shell with M-x shell, I can tab-complete a2ps.
>> 
>> Hmmm... so the GUI version seems to act weird...
>> 
> 
> If you do after shell prompt
> 
> M-x describe-variable RET completion-at-point-functions
> 
> what are the results, differ it in your environments?


in the emacs shell (GUI emacs), I get:

### start ####################################################

completion-at-point-functions is a variable defined in `minibuffer.el'.
Its value is (comint-completion-at-point t)

Local in buffer *shell*; global value is 
(tags-completion-at-point-function)


  This variable is potentially risky when used as a file local variable.

Documentation:
Special hook to find the completion table for the thing at point.
Each function on this hook is called in turns without any argument and should
return either nil to mean that it is not applicable at point,
or a function of no argument to perform completion (discouraged),
or a list of the form (START END COLLECTION &rest PROPS) where
 START and END delimit the entity to complete and should include point,
 COLLECTION is the completion table to use to complete it, and
 PROPS is a property list for additional information.
Currently supported properties are all the properties that can appear in
`completion-extra-properties' plus:
 `:predicate'	a predicate that completion candidates need to satisfy.
 `:exclusive'	If `no', means that if the completion data does not match the
   text at point failure, then instead of reporting a completion failure,
   the completion should try the next completion function.

[back]

### end ####################################################

If I start emacs shell from the emacs started in the terminal (where TAB-completion works), I get:

### start ####################################################

completion-at-point-functions is a variable defined in `minibuffer.el'.
Its value is (comint-completion-at-point t)

Local in buffer *shell*; global value is 
(tags-completion-at-point-function)


  This variable is potentially risky when used as a file local variable.

Documentation:
Special hook to find the completion table for the thing at point.
Each function on this hook is called in turns without any argument and should
return either nil to mean that it is not applicable at point,
or a function of no argument to perform completion (discouraged),
or a list of the form (START END COLLECTION &rest PROPS) where
 START and END delimit the entity to complete and should include point,
 COLLECTION is the completion table to use to complete it, and
 PROPS is a property list for additional information.
Currently supported properties are all the properties that can appear in
`completion-extra-properties' plus:
 `:predicate'	a predicate that completion candidates need to satisfy.
 `:exclusive'	If `no', means that if the completion data does not match the
   text at point failure, then instead of reporting a completion failure,
   the completion should try the next completion function.

### end ####################################################

=> looks like the same output


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  8:34                     ` Marius Hofert
@ 2011-11-09  8:41                       ` Andreas Röhler
  2011-11-09  8:59                         ` Marius Hofert
  0 siblings, 1 reply; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  8:41 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 09:34, schrieb Marius Hofert:
>
> On 2011-11-09, at 09:29 , Andreas Röhler wrote:
>
>> Am 09.11.2011 08:54, schrieb Marius Hofert:
>>> I just figured out that if I start emacs from the Mac's terminal (via "emacs" which starts /Applications/Emacs.app/Contents/MacOS/Emacs) and open an emacs shell with M-x shell, I can tab-complete a2ps.
>>>
>>> Hmmm... so the GUI version seems to act weird...
>>>
>>
>> If you do after shell prompt
>>
>> M-x describe-variable RET completion-at-point-functions
[ ... ]
> =>  looks like the same output

would assume a bug in shell.el

comint-completion-at-point is defined as

(defun comint-completion-at-point ()
   (run-hook-with-args-until-success 'comint-dynamic-complete-functions))

so you could try same play looking for contents of

comint-dynamic-complete-functions



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  8:41                       ` Andreas Röhler
@ 2011-11-09  8:59                         ` Marius Hofert
  2011-11-09  9:05                           ` Marius Hofert
  2011-11-09  9:23                           ` Andreas Röhler
  0 siblings, 2 replies; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  8:59 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

> 
> so you could try same play looking for contents of
> 
> comint-dynamic-complete-functions

I obtain (in both cases):

comint-dynamic-complete-functions is a variable defined in `comint.el'.
Its value is
(comint-c-a-p-replace-by-expanded-history shell-environment-variable-completion shell-command-completion shell-c-a-p-replace-by-expanded-directory pcomplete-completions-at-point shell-filename-completion comint-filename-completion)

Local in buffer *shell*; global value is 
(comint-c-a-p-replace-by-expanded-history comint-filename-completion)


  This variable is potentially risky when used as a file local variable.

Documentation:
List of functions called to perform completion.
Works like `completion-at-point-functions'.
See also `comint-dynamic-complete'.

This is a good thing to set in mode hooks.

[back]


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  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
  1 sibling, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09  9:05 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

I searched for shell.el, but couldn't find it...:

localhost:/ mhofert$ sudo find . -iname "shell" -print
Password:
find: ./dev/fd/3: Not a directory
find: ./dev/fd/4: Not a directory
./Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/shell
./Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/net-ssh-1.1.4/lib/net/ssh/service/shell
./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/shell
./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/shell
./opt/local/lib/perl5/5.12.3/CPANPLUS/Shell
./System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/shell
./System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/share/ri/1.8/system/Shell
./System/Library/Perl/5.10/CPANPLUS/Shell
./System/Library/Perl/5.12/CPANPLUS/Shell
./System/Library/PrivateFrameworks/MacRuby.framework/Versions/A/usr/lib/ruby/1.9.2/shell
./usr/local/texlive/2011/texmf-dist/source/latex/pslatex/shell


On 2011-11-09, at 09:59 , Marius Hofert wrote:

>> 
>> so you could try same play looking for contents of
>> 
>> comint-dynamic-complete-functions
> 
> I obtain (in both cases):
> 
> comint-dynamic-complete-functions is a variable defined in `comint.el'.
> Its value is
> (comint-c-a-p-replace-by-expanded-history shell-environment-variable-completion shell-command-completion shell-c-a-p-replace-by-expanded-directory pcomplete-completions-at-point shell-filename-completion comint-filename-completion)
> 
> Local in buffer *shell*; global value is 
> (comint-c-a-p-replace-by-expanded-history comint-filename-completion)
> 
> 
>  This variable is potentially risky when used as a file local variable.
> 
> Documentation:
> List of functions called to perform completion.
> Works like `completion-at-point-functions'.
> See also `comint-dynamic-complete'.
> 
> This is a good thing to set in mode hooks.
> 
> [back]





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  8:59                         ` Marius Hofert
  2011-11-09  9:05                           ` Marius Hofert
@ 2011-11-09  9:23                           ` Andreas Röhler
  2011-11-09 11:10                             ` Marius Hofert
  1 sibling, 1 reply; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09  9:23 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 09:59, schrieb Marius Hofert:
>>
>> so you could try same play looking for contents of
>>
>> comint-dynamic-complete-functions
>
> I obtain (in both cases):
>
> comint-dynamic-complete-functions is a variable defined in `comint.el'.
> Its value is
> (comint-c-a-p-replace-by-expanded-history shell-environment-variable-completion shell-command-completion shell-c-a-p-replace-by-expanded-directory pcomplete-completions-at-point shell-filename-completion comint-filename-completion)
>
> Local in buffer *shell*; global value is
> (comint-c-a-p-replace-by-expanded-history comint-filename-completion)

IIUC completion stops when first function in list succeeds

you could put functions one by one into edebug, thus being noticed which 
one was active and how it went



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  9:23                           ` Andreas Röhler
@ 2011-11-09 11:10                             ` Marius Hofert
  2011-11-09 13:29                               ` Andreas Röhler
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09 11:10 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs


On 2011-11-09, at 10:23 , Andreas Röhler wrote:

> Am 09.11.2011 09:59, schrieb Marius Hofert:
>>> 
>>> so you could try same play looking for contents of
>>> 
>>> comint-dynamic-complete-functions
>> 
>> I obtain (in both cases):
>> 
>> comint-dynamic-complete-functions is a variable defined in `comint.el'.
>> Its value is
>> (comint-c-a-p-replace-by-expanded-history shell-environment-variable-completion shell-command-completion shell-c-a-p-replace-by-expanded-directory pcomplete-completions-at-point shell-filename-completion comint-filename-completion)
>> 
>> Local in buffer *shell*; global value is
>> (comint-c-a-p-replace-by-expanded-history comint-filename-completion)
> 
> IIUC completion stops when first function in list succeeds
> 
> you could put functions one by one into edebug, thus being noticed which one was active and how it went

that's a bit (or rather far) above my emacs abilities. Can you give me short instructions what to do? 

The simple solution is to just start emacs from the terminal. I'm not sure if this has any disadvantages, though (but they should arise when using emacs from the terminal for some time)


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09 11:10                             ` Marius Hofert
@ 2011-11-09 13:29                               ` Andreas Röhler
  0 siblings, 0 replies; 32+ messages in thread
From: Andreas Röhler @ 2011-11-09 13:29 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

Am 09.11.2011 12:10, schrieb Marius Hofert:

>>> I obtain (in both cases):
>>>
>>> comint-dynamic-complete-functions is a variable defined in `comint.el'.
>>> Its value is
>>> (comint-c-a-p-replace-by-expanded-history shell-environment-variable-completion shell-command-completion shell-c-a-p-replace-by-expanded-directory pcomplete-completions-at-point shell-filename-completion comint-filename-completion)
>>>
>>> Local in buffer *shell*; global value is
>>> (comint-c-a-p-replace-by-expanded-history comint-filename-completion)
>>
>> IIUC completion stops when first function in list succeeds
>>
>> you could put functions one by one into edebug, thus being noticed which one was active and how it went
>
> that's a bit (or rather far) above my emacs abilities. Can you give me short instructions what to do?
>

jump into the buffer where `comint-dynamic-complete-functions' contents 
-- the functions list-- it displayed as above.

Cursor over first function, M-x describe-function RET

help-buffer than displays a link --xref-- to definition. RET over this link.

When functions definition displayed, over there M-x edebug-defun

Next completing TAB in shell should display edebug-modus.

step through with "s" or "n"
Have a look at edebug first if not used to - an excellent tool IMO.



> The simple solution is to just start emacs from the terminal. I'm not sure if this has any disadvantages, though (but they should arise when using emacs from the terminal for some time)




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  7:54                 ` Marius Hofert
  2011-11-09  8:29                   ` Andreas Röhler
@ 2011-11-09 15:28                   ` PJ Weisberg
  2011-11-09 17:02                     ` Marius Hofert
  1 sibling, 1 reply; 32+ messages in thread
From: PJ Weisberg @ 2011-11-09 15:28 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

I think you guys are going down the wrong track.

On Tuesday, November 8, 2011, Marius Hofert <marius.hofert@math.ethz.ch>
wrote:
> I just figured out that if I start emacs from the Mac's terminal (via
"emacs" which starts /Applications/Emacs.app/Contents/MacOS/Emacs) and open
an emacs shell with M-x shell, I can tab-complete a2ps.
>
> Hmmm... so the GUI version seems to act weird...

It sounds to me like OSX's launcher is not setting some environment
variable that does get set when you run the terminal.  Possibly $FPATH.  I
would guess that it's looking for and not finding a function called _a2ps
to do the completion.

-- 

-PJ

[-- Attachment #2: Type: text/html, Size: 764 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09 15:28                   ` PJ Weisberg
@ 2011-11-09 17:02                     ` Marius Hofert
  0 siblings, 0 replies; 32+ messages in thread
From: Marius Hofert @ 2011-11-09 17:02 UTC (permalink / raw)
  To: PJ Weisberg; +Cc: help-gnu-emacs@gnu.org


On 2011-11-09, at 16:28 , PJ Weisberg wrote:

> I think you guys are going down the wrong track.
> 
> On Tuesday, November 8, 2011, Marius Hofert <marius.hofert@math.ethz.ch> wrote:
> > I just figured out that if I start emacs from the Mac's terminal (via "emacs" which starts /Applications/Emacs.app/Contents/MacOS/Emacs) and open an emacs shell with M-x shell, I can tab-complete a2ps.
> >
> > Hmmm... so the GUI version seems to act weird...
> 
> It sounds to me like OSX's launcher is not setting some environment variable that does get set when you run the terminal.

I'm no expert on this (otherwise I would have figured it out on my own), but it sounds reasonable.

>  Possibly $FPATH.

never heard about that. I echo'ed that in the terminal and in the emacs shell and obtained an empty line in both cases.

>  I would guess that it's looking for and not finding a function called _a2ps to do the completion.
> 
> -- 
> 
> -PJ




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
       [not found] <mailman.2976.1320857313.797.help-gnu-emacs@gnu.org>
@ 2011-11-09 17:06 ` Jonathan Oddie
  2011-11-09 17:28   ` Marius Hofert
  0 siblings, 1 reply; 32+ messages in thread
From: Jonathan Oddie @ 2011-11-09 17:06 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Marius and all,

> It sounds to me like OSX's launcher is not setting some environment
> variable that does get set when you run the terminal.  Possibly $FPATH.  I
> would guess that it's looking for and not finding a function called _a2ps
> to do the completion.

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 ":"))


HTH,
Jonathan




> 
> -- 
> 
> -PJ
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.gnu.org/archive/html/help-gnu-emacs/attachments/20111109/4db7f9ae/attachment.html>
> 
> ------------------------------
> 
> Message: 8
> Date: Wed, 09 Nov 2011 18:46:22 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Very slow redrawing when several windows in one frame
> Message-ID: <83mxc5gs69.fsf@gnu.org>
> 
>> From: julien Barnier <julien@nozav.org>
>> Date: Wed, 9 Nov 2011 14:18:03 +0000 (UTC)
>> 
>> One thing I've noticed is that as soon as I've got several windows opened in
>> one frame, window redrawing begin to be very slow (and the more open windows,
>> the slower it is). Any operation that requires a bit of redrawing (window
>> switching, minibuffer height change, etc.) is slow.
> 
> Please submit a bug report (with "M-x report-emacs-bug RET"), and
> please show a recipe starting with "emacs -Q" for reproducing this
> progressive slowdown.  If you need to visit specific files for
> reproducing the problem, please try using files that are part of the
> Emacs source tree, or else tell where to get those files.
> 
> Thanks in advance.
> 
>> Is it a known bug ?
> 
> Not as far as I Know.
> 
>> Is there a workaround ?
> 
> Bugs should be fixed, not worked around. ;-)
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> https://lists.gnu.org/mailman/listinfo/help-gnu-emacs
> 
> 
> End of help-gnu-emacs Digest, Vol 108, Issue 16
> ***********************************************




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 17:06 ` Jonathan Oddie
@ 2011-11-09 17:28   ` Marius Hofert
  2011-11-09 17:38     ` Jonathan Oddie
  2011-11-09 17:46     ` Jonathan Oddie
  0 siblings, 2 replies; 32+ messages in thread
From: Marius Hofert @ 2011-11-09 17:28 UTC (permalink / raw)
  To: Jonathan Oddie; +Cc: help-gnu-emacs


> 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





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 17:28   ` Marius Hofert
@ 2011-11-09 17:38     ` Jonathan Oddie
  2011-11-09 17:51       ` Marius Hofert
  2011-11-09 17:46     ` Jonathan Oddie
  1 sibling, 1 reply; 32+ messages in thread
From: Jonathan Oddie @ 2011-11-09 17:38 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs


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.

> [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

> 
> Cheers,
> 
> Marius
> 
> 




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 17:28   ` Marius Hofert
  2011-11-09 17:38     ` Jonathan Oddie
@ 2011-11-09 17:46     ` Jonathan Oddie
  1 sibling, 0 replies; 32+ messages in thread
From: Jonathan Oddie @ 2011-11-09 17:46 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 17:38     ` Jonathan Oddie
@ 2011-11-09 17:51       ` Marius Hofert
  2011-11-09 18:05         ` Jonathan Oddie
  0 siblings, 1 reply; 32+ messages in thread
From: Marius Hofert @ 2011-11-09 17:51 UTC (permalink / raw)
  To: Jonathan Oddie; +Cc: help-gnu-emacs


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.






^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 17:51       ` Marius Hofert
@ 2011-11-09 18:05         ` Jonathan Oddie
  2011-11-09 18:49           ` Jonathan Oddie
  2011-11-09 21:19           ` Marius Hofert
  0 siblings, 2 replies; 32+ messages in thread
From: Jonathan Oddie @ 2011-11-09 18:05 UTC (permalink / raw)
  To: Marius Hofert; +Cc: help-gnu-emacs

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.
> 
> 
> 




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  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
  1 sibling, 1 reply; 32+ messages in thread
From: Jonathan Oddie @ 2011-11-09 18:49 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

One more detail about this that surprised me: the last component
of `exec-path' is always ignored by tab-completion in shell-mode. I
thought this was weird initially, but it's because by default
the last component of `exec-path' will be a directory of executables
Emacs uses internally: stuff like `vcdiff' and `movemail'.

This also means one needs to be a bit careful about setting the value of
`exec-path'. I wonder if there should be a note about this in the
docstring either for `exec-path' or `shell-dynamic-complete-as-command'?

cheers,
Jonathan

On 9 Nov 2011, at 18:05, Jonathan Oddie wrote:

> 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.
>> 
>> 
>> 
> 




^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 18:49           ` Jonathan Oddie
@ 2011-11-09 18:52             ` Jonathan Oddie
  0 siblings, 0 replies; 32+ messages in thread
From: Jonathan Oddie @ 2011-11-09 18:52 UTC (permalink / raw)
  To: help-gnu-emacs

> 
> This also means one needs to be a bit careful about setting the value of
> `exec-path'. I wonder if there should be a note about this in the
> docstring either for `exec-path' or `shell-dynamic-complete-as-command'?

... which in fact there is, and I even copied and pasted it in my last email. 
never mind, ignore the dummy over here.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some  commands?
  2011-11-09 18:05         ` Jonathan Oddie
  2011-11-09 18:49           ` Jonathan Oddie
@ 2011-11-09 21:19           ` Marius Hofert
  1 sibling, 0 replies; 32+ messages in thread
From: Marius Hofert @ 2011-11-09 21:19 UTC (permalink / raw)
  To: Jonathan Oddie; +Cc: help-gnu-emacs

Dear Jonathan,

thank you very much, it works *perfectly*!!!
I have the same PATH *and* a2ps is properly TAB-completed.

*Brilliant* :-)

Cheers,

Marius


On 2011-11-09, at 19:05 , Jonathan Oddie wrote:

> 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.
>> 
>> 
>> 
> 





^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: Why is TAB-completion in shell not working for some commands?
  2011-11-09  9:05                           ` Marius Hofert
@ 2011-11-11  3:03                             ` Kevin Rodgers
  0 siblings, 0 replies; 32+ messages in thread
From: Kevin Rodgers @ 2011-11-11  3:03 UTC (permalink / raw)
  To: help-gnu-emacs

On 11/9/11 2:05 AM, Marius Hofert wrote:
> I searched for shell.el, but couldn't find it...:

M-x find-library RET shell RET

> localhost:/ mhofert$ sudo find . -iname "shell" -print

"shell" should be "shell.el*"

> Password:
> find: ./dev/fd/3: Not a directory
> find: ./dev/fd/4: Not a directory
> ./Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/shell
> ./Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/net-ssh-1.1.4/lib/net/ssh/service/shell
> ./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/shell
> ./Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/vendor/thor/shell
> ./opt/local/lib/perl5/5.12.3/CPANPLUS/Shell
> ./System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/shell
> ./System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/share/ri/1.8/system/Shell
> ./System/Library/Perl/5.10/CPANPLUS/Shell
> ./System/Library/Perl/5.12/CPANPLUS/Shell
> ./System/Library/PrivateFrameworks/MacRuby.framework/Versions/A/usr/lib/ruby/1.9.2/shell
> ./usr/local/texlive/2011/texmf-dist/source/latex/pslatex/shell

-- 
Kevin Rodgers
Denver, Colorado, USA




^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2011-11-11  3:03 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.9.1320780886.798.help-gnu-emacs@gnu.org>
2011-11-09  1:34 ` Why is TAB-completion in shell not working for some commands? Stefan Monnier
     [not found] <mailman.2976.1320857313.797.help-gnu-emacs@gnu.org>
2011-11-09 17:06 ` 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
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

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.