Function: reftex-get-file-buffer-force
reftex-get-file-buffer-force is a byte-compiled function defined in
reftex.el.gz.
Signature
(reftex-get-file-buffer-force FILE &optional MARK-TO-KILL)
Documentation
Return a buffer visiting file. Make one, if necessary.
If neither such a buffer nor the file exist, return nil.
If MARK-TO-KILL is t and there is no live buffer, visit the file with
initializations according to reftex-initialize-temporary-buffers,
and mark the buffer to be killed after use.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/reftex.el.gz
(defun reftex-get-file-buffer-force (file &optional mark-to-kill)
"Return a buffer visiting file. Make one, if necessary.
If neither such a buffer nor the file exist, return nil.
If MARK-TO-KILL is t and there is no live buffer, visit the file with
initializations according to `reftex-initialize-temporary-buffers',
and mark the buffer to be killed after use."
(let ((buf (if (bufferp file)
file
(find-buffer-visiting file))))
(cond (buf
;; We have it already as a buffer - just return it
buf)
((file-readable-p file)
;; At least there is such a file and we can read it.
(if (or (not mark-to-kill)
(eq t reftex-initialize-temporary-buffers))
;; Visit the file with full magic
(setq buf (find-file-noselect file))
;; Else: Visit the file just briefly, without or
;; with limited Magic
;; The magic goes away
(cl-letf ((format-alist nil)
(auto-mode-alist (reftex-auto-mode-alist))
((default-value 'major-mode) 'fundamental-mode)
(enable-local-variables nil)
(after-insert-file-functions nil))
(setq buf (find-file-noselect file)))
;; Is there a hook to run?
(when (listp reftex-initialize-temporary-buffers)
(with-current-buffer buf
(run-hooks 'reftex-initialize-temporary-buffers))))
;; Let's see if we got a license to kill :-|
(and mark-to-kill
(cl-pushnew buf reftex-buffers-to-kill))
;; Return the new buffer
buf)
;; If no such file exists, return nil
(t nil))))