Function: info-xref-with-file
info-xref-with-file is a macro defined in info-xref.el.gz.
Signature
(info-xref-with-file FILENAME &rest BODY)
Documentation
Evaluate BODY in a buffer containing the contents of FILENAME.
If FILENAME is already in a buffer then that's used, otherwise a temporary buffer.
The current implementation uses insert-file-contents rather
than find-file-noselect so as not to be held up by queries
about local variables or possible weirdness in a major mode.
lm-with-file does a similar thing, but it sets
emacs-lisp-mode which is not wanted here.
Source Code
;; Defined in /usr/src/emacs/lisp/info-xref.el.gz
(defmacro info-xref-with-file (filename &rest body)
;; checkdoc-params: (filename body)
"Evaluate BODY in a buffer containing the contents of FILENAME.
If FILENAME is already in a buffer then that's used, otherwise a
temporary buffer.
The current implementation uses `insert-file-contents' rather
than `find-file-noselect' so as not to be held up by queries
about local variables or possible weirdness in a major mode.
`lm-with-file' does a similar thing, but it sets
`emacs-lisp-mode' which is not wanted here."
(declare (debug (form def-body)) (indent 1))
`(let* ((info-xref-with-file--filename ,filename)
(info-xref-with-file--body (lambda () ,@body))
(info-xref-with-file--existing
(find-buffer-visiting info-xref-with-file--filename)))
(if info-xref-with-file--existing
(with-current-buffer info-xref-with-file--existing
(save-excursion
(funcall info-xref-with-file--body)))
(with-temp-buffer
(insert-file-contents ,filename)
(funcall info-xref-with-file--body)))))