diff options
author | Richard M. Stallman <rms@gnu.org> | 2003-09-22 15:23:53 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2003-09-22 15:23:53 +0000 |
commit | a94d391acd3059662f2c47620a6f85940db63a49 (patch) | |
tree | 1b78079bf1b6be77bbdc93b98416c9deae902d58 /lisp/emacs-lisp | |
parent | 9dbd7d667468d1c162ded576e2eb19b9cb3e91da (diff) | |
download | emacs-a94d391acd3059662f2c47620a6f85940db63a49.tar.gz emacs-a94d391acd3059662f2c47620a6f85940db63a49.tar.bz2 emacs-a94d391acd3059662f2c47620a6f85940db63a49.zip |
(lm-with-file): Don't visit the file,
just use insert-file-contents in temp buffer.
(lm-get-header-re): Added surrounding \\( and \\) around the header,
as in for lm-history-header 'Change Log\\|History'.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/lisp-mnt.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index d8593442620..893d95db05c 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -180,8 +180,8 @@ Leading comment characters and whitespace should be in regexp group 1." If called with optional MODE and with value `section', return section regexp instead." (if (eq mode 'section) - (concat "^;;;;* " header ":[ \t]*$") - (concat lm-header-prefix header "[ \t]*:[ \t]*"))) + (concat "^;;;;* \\(" header "\\):[ \t]*$") + (concat lm-header-prefix "\\(" header "\\)[ \t]*:[ \t]*"))) (defun lm-get-package-name () "Return package name by looking at the first line." @@ -296,15 +296,14 @@ The returned value is a list of strings, one per line." ;; These give us smart access to the header fields and commentary (defmacro lm-with-file (file &rest body) - "Make a buffer with FILE current, and execute BODY. -If FILE isn't in a buffer, load it in, and kill it after BODY is executed." + "Execute BODY in a buffer containing the contents of FILE. +If FILE is nil, just return nil." (let ((filesym (make-symbol "file"))) - `(save-excursion - (let ((,filesym ,file)) - (if ,filesym (set-buffer (find-file-noselect ,filesym))) - (prog1 (progn ,@body) - (if (and ,filesym (not (get-buffer-window (current-buffer) t))) - (kill-buffer (current-buffer)))))))) + `(let ((,filesym ,file)) + (when ,filesym + (with-temp-buffer + (insert-file-contents ,filesym) + ,@body))))) (put 'lm-with-file 'lisp-indent-function 1) (put 'lm-with-file 'edebug-form-spec t) |