# HG changeset patch # User Richard M. Stallman # Date 1064244233 0 # Node ID e4693bed89ad4f5ebaed14cb3457bbdc8c9c5b32 # Parent 993d4afcd6d0016b8daf52f0c9c8d26b25bc7632 (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'. diff -r 993d4afcd6d0 -r e4693bed89ad lisp/emacs-lisp/lisp-mnt.el --- a/lisp/emacs-lisp/lisp-mnt.el Mon Sep 22 15:16:10 2003 +0000 +++ b/lisp/emacs-lisp/lisp-mnt.el Mon Sep 22 15:23:53 2003 +0000 @@ -180,8 +180,8 @@ 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 @@ ;; 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)