(defvar-local xref--temporary-buffers nil
"List of buffers created by xref code.")
-(defvar-local xref--selected nil
- "t if the current buffer has ever been selected.
+(defvar-local xref--current nil
+ "Non-nil if this buffer was once current, except while displaying xrefs.
Used for temporary buffers.")
-(defvar xref--inhibit-mark-selected nil)
+(defvar xref--inhibit-mark-current nil)
(defun xref--mark-selected ()
- (unless xref--inhibit-mark-selected
- (setq xref--selected t))
+ (unless xref--inhibit-mark-current
+ (setq xref--current t))
(remove-hook 'buffer-list-update-hook #'xref--mark-selected t))
(defun xref--save-to-history (buf win)
(condition-case err
(let ((xref-buf (current-buffer))
(bl (buffer-list))
- (xref--inhibit-mark-selected t))
+ (xref--inhibit-mark-current t))
(xref--goto-location location)
(let ((buf (current-buffer)))
(unless (memq buf bl)
(setq buffer-read-only t))
(defun xref-quit (&optional kill)
- "Perform cleanup, then quit the current window.
-The cleanup consists of burying all temporarily displayed
-buffers, and if KILL is non-nil, of killing all buffers that were
-created in the process of showing xrefs.
-
-Exceptions are made for buffers switched to by the user in the
-meantime, and other window configuration changes. These are
-preserved."
+ "Bury temporarily displayed buffers, then quit the current window.
+
+If KILL is non-nil, kill all buffers that were created in the
+process of showing xrefs, and also kill the current buffer.
+
+The buffers that the user has otherwise interacted with in the
+meantime are preserved."
(interactive "P")
(let ((window (selected-window))
(history xref--display-history))
(setq xref--display-history nil)
+ (pcase-dolist (`(,buf . ,win) history)
+ (when (and (window-live-p win)
+ (eq buf (window-buffer win)))
+ (quit-window nil win)))
(when kill
- (let ((xref--inhibit-mark-selected t)
+ (let ((xref--inhibit-mark-current t)
kill-buffer-query-functions)
(dolist (buf xref--temporary-buffers)
- (unless (buffer-local-value 'xref--selected buf)
+ (unless (buffer-local-value 'xref--current buf)
(kill-buffer buf)))
(setq xref--temporary-buffers nil)))
- (pcase-dolist (`(,buf . ,win) history)
- (when (and (window-live-p win)
- (eq buf (window-buffer win)))
- (quit-window nil win)))
(quit-window kill window)))
(defconst xref-buffer-name "*xref*"
'face 'font-lock-keyword-face
'mouse-face 'highlight
'keymap xref--button-map
- 'help-echo "mouse-2: display in another window, RET or mouse-1: navigate")
+ 'help-echo
+ (concat "mouse-2: display in another window, "
+ "RET or mouse-1: follow reference"))
description))
(when (or more1 more2)
(insert "\n")))))
(defvar xref-show-xrefs-function 'xref--show-xref-buffer
"Function to display a list of xrefs.")
+(defvar xref--read-identifier-history nil)
+
+(defvar xref--read-pattern-history nil)
+
(defun xref--show-xrefs (input kind arg window)
(let* ((bl (buffer-list))
(xrefs (funcall xref-find-function kind arg))
(cond ((or current-prefix-arg (not id))
(completing-read prompt
(funcall xref-identifier-completion-table-function)
- nil t id))
+ nil t id
+ 'xref--read-identifier-history))
(t id))))
\f
(interactive (list (xref--read-identifier "Find references of: ")))
(xref--show-xrefs identifier 'references identifier nil))
+(declare-function apropos-parse-pattern "apropos" (pattern))
+
;;;###autoload
(defun xref-find-apropos (pattern)
"Find all meaningful symbols that match PATTERN.
The argument has the same meaning as in `apropos'."
(interactive (list (read-from-minibuffer
- "Search for pattern (word list or regexp): ")))
+ "Search for pattern (word list or regexp): "
+ nil nil nil 'xref--read-pattern-history)))
(require 'apropos)
(xref--show-xrefs pattern 'apropos
(apropos-parse-pattern