unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* open file listed in a text file
@ 2010-02-07 13:34 Chitlesh Goorah
  2010-02-07 14:38 ` José A. Romero L.
  0 siblings, 1 reply; 18+ messages in thread
From: Chitlesh Goorah @ 2010-02-07 13:34 UTC (permalink / raw)
  To: help-gnu-emacs

Hello there,

I've seen people using gvim opening a file whose filename and path are
listed in a text file. e.g

#----------------------
#!/usr/bin/tclsh

source $(SCRIPTS_HOME)/definitions.tcl
....
#----------------------


Is there a  way to open the $(SCRIPTS_HOME)/definitions.tcl (with a
shortcut) within emacs itself just by placing the cursor on that
filename, instead of ctrl-x-f  ?



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

* Re: open file listed in a text file
  2010-02-07 13:34 open file listed in a text file Chitlesh Goorah
@ 2010-02-07 14:38 ` José A. Romero L.
  2010-02-07 22:09   ` Chitlesh Goorah
  0 siblings, 1 reply; 18+ messages in thread
From: José A. Romero L. @ 2010-02-07 14:38 UTC (permalink / raw)
  To: help-gnu-emacs

On 7 Lut, 14:34, Chitlesh Goorah <chitl...@gmail.com> wrote:
(...)
> Is there a  way to open the $(SCRIPTS_HOME)/definitions.tcl (with a
> shortcut) within emacs itself just by placing the cursor on that
> filename, instead of ctrl-x-f  ?

Probably this is what you're looking for:

    find-file-at-point is an interactive compiled Lisp function in
    `ffap.el'.

    It is bound to g f.

    (find-file-at-point &optional FILENAME)

    Find FILENAME, guessing a default from text around point.  If
    `ffap-url-regexp' is not nil, the FILENAME may also be an URL.
    With a prefix, this command behaves exactly like
    `ffap-file-finder'.  If `ffap-require-prefix' is set, the prefix
    meaning is reversed.  See also the variables
    `ffap-dired-wildcards', `ffap-newfile-prompt', and the functions
    `ffap-file-at-point' and `ffap-url-at-point'.

Cheers,
--
José A. Romero L.
escherdragon at gmail.com
"We who cut mere stones must always be envisioning cathedrals."
(Quarry worker's creed)


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

* Re: open file listed in a text file
  2010-02-07 14:38 ` José A. Romero L.
@ 2010-02-07 22:09   ` Chitlesh Goorah
  2010-02-08  2:57     ` Barry Margolin
  0 siblings, 1 reply; 18+ messages in thread
From: Chitlesh Goorah @ 2010-02-07 22:09 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 7, 3:38 pm, José A. Romero L. wrote:
> Probably this is what you're looking for:
>     find-file-at-point is an interactive compiled Lisp function in
>     `ffap.el'.

Hello,

No unfortunately, this is not what I'm looking for.


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

* Re: open file listed in a text file
  2010-02-07 22:09   ` Chitlesh Goorah
@ 2010-02-08  2:57     ` Barry Margolin
  2010-02-08 12:22       ` Jorgen Grahn
                         ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Barry Margolin @ 2010-02-08  2:57 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

In article 
<800bd9a9-0a03-4fc9-b395-328fbd835c93@l26g2000yqd.googlegroups.com>,
 Chitlesh Goorah <chitlesh@gmail.com> wrote:

> On Feb 7, 3:38 pm, José A. Romero L. wrote:
> > Probably this is what you're looking for:
> >     find-file-at-point is an interactive compiled Lisp function in
> >     `ffap.el'.
> 
> Hello,
> 
> No unfortunately, this is not what I'm looking for.

It was what I was going to suggest as well. What's the difference 
between what it does and what you want?

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


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

* Re: open file listed in a text file
  2010-02-08  2:57     ` Barry Margolin
@ 2010-02-08 12:22       ` Jorgen Grahn
  2010-02-09  1:37       ` William Xu
       [not found]       ` <mailman.889.1265679652.14305.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 18+ messages in thread
From: Jorgen Grahn @ 2010-02-08 12:22 UTC (permalink / raw)
  To: help-gnu-emacs

On Mon, 2010-02-08, Barry Margolin wrote:
> In article 
> <800bd9a9-0a03-4fc9-b395-328fbd835c93@l26g2000yqd.googlegroups.com>,
>  Chitlesh Goorah <chitlesh@gmail.com> wrote:
>
>> On Feb 7, 3:38 pm, José A. Romero L. wrote:
>> > Probably this is what you're looking for:
>> >     find-file-at-point is an interactive compiled Lisp function in
>> >     `ffap.el'.
>> 
>> Hello,
>> 
>> No unfortunately, this is not what I'm looking for.
>
> It was what I was going to suggest as well. What's the difference 
> between what it does and what you want?

He should have said, but possibly the variable in his example
is what makes it fail:

    source $(SCRIPTS_HOME)/definitions.tcl

I see no easy way around that. That's a name for the run-time
environment and if he's unlucky it doesn't even exist in the edit-time
environment (maybe installing the program means copying files from all
over the place into $SCRIPTS_HOME).

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .


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

* Re: open file listed in a text file
  2010-02-08  2:57     ` Barry Margolin
  2010-02-08 12:22       ` Jorgen Grahn
@ 2010-02-09  1:37       ` William Xu
  2010-02-09  2:08         ` William Xu
       [not found]       ` <mailman.889.1265679652.14305.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 18+ messages in thread
From: William Xu @ 2010-02-09  1:37 UTC (permalink / raw)
  To: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:

>> Hello,
>> 
>> No unfortunately, this is not what I'm looking for.
>
> It was what I was going to suggest as well. What's the difference 
> between what it does and what you want?

It seems that his file path includes an environment variable: 

  $(SCRIPTS_HOME)/definitions.tcl

Vim is smart...  An elisp function may be needed to achieve that.  

-- 
William

http://xwl.appspot.com





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

* Re: open file listed in a text file
  2010-02-09  1:37       ` William Xu
@ 2010-02-09  2:08         ` William Xu
  2010-02-09  2:26           ` Lennart Borgman
  2010-02-09  4:09           ` Eli Zaretskii
  0 siblings, 2 replies; 18+ messages in thread
From: William Xu @ 2010-02-09  2:08 UTC (permalink / raw)
  To: help-gnu-emacs

William Xu <william.xwl@gmail.com> writes:

> Barry Margolin <barmar@alum.mit.edu> writes:
>
>>> Hello,
>>> 
>>> No unfortunately, this is not what I'm looking for.
>>
>> It was what I was going to suggest as well. What's the difference 
>> between what it does and what you want?
>
> It seems that his file path includes an environment variable: 
>
>   $(SCRIPTS_HOME)/definitions.tcl
>
> Vim is smart...  An elisp function may be needed to achieve that.  

Ahh, I was wrong.  Emacs also understands that.  Except both emacs & vim
don't recognize environment variable on Windows XP.  

-- 
William

http://xwl.appspot.com





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

* Re: open file listed in a text file
  2010-02-09  2:08         ` William Xu
@ 2010-02-09  2:26           ` Lennart Borgman
  2010-02-09  4:09           ` Eli Zaretskii
  1 sibling, 0 replies; 18+ messages in thread
From: Lennart Borgman @ 2010-02-09  2:26 UTC (permalink / raw)
  To: William Xu; +Cc: help-gnu-emacs

On Tue, Feb 9, 2010 at 3:08 AM, William Xu <william.xwl@gmail.com> wrote:
>
> Ahh, I was wrong.  Emacs also understands that.  Except both emacs & vim
> don't recognize environment variable on Windows XP.

(unless (file-exists-p (substitute-in-file-name "$ProgramFiles/GIMP-2.0"))
  (message "Don't you know about GIMP?"))




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

* Re: open file listed in a text file
  2010-02-09  2:08         ` William Xu
  2010-02-09  2:26           ` Lennart Borgman
@ 2010-02-09  4:09           ` Eli Zaretskii
  2010-02-09  5:35             ` William Xu
  1 sibling, 1 reply; 18+ messages in thread
From: Eli Zaretskii @ 2010-02-09  4:09 UTC (permalink / raw)
  To: help-gnu-emacs

> From: William Xu <william.xwl@gmail.com>
> Date: Tue, 09 Feb 2010 10:08:37 +0800
> 
> Except both emacs & vim don't recognize environment variable on
> Windows XP.

How do you see that?




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

* Re: open file listed in a text file
  2010-02-09  4:09           ` Eli Zaretskii
@ 2010-02-09  5:35             ` William Xu
  2010-02-09 18:19               ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: William Xu @ 2010-02-09  5:35 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: William Xu <william.xwl@gmail.com>
>> Date: Tue, 09 Feb 2010 10:08:37 +0800
>> 
>> Except both emacs & vim don't recognize environment variable on
>> Windows XP.
>
> How do you see that?

On Windows XP, I tried `ffap' with: 
  %HOME%/.emacs.d

which i assume is similar to: (in GNU/Linux)
  $HOME/.emacs.d

ffap could open the path successfully on GNU/Linux.  

While it looks like on Windows XP, ffap also understands $HOME, but not
%HOME%.  

-- 
William

http://xwl.appspot.com





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

* Re: open file listed in a text file
  2010-02-09  5:35             ` William Xu
@ 2010-02-09 18:19               ` Eli Zaretskii
  0 siblings, 0 replies; 18+ messages in thread
From: Eli Zaretskii @ 2010-02-09 18:19 UTC (permalink / raw)
  To: help-gnu-emacs

> From: William Xu <william.xwl@gmail.com>
> Date: Tue, 09 Feb 2010 13:35:14 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: William Xu <william.xwl@gmail.com>
> >> Date: Tue, 09 Feb 2010 10:08:37 +0800
> >> 
> >> Except both emacs & vim don't recognize environment variable on
> >> Windows XP.
> >
> > How do you see that?
> 
> On Windows XP, I tried `ffap' with: 
>   %HOME%/.emacs.d
> 
> which i assume is similar to: (in GNU/Linux)
>   $HOME/.emacs.d
> 
> ffap could open the path successfully on GNU/Linux.  
> 
> While it looks like on Windows XP, ffap also understands $HOME, but not
> %HOME%.  

That's by design: Emacs supports the $FOO notation on all platforms,
and does not support DOS/Windows-specific %FOO% syntax.  Here's an
example:

 (substitute-in-file-name "$ComSpec") => "C:\\WINDOWS\\system32\\cmd.exe"




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

* Re: open file listed in a text file
       [not found]       ` <mailman.889.1265679652.14305.help-gnu-emacs@gnu.org>
@ 2010-02-09 21:02         ` Chitlesh Goorah
  2010-02-09 23:01           ` Suvayu Ali
                             ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Chitlesh Goorah @ 2010-02-09 21:02 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 9, 2:37 am, William Xu <william....@gmail.com> wrote:
> It seems that his file path includes an environment variable:
>
>   $(SCRIPTS_HOME)/definitions.tcl
>
> Vim is smart...  An elisp function may be needed to achieve that.  


I have full control over the env variable. Imagine it is set with a
sort of cshrc file.

I just learnt that even nedit can open that file with Ctrl-Y. Surely
emacs must have an equivalent.

Chitlesh


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

* Re: open file listed in a text file
  2010-02-09 21:02         ` Chitlesh Goorah
@ 2010-02-09 23:01           ` Suvayu Ali
  2010-02-10 11:03           ` Andreas Politz
       [not found]           ` <mailman.959.1265756505.14305.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 18+ messages in thread
From: Suvayu Ali @ 2010-02-09 23:01 UTC (permalink / raw)
  To: help-gnu-emacs

On Tuesday 09 February 2010 01:02 PM, Chitlesh Goorah wrote:
> On Feb 9, 2:37�am, William Xu<william....@gmail.com>  wrote:
>> It seems that his file path includes an environment variable:
>>
>> � $(SCRIPTS_HOME)/definitions.tcl
>>
>> Vim is smart... �An elisp function may be needed to achieve that. �
>
>
> I have full control over the env variable. Imagine it is set with a
> sort of cshrc file.
>
> I just learnt that even nedit can open that file with Ctrl-Y. Surely
> emacs must have an equivalent.

I don't understand your problem, I just tried the same thing with a 
custom environment variable, and it worked.

`M-! file $ROOTSYS/build/version_number RET'

returns,

/home/suvayu/root/build/version_number: ASCII text

`M-x ffap' prompts me for,

Find file or URL: ~/root/build/version_number

and on `RET' opens the file showing its contents. Are you sure your 
environment is setup correctly?

>
> Chitlesh

-- 
Suvayu

Open source is the future. It sets us free.




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

* Re: open file listed in a text file
  2010-02-09 21:02         ` Chitlesh Goorah
  2010-02-09 23:01           ` Suvayu Ali
@ 2010-02-10 11:03           ` Andreas Politz
       [not found]           ` <mailman.959.1265756505.14305.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 18+ messages in thread
From: Andreas Politz @ 2010-02-10 11:03 UTC (permalink / raw)
  To: help-gnu-emacs

Chitlesh Goorah <chitlesh@gmail.com> writes:

> On Feb 9, 2:37 am, William Xu <william....@gmail.com> wrote:
>> It seems that his file path includes an environment variable:
>>
>>   $(SCRIPTS_HOME)/definitions.tcl
>>
>> Vim is smart...  An elisp function may be needed to achieve that.  
>
>
> I have full control over the env variable. Imagine it is set with a
> sort of cshrc file.
>
> I just learnt that even nedit can open that file with Ctrl-Y. Surely
> emacs must have an equivalent.
>
> Chitlesh

Maybe you could use an before advice on the function
`substitute-in-file-name', that transforms the variables into a format
which the function understands.

%FOO%,$(FOO) -> ${FOO}

-ap





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

* Re: open file listed in a text file
       [not found]           ` <mailman.959.1265756505.14305.help-gnu-emacs@gnu.org>
@ 2010-02-11  8:04             ` Chitlesh Goorah
  2010-02-11  9:21               ` Suvayu Ali
  0 siblings, 1 reply; 18+ messages in thread
From: Chitlesh Goorah @ 2010-02-11  8:04 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 10, 12:01 am, Suvayu Ali <fatkasuvayu+li...@gmail.com> wrote:
> I don't understand your problem, I just tried the same thing with a
> custom environment variable, and it worked.
>
> `M-! file $ROOTSYS/build/version_number RET'
>
> returns,
>
> /home/suvayu/root/build/version_number: ASCII text
>
> `M-x ffap' prompts me for,
>
> Find file or URL: ~/root/build/version_number
>

What I want is that when the cursor is on the path of a file (in a
file), I would like to open that particular file with a keyboard
shortcut.

Chitlesh


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

* Re: open file listed in a text file
  2010-02-11  8:04             ` Chitlesh Goorah
@ 2010-02-11  9:21               ` Suvayu Ali
  2010-02-11  9:31                 ` Suvayu Ali
  0 siblings, 1 reply; 18+ messages in thread
From: Suvayu Ali @ 2010-02-11  9:21 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday 11 February 2010 12:04 AM, Chitlesh Goorah wrote:
> On Feb 10, 12:01 am, Suvayu Ali<fatkasuvayu+li...@gmail.com>  wrote:
>> I don't understand your problem, I just tried the same thing with a
>> custom environment variable, and it worked.
>>
>> `M-! file $ROOTSYS/build/version_number RET'
>>
>> returns,
>>
>> /home/suvayu/root/build/version_number: ASCII text
>>
>> `M-x ffap' prompts me for,
>>
>> Find file or URL: ~/root/build/version_number
>>
>
> What I want is that when the cursor is on the path of a file (in a
> file), I would like to open that particular file with a keyboard
> shortcut.

I did the exact same thing! I put this `$ROOTSYS/build/version_number' 
in the *scratch* buffer and executed `M-x ffap'. I mention this in my 
previous message.

>
> Chitlesh

-- 
Suvayu

Open source is the future. It sets us free.




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

* Re: open file listed in a text file
  2010-02-11  9:21               ` Suvayu Ali
@ 2010-02-11  9:31                 ` Suvayu Ali
  2010-02-11 16:09                   ` Drew Adams
  0 siblings, 1 reply; 18+ messages in thread
From: Suvayu Ali @ 2010-02-11  9:31 UTC (permalink / raw)
  To: help-gnu-emacs

On Thursday 11 February 2010 01:21 AM, Suvayu Ali wrote:
> On Thursday 11 February 2010 12:04 AM, Chitlesh Goorah wrote:
>> On Feb 10, 12:01 am, Suvayu Ali<fatkasuvayu+li...@gmail.com> wrote:
>>> I don't understand your problem, I just tried the same thing with a
>>> custom environment variable, and it worked.
>>>
>>> `M-! file $ROOTSYS/build/version_number RET'
>>>
>>> returns,
>>>
>>> /home/suvayu/root/build/version_number: ASCII text
>>>
>>> `M-x ffap' prompts me for,
>>>
>>> Find file or URL: ~/root/build/version_number
>>>
>>
>> What I want is that when the cursor is on the path of a file (in a
>> file), I would like to open that particular file with a keyboard
>> shortcut.
>
> I did the exact same thing! I put this `$ROOTSYS/build/version_number'
> in the *scratch* buffer and executed `M-x ffap'. I mention this in my
> previous message.

I think what Andreas mentioned in a previous post is of importance. 
Emacs is not understanding that ${var} or $(var) or $var are the same 
thing. I repeated my experiment again, I noticed `M-x ffap' works only 
when I use the $var construct in the buffer. Maybe you can write a 
function that translates your preferred construct to $var and calls ffap 
with that modified string?

I hope this helps.
-- 
Suvayu

Open source is the future. It sets us free.




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

* RE: open file listed in a text file
  2010-02-11  9:31                 ` Suvayu Ali
@ 2010-02-11 16:09                   ` Drew Adams
  0 siblings, 0 replies; 18+ messages in thread
From: Drew Adams @ 2010-02-11 16:09 UTC (permalink / raw)
  To: 'Suvayu Ali', help-gnu-emacs

> >> What I want is that when the cursor is on the path of a file (in a
> >> file), I would like to open that particular file with a keyboard
> >> shortcut.
> >
> > I did the exact same thing! I put this 
> > `$ROOTSYS/build/version_number'
> > in the *scratch* buffer and executed `M-x ffap'. I mention 
> > this in my previous message.
> 
> I think what Andreas mentioned in a previous post is of importance. 
> Emacs is not understanding that ${var} or $(var) or $var are the same 
> thing. I repeated my experiment again, I noticed `M-x ffap' 
> works only when I use the $var construct in the buffer. Maybe you
> can write a function that translates your preferred construct to
> $var and calls ffap with that modified string?

I haven't followed this thread closely. I get the impression that the question
has been answered several times now.

FWIW, In Icicles, `M-.' in the minibuffer retrieves text at point - always. For
commands that act on file names (e.g. `C-x C-f'), you can use `M-.' to pick up a
file name or URL at point.

And it will expand $var and ${var} correctly. (But it does not expand $(var).)

HTH.





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

end of thread, other threads:[~2010-02-11 16:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-07 13:34 open file listed in a text file Chitlesh Goorah
2010-02-07 14:38 ` José A. Romero L.
2010-02-07 22:09   ` Chitlesh Goorah
2010-02-08  2:57     ` Barry Margolin
2010-02-08 12:22       ` Jorgen Grahn
2010-02-09  1:37       ` William Xu
2010-02-09  2:08         ` William Xu
2010-02-09  2:26           ` Lennart Borgman
2010-02-09  4:09           ` Eli Zaretskii
2010-02-09  5:35             ` William Xu
2010-02-09 18:19               ` Eli Zaretskii
     [not found]       ` <mailman.889.1265679652.14305.help-gnu-emacs@gnu.org>
2010-02-09 21:02         ` Chitlesh Goorah
2010-02-09 23:01           ` Suvayu Ali
2010-02-10 11:03           ` Andreas Politz
     [not found]           ` <mailman.959.1265756505.14305.help-gnu-emacs@gnu.org>
2010-02-11  8:04             ` Chitlesh Goorah
2010-02-11  9:21               ` Suvayu Ali
2010-02-11  9:31                 ` Suvayu Ali
2010-02-11 16:09                   ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).