Add basic xref apropos implementation to elisp-mode
* lisp/progmodes/elisp-mode.el (elisp--xref-find-definitions): Filter out nil results. (elisp--xref-find-apropos): New function. (elisp-xref-find): Use it. * lisp/progmodes/xref.el (xref--show-xrefs): Use `user-error'.
This commit is contained in:
parent
f4a6345114
commit
807c3413c4
3 changed files with 42 additions and 19 deletions
|
@ -1,3 +1,14 @@
|
|||
2014-12-26 Dmitry Gutov <dgutov@yandex.ru>
|
||||
|
||||
Add basic xref apropos implementation to elisp-mode.
|
||||
|
||||
* progmodes/elisp-mode.el (elisp--xref-find-definitions):
|
||||
Filter out nil results.
|
||||
(elisp--xref-find-apropos): New function.
|
||||
(elisp-xref-find): Use it.
|
||||
|
||||
* progmodes/xref.el (xref--show-xrefs): Use `user-error'.
|
||||
|
||||
2014-12-25 Helmut Eller <eller.helmut@gmail.com>
|
||||
Dmitry Gutov <dgutov@yandex.ru>
|
||||
|
||||
|
|
|
@ -577,27 +577,39 @@ It can be quoted, or be inside a quoted form."
|
|||
(declare-function xref-make "xref" (description location))
|
||||
|
||||
(defun elisp-xref-find (action id)
|
||||
(when (eq action 'definitions)
|
||||
(let ((sym (intern-soft id)))
|
||||
(when sym
|
||||
(remove nil (elisp--xref-find-definitions sym))))))
|
||||
(pcase action
|
||||
(`definitions
|
||||
(let ((sym (intern-soft id)))
|
||||
(when sym
|
||||
(elisp--xref-find-definitions sym))))
|
||||
(`apropos
|
||||
(elisp--xref-find-apropos id))))
|
||||
|
||||
(defun elisp--xref-find-definitions (symbol)
|
||||
(save-excursion
|
||||
(mapcar
|
||||
(lambda (type)
|
||||
(let ((loc
|
||||
(condition-case err
|
||||
(let ((buf-pos (elisp--identifier-location type symbol)))
|
||||
(when buf-pos
|
||||
(xref-make-buffer-location (car buf-pos)
|
||||
(or (cdr buf-pos) 1))))
|
||||
(error
|
||||
(xref-make-bogus-location (error-message-string err))))))
|
||||
(when loc
|
||||
(xref-make (format "(%s %s)" type symbol)
|
||||
loc))))
|
||||
elisp--identifier-types)))
|
||||
(let (lst)
|
||||
(dolist (type elisp--identifier-types)
|
||||
(let ((loc
|
||||
(condition-case err
|
||||
(let ((buf-pos (elisp--identifier-location type symbol)))
|
||||
(when buf-pos
|
||||
(xref-make-buffer-location (car buf-pos)
|
||||
(or (cdr buf-pos) 1))))
|
||||
(error
|
||||
(xref-make-bogus-location (error-message-string err))))))
|
||||
(when loc
|
||||
(push
|
||||
(xref-make (format "(%s %s)" type symbol)
|
||||
loc)
|
||||
lst))))
|
||||
lst)))
|
||||
|
||||
(defun elisp--xref-find-apropos (regexp)
|
||||
(apply #'nconc
|
||||
(let (lst)
|
||||
(dolist (sym (apropos-internal regexp))
|
||||
(push (elisp--xref-find-definitions sym) lst))
|
||||
(nreverse lst))))
|
||||
|
||||
(defun elisp--xref-identifier-completion-table ()
|
||||
elisp--identifier-completion-table)
|
||||
|
|
|
@ -414,7 +414,7 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
|
|||
(defun xref--show-xrefs (id kind xrefs window)
|
||||
(cond
|
||||
((null xrefs)
|
||||
(error "No known %s for: %s" kind id))
|
||||
(user-error "No known %s for: %s" kind id))
|
||||
((not (cdr xrefs))
|
||||
(xref-push-marker-stack)
|
||||
(xref--pop-to-location (xref--xref-location (car xrefs)) window))
|
||||
|
|
Loading…
Add table
Reference in a new issue