* lisp/minibuffer.el (completion-category-defaults)
Use 'substring' completion style for 'xref-location' category by
default.
* lisp/progmodes/xref.el (xref-show-definitions-completing-read):
Assign the 'xref-location' category to the completions. Pass
REQUIRE-MATCH=t.
;; A new style that combines substring and pcm might be better,
;; e.g. one that does not anchor to bos.
(project-file (styles . (substring)))
+ (xref-location (styles . (substring)))
(info-menu (styles . (basic substring))))
"Default settings for specific completion categories.
Each entry has the shape (CATEGORY . ALIST) where ALIST is
(setq xref (if (not (cdr xrefs))
(car xrefs)
- (cdr (assoc (completing-read "Jump to definition: "
- (reverse xref-alist-with-line-info))
- xref-alist-with-line-info))))
+ (let* ((collection (reverse xref-alist-with-line-info))
+ (ctable
+ (lambda (string pred action)
+ (cond
+ ((eq action 'metadata)
+ '(metadata . ((category . xref-location))))
+ (t
+ (complete-with-action action collection string pred))))))
+ (cdr (assoc (completing-read "Choose definition: "
+ ctable nil t)
+ collection)))))
(xref-pop-to-location xref (assoc-default 'display-action alist))))