unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Is there any way to open a file whose name is written in another file?
@ 2015-02-06 21:29 xiongjieyi
  2015-02-06 22:43 ` Emanuel Berg
  0 siblings, 1 reply; 4+ messages in thread
From: xiongjieyi @ 2015-02-06 21:29 UTC (permalink / raw)
  To: help-gnu-emacs

Is there any way to open a file whose name is written in another file? For example, I want to open file A in emacs. The path and name of file A is recorded in file B. The filename of file B is fixed, but file A is changeable. So I hope emacs can read the path&name of file A in file B first, and open file A.


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

* Re: Is there any way to open a file whose name is written in another file?
  2015-02-06 21:29 Is there any way to open a file whose name is written in another file? xiongjieyi
@ 2015-02-06 22:43 ` Emanuel Berg
  2015-02-07  7:01   ` Jason Rumney
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg @ 2015-02-06 22:43 UTC (permalink / raw)
  To: help-gnu-emacs

xiongjieyi@gmail.com writes:

> Is there any way to open a file whose name is
> written in another file? For example, I want to open
> file A in emacs. The path and name of file A is
> recorded in file B. The filename of file B is fixed,
> but file A is changeable. So I hope emacs can read
> the path&name of file A in file B first, and open
> file A.

Try this:

    (progn
      (find-file "b.txt")
      (goto-char 0)
      (find-file (thing-at-point 'filename)) )

If you want to do something similar interactively, try
this:

    (defun find-file-at-line (&optional other-window)
      (interactive "P")
      (let ((possible-filename (thing-at-point 'filename))
            (find-f (if other-window 'find-file-other-window 'find-file)) )
        (if (and possible-filename (file-exists-p possible-filename))
              (apply find-f (list possible-filename))
          (progn
            (forward-char 1)
            (find-file-at-line) ))))

-- 
underground experts united


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

* Re: Is there any way to open a file whose name is written in another file?
  2015-02-06 22:43 ` Emanuel Berg
@ 2015-02-07  7:01   ` Jason Rumney
  2015-02-07 21:08     ` Emanuel Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Rumney @ 2015-02-07  7:01 UTC (permalink / raw)
  To: help-gnu-emacs

On Saturday, 7 February 2015 06:40:48 UTC+8, Emanuel Berg  wrote:

> If you want to do something similar interactively, try

M-x ffap


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

* Re: Is there any way to open a file whose name is written in another file?
  2015-02-07  7:01   ` Jason Rumney
@ 2015-02-07 21:08     ` Emanuel Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2015-02-07 21:08 UTC (permalink / raw)
  To: help-gnu-emacs

Jason Rumney <jasonrumney@gmail.com> writes:

>> If you want to do something similar interactively,
>> try
>
> M-x ffap

`find-file-at-point' works if point is exactly at the
path (hence the name), and you have to confirm the
path in the metabuffer with RET.

-- 
underground experts united


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

end of thread, other threads:[~2015-02-07 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 21:29 Is there any way to open a file whose name is written in another file? xiongjieyi
2015-02-06 22:43 ` Emanuel Berg
2015-02-07  7:01   ` Jason Rumney
2015-02-07 21:08     ` Emanuel Berg

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