From: Dmitry Gutov Date: Fri, 26 Dec 2014 16:34:47 +0000 (+0200) Subject: Add basic xref apropos implementation to elisp-mode X-Git-Tag: emacs-25.0.90~2634^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=807c3413c478be964f24b5ecc44712ce3358001e;p=emacs.git 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'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a2bee149b7f..4c6b23dac0b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2014-12-26 Dmitry Gutov + + 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 Dmitry Gutov diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index e73c20df263..ef619f0899a 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -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) diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 02e02de4e9e..21c0d6aa6a4 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -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))