Skip to content

Commit

Permalink
New functions for opening files.
Browse files Browse the repository at this point in the history
find-file-noselect-relative opens a file with a relative path.
with-relative-file is a macro that runs in a buffer created with the
contents of the file.
  • Loading branch information
phillord-ncl committed Feb 19, 2015
1 parent 3fa56d7 commit 267e9c3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions load-relative.el
Expand Up @@ -179,6 +179,30 @@ finding __FILE__ don't work."
docstring interactive type))
)

;;;###autoload
(defun find-file-noselect-relative (filename &optional nowarn rawfile wildcards)
"Read relative FILENAME into a buffer and return the buffer.
If a buffer exists visiting FILENAME, return that one, but
verify that the file has not changed since visited or saved.
The buffer is not selected, just returned to the caller.
Optional second arg NOWARN non-nil means suppress any warning messages.
Optional third arg RAWFILE non-nil means the file is read literally.
Optional fourth arg WILDCARDS non-nil means do wildcard processing
and visit all the matching files. When wildcards are actually
used and expanded, return a list of buffers that are visiting
the various files."
(find-file-noselect (relative-expand-file-name filename)
nowarn rawfile wildcards))

;;;###autoload
(defmacro with-relative-file (file &rest body)
"Read relative FILE into a temporary buffer and evaluated BODY
in this buffer."
(declare (indent 1) (debug t))
`(with-current-buffer
(find-file-noselect-relative ,file)
,@body))

;;;###autoload
(defun load-relative (file-or-list &optional symbol)
"Load an Emacs Lisp file relative to Emacs Lisp code that is in
Expand Down

0 comments on commit 267e9c3

Please sign in to comment.