[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there any way to open a file whose name is written in another fil
From: |
Emanuel Berg |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
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