+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>
(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)