From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: master b02c9bc: Improve documentation of new Xref options
Date: Wed, 8 Sep 2021 03:24:12 +0300 [thread overview]
Message-ID: <9aef615d-039a-0c9f-fda7-f3fb11db9d47@yandex.ru> (raw)
In-Reply-To: <8335qgpd64.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 558 bytes --]
On 07.09.2021 19:23, Eli Zaretskii wrote:
>>> No, it's about the features listed after the shown hunk. I just made
>>> its language less extreme, because xref-find-apropos does exist.
>> tags-apropos-additional-actions, then? That seems easier to support.
> Yes, pretty much.
Here's a quick implementation.
But the feature doesn't seem to be particularly popular/polished: the
example value for Elisp, for instance, sets up search across all symbols
(obarray), but subsequent navigation only works for commands, and only
ones documented in the manual.
[-- Attachment #2: xref-emacs-additional-apropos.diff --]
[-- Type: text/x-patch, Size: 2797 bytes --]
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index a1f806ae8c..7efa88546d 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -2096,7 +2096,10 @@ xref-backend-definitions
definitions))
(cl-defmethod xref-backend-apropos ((_backend (eql 'etags)) pattern)
- (etags--xref-find-definitions (xref-apropos-regexp pattern) t))
+ (let ((regexp (xref-apropos-regexp pattern)))
+ (nconc
+ (etags--xref-find-definitions regexp t)
+ (etags--xref-apropos-additional regexp))))
(defun etags--xref-find-definitions (pattern &optional regexp?)
;; This emulates the behavior of `find-tag-in-order' but instead of
@@ -2131,6 +2134,32 @@ etags--xref-find-definitions
(puthash mark-key t marks))))))))))
(nreverse xrefs)))
+(defun etags--xref-apropos-additional (regexp)
+ (cl-mapcan
+ (lambda (oba)
+ (pcase-let* ((`(,group ,goto-fun ,symbs) oba)
+ (res nil)
+ (add-xref (lambda (sym)
+ (let ((sn (symbol-name sym)))
+ (when (string-match-p regexp sn)
+ (push
+ (xref-make
+ sn
+ (xref-make-etags-apropos-location
+ sym goto-fun group))
+ res))))))
+ (when (symbolp symbs)
+ (if (boundp symbs)
+ (setq symbs (symbol-value symbs))
+ (warn "symbol `%s' has no value" symbs)
+ (setq symbs nil))
+ (if (vectorp symbs)
+ (mapatoms add-xref symbs)
+ (dolist (sy symbs)
+ (funcall add-xref (car sy))))
+ (nreverse res))))
+ tags-apropos-additional-actions))
+
(defclass xref-etags-location (xref-location)
((tag-info :type list :initarg :tag-info)
(file :type string :initarg :file
@@ -2155,6 +2184,25 @@ xref-location-line
(with-slots (tag-info) l
(nth 1 tag-info)))
+(defclass xref-etags-apropos-location (xref-location)
+ ((symbol :type symbol :initarg :symbol)
+ (goto-fun :type function :initarg :goto-fun)
+ (group :type string :initarg :group
+ :reader xref-location-group))
+ :documentation "Location of an additional apropos etags symbol.")
+
+(defun xref-make-etags-apropos-location (symbol goto-fun group)
+ (make-instance 'xref-etags-apropos-location
+ :symbol symbol
+ :goto-fun goto-fun
+ :group group))
+
+(cl-defmethod xref-location-marker ((l xref-etags-apropos-location))
+ (save-window-excursion
+ (with-slots (goto-fun symbol) l
+ (funcall goto-fun symbol)
+ (point-marker))))
+
\f
(provide 'etags)
next prev parent reply other threads:[~2021-09-08 0:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210907130400.31609.90502@vcs0.savannah.gnu.org>
[not found] ` <20210907130401.D074320A10@vcs0.savannah.gnu.org>
2021-09-07 15:21 ` master b02c9bc: Improve documentation of new Xref options Dmitry Gutov
2021-09-07 15:45 ` Eli Zaretskii
2021-09-07 16:06 ` Dmitry Gutov
2021-09-07 16:23 ` Eli Zaretskii
2021-09-08 0:24 ` Dmitry Gutov [this message]
2021-09-08 6:18 ` Eli Zaretskii
2021-09-09 1:22 ` Dmitry Gutov
2021-09-09 6:26 ` Eli Zaretskii
2021-09-10 0:18 ` Dmitry Gutov
2021-09-10 12:06 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9aef615d-039a-0c9f-fda7-f3fb11db9d47@yandex.ru \
--to=dgutov@yandex.ru \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.