Function: server-visit-files
server-visit-files is a byte-compiled function defined in
server.el.gz.
Signature
(server-visit-files FILES PROC &optional NOWAIT)
Documentation
Find FILES and return a list of buffers created.
If some file was deleted since last visited, offer to save its buffer. FILES is an alist whose elements are (FILENAME . FILEPOS) where FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER). PROC is the client that requested this operation. NOWAIT non-nil means this client is not waiting for the results, so don't mark these buffers specially, just visit them normally.
This function has :after advice: server-visit-files@with-editor-file-name-history-exclude.
This function has :around advice: org--protocol-detect-protocol-server.
Source Code
;; Defined in /usr/src/emacs/lisp/server.el.gz
(defun server-visit-files (files proc &optional nowait)
"Find FILES and return a list of buffers created.
If some file was deleted since last visited, offer to save its buffer.
FILES is an alist whose elements are (FILENAME . FILEPOS)
where FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).
PROC is the client that requested this operation.
NOWAIT non-nil means this client is not waiting for the results,
so don't mark these buffers specially, just visit them normally."
;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries.
(let ((last-nonmenu-event t) client-record)
;; Restore the current buffer afterward, but not using save-excursion,
;; because we don't want to save point in this buffer
;; if it happens to be one of those specified by the server.
(save-current-buffer
(dolist (file files)
;; If there is an existing buffer modified or the file is
;; modified, revert it. If there is an existing buffer with
;; deleted file, offer to write it.
(let* ((minibuffer-auto-raise (or server-raise-frame
minibuffer-auto-raise))
(filen (car file))
(obuf (get-file-buffer filen)))
(file-name-history--add filen)
(if (null obuf)
(progn
(run-hooks 'pre-command-hook)
(set-buffer (find-file-noselect filen)))
(set-buffer obuf)
;; separately for each file, in sync with post-command hooks,
;; with the new buffer current:
(run-hooks 'pre-command-hook)
(cond ((file-exists-p filen)
(when (not (verify-visited-file-modtime obuf))
(revert-buffer t nil)))
;; Only ask the question if the file did exist at some
;; point, but was deleted since.
((listp (visited-file-modtime))
(when (y-or-n-p
(concat "File no longer exists: " filen
", write buffer to file? "))
(write-file filen))))
(unless server-buffer-clients
(setq server-existing-buffer t)))
(server-goto-line-column (cdr file))
(run-hooks 'server-visit-hook)
;; hooks may be specific to current buffer:
(run-hooks 'post-command-hook))
(unless nowait
;; When the buffer is killed, inform the clients.
(add-hook 'kill-buffer-hook #'server-kill-buffer nil t)
(push proc server-buffer-clients))
(push (current-buffer) client-record)))
(unless nowait
(process-put proc 'buffers
(nconc (process-get proc 'buffers) client-record)))
client-record))