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.
This commit is contained in:
parent
4df0c1c6c4
commit
e898442be3
3 changed files with 24 additions and 11 deletions
4
etc/NEWS
4
etc/NEWS
|
@ -1458,6 +1458,10 @@ A new command 'xref-revert-buffer' is bound to 'g'.
|
||||||
---
|
---
|
||||||
*** Imenu support has been added to 'xref--xref-buffer-mode'.
|
*** Imenu support has been added to 'xref--xref-buffer-mode'.
|
||||||
|
|
||||||
|
*** New generic method 'xref-backend-identifier-completion-ignore-case'.
|
||||||
|
Using it, the etags backend now honors 'tags-case-fold-search' during
|
||||||
|
identifier completion.
|
||||||
|
|
||||||
** Checkdoc
|
** Checkdoc
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
@ -60,7 +60,8 @@ Any other value means use the setting of `case-fold-search'."
|
||||||
:type '(choice (const :tag "Case-sensitive" nil)
|
:type '(choice (const :tag "Case-sensitive" nil)
|
||||||
(const :tag "Case-insensitive" t)
|
(const :tag "Case-insensitive" t)
|
||||||
(other :tag "Use default" default))
|
(other :tag "Use default" default))
|
||||||
:version "21.1")
|
:version "21.1"
|
||||||
|
:safe 'symbolp)
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
;; Use `visit-tags-table-buffer' to cycle through tags tables in this list.
|
;; 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."
|
||||||
"Using tags, return a completion table for the text around point.
|
"Using tags, return a completion table for the text around point.
|
||||||
If no tags table is loaded, do nothing and return nil."
|
If no tags table is loaded, do nothing and return nil."
|
||||||
(when (or tags-table-list tags-file-name)
|
(when (or tags-table-list tags-file-name)
|
||||||
(let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
|
(let ((completion-ignore-case (find-tag--completion-ignore-case))
|
||||||
tags-case-fold-search
|
|
||||||
case-fold-search))
|
|
||||||
(pattern (find-tag--default))
|
(pattern (find-tag--default))
|
||||||
beg)
|
beg)
|
||||||
(when pattern
|
(when pattern
|
||||||
|
@ -836,9 +835,7 @@ If no tags table is loaded, do nothing and return nil."
|
||||||
|
|
||||||
(defun find-tag-tag (string)
|
(defun find-tag-tag (string)
|
||||||
"Read a tag name, with defaulting and completion."
|
"Read a tag name, with defaulting and completion."
|
||||||
(let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
|
(let* ((completion-ignore-case (find-tag--completion-ignore-case))
|
||||||
tags-case-fold-search
|
|
||||||
case-fold-search))
|
|
||||||
(default (find-tag--default))
|
(default (find-tag--default))
|
||||||
(spec (completing-read (if default
|
(spec (completing-read (if default
|
||||||
(format "%s (default %s): "
|
(format "%s (default %s): "
|
||||||
|
@ -851,6 +848,11 @@ If no tags table is loaded, do nothing and return nil."
|
||||||
(or default (user-error "There is no default tag"))
|
(or default (user-error "There is no default tag"))
|
||||||
spec)))
|
spec)))
|
||||||
|
|
||||||
|
(defun find-tag--completion-ignore-case ()
|
||||||
|
(if (memq tags-case-fold-search '(t nil))
|
||||||
|
tags-case-fold-search
|
||||||
|
case-fold-search))
|
||||||
|
|
||||||
(defun find-tag--default ()
|
(defun find-tag--default ()
|
||||||
(funcall (or find-tag-default-function
|
(funcall (or find-tag-default-function
|
||||||
(get major-mode 'find-tag-default-function)
|
(get major-mode 'find-tag-default-function)
|
||||||
|
@ -2072,6 +2074,9 @@ file name, add `tag-partial-file-name-match-p' to the list value.")
|
||||||
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
|
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
|
||||||
(tags-lazy-completion-table))
|
(tags-lazy-completion-table))
|
||||||
|
|
||||||
|
(cl-defmethod xref-backend-identifier-completion-ignore-case ((_backend (eql etags)))
|
||||||
|
(find-tag--completion-ignore-case))
|
||||||
|
|
||||||
(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol)
|
(cl-defmethod xref-backend-definitions ((_backend (eql etags)) symbol)
|
||||||
(etags--xref-find-definitions symbol))
|
(etags--xref-find-definitions symbol))
|
||||||
|
|
||||||
|
@ -2086,9 +2091,7 @@ file name, add `tag-partial-file-name-match-p' to the list value.")
|
||||||
(first-time t)
|
(first-time t)
|
||||||
(search-fun (if regexp? #'re-search-forward #'search-forward))
|
(search-fun (if regexp? #'re-search-forward #'search-forward))
|
||||||
(marks (make-hash-table :test 'equal))
|
(marks (make-hash-table :test 'equal))
|
||||||
(case-fold-search (if (memq tags-case-fold-search '(nil t))
|
(case-fold-search (find-tag--completion-ignore-case))
|
||||||
tags-case-fold-search
|
|
||||||
case-fold-search))
|
|
||||||
(cbuf (current-buffer)))
|
(cbuf (current-buffer)))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(while (visit-tags-table-buffer (not first-time) cbuf)
|
(while (visit-tags-table-buffer (not first-time) cbuf)
|
||||||
|
|
|
@ -287,6 +287,10 @@ recognize and then delegate the work to an external process."
|
||||||
(cl-defgeneric xref-backend-identifier-completion-table (backend)
|
(cl-defgeneric xref-backend-identifier-completion-table (backend)
|
||||||
"Return the completion table for identifiers.")
|
"Return the completion table for identifiers.")
|
||||||
|
|
||||||
|
(cl-defgeneric xref-backend-identifier-completion-ignore-case (_backend)
|
||||||
|
"Return t if case is not significant in identifier completion."
|
||||||
|
completion-ignore-case)
|
||||||
|
|
||||||
|
|
||||||
;;; misc utilities
|
;;; misc utilities
|
||||||
(defun xref--alistify (list key test)
|
(defun xref--alistify (list key test)
|
||||||
|
@ -967,7 +971,9 @@ Accepts the same arguments as `xref-show-xrefs-function'."
|
||||||
(defun xref--read-identifier (prompt)
|
(defun xref--read-identifier (prompt)
|
||||||
"Return the identifier at point or read it from the minibuffer."
|
"Return the identifier at point or read it from the minibuffer."
|
||||||
(let* ((backend (xref-find-backend))
|
(let* ((backend (xref-find-backend))
|
||||||
(def (xref-backend-identifier-at-point backend)))
|
(def (xref-backend-identifier-at-point backend))
|
||||||
|
(completion-ignore-case
|
||||||
|
(xref-backend-identifier-completion-ignore-case backend)))
|
||||||
(cond ((or current-prefix-arg
|
(cond ((or current-prefix-arg
|
||||||
(not def)
|
(not def)
|
||||||
(xref--prompt-p this-command))
|
(xref--prompt-p this-command))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue