From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Is there any way to open a file whose name is written in another file?
Date: Fri, 06 Feb 2015 23:43:43 +0100 [thread overview]
Message-ID: <87r3u2hd9c.fsf@debian.uxu> (raw)
In-Reply-To: 559d9e65-37dd-4ac0-8cbd-f80e8d91bb83@googlegroups.com
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
next prev parent reply other threads:[~2015-02-06 22:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2015-02-07 7:01 ` Jason Rumney
2015-02-07 21:08 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r3u2hd9c.fsf@debian.uxu \
--to=embe8573@student.uu.se \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).