aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2020-01-18 00:14:24 +0300
committerDmitry Gutov2020-01-18 00:23:46 +0300
commite898442be343588c2be9638b1684856dbc898ab9 (patch)
tree46e56a5a9190e8f69608fa36a0f9e4b66f6d3c7d
parent4df0c1c6c4627e83ba3b2a76ce618af6ef180a57 (diff)
downloademacs-e898442be343588c2be9638b1684856dbc898ab9.tar.gz
emacs-e898442be343588c2be9638b1684856dbc898ab9.zip
Honor tags-case-fold-search during xref identifer completion
* etc/NEWS: New entry. * lisp/progmodes/etags.el (tags-case-fold-search): Mark as safe-local. (find-tag--completion-ignore-case): Extract from tags-completion-at-point-function, find-tag-tag and etags--xref-find-definitions. (xref-backend-identifier-completion-ignore-case): New method. Use it here as well. * lisp/progmodes/xref.el (xref-backend-identifier-completion-ignore-case): New generic. (xref--read-identifier): Use it here.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/progmodes/etags.el23
-rw-r--r--lisp/progmodes/xref.el8
3 files changed, 24 insertions, 11 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 69ffcdb66e5..1494fab47a8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1458,6 +1458,10 @@ A new command 'xref-revert-buffer' is bound to 'g'.
1458--- 1458---
1459*** Imenu support has been added to 'xref--xref-buffer-mode'. 1459*** Imenu support has been added to 'xref--xref-buffer-mode'.
1460 1460
1461*** New generic method 'xref-backend-identifier-completion-ignore-case'.
1462Using it, the etags backend now honors 'tags-case-fold-search' during
1463identifier completion.
1464
1461** Checkdoc 1465** Checkdoc
1462 1466
1463--- 1467---
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index fe64895725f..897f105019e 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -60,7 +60,8 @@ Any other value means use the setting of `case-fold-search'."
60 :type '(choice (const :tag "Case-sensitive" nil) 60 :type '(choice (const :tag "Case-sensitive" nil)
61 (const :tag "Case-insensitive" t) 61 (const :tag "Case-insensitive" t)
62 (other :tag "Use default" default)) 62 (other :tag "Use default" default))
63 :version "21.1") 63 :version "21.1"
64 :safe 'symbolp)
64 65
65;;;###autoload 66;;;###autoload
66;; Use `visit-tags-table-buffer' to cycle through tags tables in this list. 67;; Use `visit-tags-table-buffer' to cycle through tags tables in this list.
@@ -819,9 +820,7 @@ tags table for BUF and its (recursively) included tags tables."
819 "Using tags, return a completion table for the text around point. 820 "Using tags, return a completion table for the text around point.
820If no tags table is loaded, do nothing and return nil." 821If no tags table is loaded, do nothing and return nil."
821 (when (or tags-table-list tags-file-name) 822 (when (or tags-table-list tags-file-name)
822 (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) 823 (let ((completion-ignore-case (find-tag--completion-ignore-case))
823 tags-case-fold-search
824 case-fold-search))
825 (pattern (find-tag--default)) 824 (pattern (find-tag--default))
826 beg) 825 beg)
827 (when pattern 826 (when pattern
@@ -836,9 +835,7 @@ If no tags table is loaded, do nothing and return nil."
836 835
837(defun find-tag-tag (string) 836(defun find-tag-tag (string)
838 "Read a tag name, with defaulting and completion." 837 "Read a tag name, with defaulting and completion."
839 (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) 838 (let* ((completion-ignore-case (find-tag--completion-ignore-case))
840 tags-case-fold-search
841 case-fold-search))
842 (default (find-tag--default)) 839 (default (find-tag--default))
843 (spec (completing-read (if default 840 (spec (completing-read (if default
844 (format "%s (default %s): " 841 (format "%s (default %s): "
@@ -851,6 +848,11 @@ If no tags table is loaded, do nothing and return nil."
851 (or default (user-error "There is no default tag")) 848 (or default (user-error "There is no default tag"))
852 spec))) 849 spec)))
853 850
851(defun find-tag--completion-ignore-case ()
852 (if (memq tags-case-fold-search '(t nil))
853 tags-case-fold-search
854 case-fold-search))
855
854(defun find-tag--default () 856(defun find-tag--default ()
855 (funcall (or find-tag-default-function 857 (funcall (or find-tag-default-function
856 (get major-mode 'find-tag-default-function) 858 (get major-mode 'find-tag-default-function)
@@ -2072,6 +2074,9 @@ file name, add `tag-partial-file-name-match-p' to the list value.")
2072(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags))) 2074(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
2073 (tags-lazy-completion-table)) 2075 (tags-lazy-completion-table))
2074 2076
2077(cl-defmethod xref-backend-identifier-completion-ignore-case ((_backend (eql etags)))
2078 (find-tag--completion-ignore-case))
2079
2075(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol) 2080(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol)
2076 (etags--xref-find-definitions symbol)) 2081 (etags--xref-find-definitions symbol))
2077 2082
@@ -2086,9 +2091,7 @@ file name, add `tag-partial-file-name-match-p' to the list value.")
2086 (first-time t) 2091 (first-time t)
2087 (search-fun (if regexp? #'re-search-forward #'search-forward)) 2092 (search-fun (if regexp? #'re-search-forward #'search-forward))
2088 (marks (make-hash-table :test 'equal)) 2093 (marks (make-hash-table :test 'equal))
2089 (case-fold-search (if (memq tags-case-fold-search '(nil t)) 2094 (case-fold-search (find-tag--completion-ignore-case))
2090 tags-case-fold-search
2091 case-fold-search))
2092 (cbuf (current-buffer))) 2095 (cbuf (current-buffer)))
2093 (save-excursion 2096 (save-excursion
2094 (while (visit-tags-table-buffer (not first-time) cbuf) 2097 (while (visit-tags-table-buffer (not first-time) cbuf)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 4fbcd08506b..1a344563405 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -287,6 +287,10 @@ recognize and then delegate the work to an external process."
287(cl-defgeneric xref-backend-identifier-completion-table (backend) 287(cl-defgeneric xref-backend-identifier-completion-table (backend)
288 "Return the completion table for identifiers.") 288 "Return the completion table for identifiers.")
289 289
290(cl-defgeneric xref-backend-identifier-completion-ignore-case (_backend)
291 "Return t if case is not significant in identifier completion."
292 completion-ignore-case)
293
290 294
291;;; misc utilities 295;;; misc utilities
292(defun xref--alistify (list key test) 296(defun xref--alistify (list key test)
@@ -967,7 +971,9 @@ Accepts the same arguments as `xref-show-xrefs-function'."
967(defun xref--read-identifier (prompt) 971(defun xref--read-identifier (prompt)
968 "Return the identifier at point or read it from the minibuffer." 972 "Return the identifier at point or read it from the minibuffer."
969 (let* ((backend (xref-find-backend)) 973 (let* ((backend (xref-find-backend))
970 (def (xref-backend-identifier-at-point backend))) 974 (def (xref-backend-identifier-at-point backend))
975 (completion-ignore-case
976 (xref-backend-identifier-completion-ignore-case backend)))
971 (cond ((or current-prefix-arg 977 (cond ((or current-prefix-arg
972 (not def) 978 (not def)
973 (xref--prompt-p this-command)) 979 (xref--prompt-p this-command))