[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 267e9c3 04/14: New functions for opening files.

From: Rocky Bernstein
Subject: [elpa] master 267e9c3 04/14: New functions for opening files.
Date: Wed, 25 Feb 2015 01:24:38 +0000

branch: master
commit 267e9c382addeace22f46adefe654198aaf921e5
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    New functions for opening files.
    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.
 load-relative.el |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/load-relative.el b/load-relative.el
index 16661bc..6fac96f 100644
--- a/load-relative.el
+++ b/load-relative.el
@@ -180,6 +180,30 @@ finding __FILE__ don't work."
+(defun find-file-noselect-relative (filename &optional nowarn rawfile 
+  "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))
+(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))
 (defun load-relative (file-or-list &optional symbol)
   "Load an Emacs Lisp file relative to Emacs Lisp code that is in
 the process of being loaded or eval'd.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]