aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2015-05-26 19:28:38 +0300
committerDmitry Gutov2015-05-26 19:28:38 +0300
commitd86ef9fc4a45bd1f3c79c4814b9e1e545ce0a07c (patch)
tree7b883155e5b125e31fc070b730a405cdba69db53
parent53bedd3a8eb7169b734ee8925c76712c68d9c4fc (diff)
downloademacs-d86ef9fc4a45bd1f3c79c4814b9e1e545ce0a07c.tar.gz
emacs-d86ef9fc4a45bd1f3c79c4814b9e1e545ce0a07c.zip
xref-prompt-for-identifier: Use a list value
* lisp/progmodes/xref.el (xref-prompt-for-identifier): Allow list value, to be interpreted as a list of commands. (xref--prompt-p): New function. (xref--read-identifier): Use it.
-rw-r--r--lisp/progmodes/xref.el36
1 files changed, 30 insertions, 6 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 3bb4fde0d0c..c9bffc6fc6f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -283,13 +283,25 @@ backward."
283 :type 'integer 283 :type 'integer
284 :version "25.1") 284 :version "25.1")
285 285
286(defcustom xref-prompt-for-identifier nil 286(defcustom xref-prompt-for-identifier '(not xref-find-definitions
287 "When non-nil, always prompt for the identifier name. 287 xref-find-definitions-other-window
288 xref-find-definitions-other-frame)
289 "When t, always prompt for the identifier name.
288 290
289Otherwise, only prompt when there's no value at point we can use, 291When nil, prompt only when there's no value at point we can use,
290or when the command has been called with the prefix argument." 292or when the command has been called with the prefix argument.
293
294Otherwise, it's a list of xref commands which will prompt
295anyway (the value at point, if any, will be used as the default).
296
297If the list starts with `not', the meaning of the rest of the
298elements is negated."
291 :type '(choice (const :tag "always" t) 299 :type '(choice (const :tag "always" t)
292 (const :tag "auto" nil)) 300 (const :tag "auto" nil)
301 (set :menu-tag "command specific" :tag "commands"
302 :value (not)
303 (const :tag "Except" not)
304 (repeat :inline t (symbol :tag "command"))))
293 :version "25.1") 305 :version "25.1")
294 306
295(defcustom xref-pulse-on-jump t 307(defcustom xref-pulse-on-jump t
@@ -621,10 +633,18 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
621 `((window . ,window) 633 `((window . ,window)
622 (temporary-buffers . ,tb))))))) 634 (temporary-buffers . ,tb)))))))
623 635
636(defun xref--prompt-p (command)
637 (or (eq xref-prompt-for-identifier t)
638 (if (eq (car xref-prompt-for-identifier) 'not)
639 (not (memq command (cdr xref-prompt-for-identifier)))
640 (memq command xref-prompt-for-identifier))))
641
624(defun xref--read-identifier (prompt) 642(defun xref--read-identifier (prompt)
625 "Return the identifier at point or read it from the minibuffer." 643 "Return the identifier at point or read it from the minibuffer."
626 (let ((id (funcall xref-identifier-at-point-function))) 644 (let ((id (funcall xref-identifier-at-point-function)))
627 (cond ((or current-prefix-arg xref-prompt-for-identifier (not id)) 645 (cond ((or current-prefix-arg
646 (not id)
647 (xref--prompt-p this-command))
628 (completing-read prompt 648 (completing-read prompt
629 (funcall xref-identifier-completion-table-function) 649 (funcall xref-identifier-completion-table-function)
630 nil nil nil 650 nil nil nil
@@ -667,6 +687,7 @@ With prefix argument, prompt for the identifier."
667;;;###autoload 687;;;###autoload
668(defun xref-find-regexp (regexp) 688(defun xref-find-regexp (regexp)
669 "Find all matches for REGEXP." 689 "Find all matches for REGEXP."
690 ;; FIXME: Prompt for directory.
670 (interactive (list (xref--read-identifier "Find regexp: "))) 691 (interactive (list (xref--read-identifier "Find regexp: ")))
671 (xref--show-xrefs regexp 'matches regexp nil)) 692 (xref--show-xrefs regexp 'matches regexp nil))
672 693
@@ -736,6 +757,9 @@ details on which tools are used, and when."
736 (cl-assert (directory-name-p dir)) 757 (cl-assert (directory-name-p dir))
737 (when (null kind) 758 (when (null kind)
738 (setq input (regexp-quote input))) 759 (setq input (regexp-quote input)))
760 ;; FIXME: When regexp, search in all files, except
761 ;; `grep-find-ignored-directories' and `grep-find-ignored-files',
762 ;; like `rgrep' does.
739 (let* ((default-directory dir) 763 (let* ((default-directory dir)
740 (semantic-symref-tool 'detect) 764 (semantic-symref-tool 'detect)
741 (res (if (eq kind 'symbol) 765 (res (if (eq kind 'symbol)