From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: master b02c9bc: Improve documentation of new Xref options Date: Wed, 8 Sep 2021 03:24:12 +0300 Message-ID: <9aef615d-039a-0c9f-fda7-f3fb11db9d47@yandex.ru> References: <20210907130400.31609.90502@vcs0.savannah.gnu.org> <20210907130401.D074320A10@vcs0.savannah.gnu.org> <83a6kopeye.fsf@gnu.org> <8335qgpd64.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------80F4CDF9283A7E0D05B12E71" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38650"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 08 02:26:19 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mNlPt-0009uM-Re for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Sep 2021 02:26:17 +0200 Original-Received: from localhost ([::1]:51268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNlPs-0003Uv-2V for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Sep 2021 20:26:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNlNy-0002gY-Qq for emacs-devel@gnu.org; Tue, 07 Sep 2021 20:24:19 -0400 Original-Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:42670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNlNw-0000UP-TS; Tue, 07 Sep 2021 20:24:18 -0400 Original-Received: by mail-wm1-x32d.google.com with SMTP id u19-20020a7bc053000000b002f8d045b2caso212601wmc.1; Tue, 07 Sep 2021 17:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=polUUBSXIrPDzfaLNvwqbV1n9CXzdzzfIg2axajAqqs=; b=clYEbSqQVumoomxJjrhyZRnC/4Y9uj/zd/6PQUlUwp1bCsNn/xJ+b1l/5U8ClY0iDN f8Qwjcvyr+c62Mblv87EkDyZopc1CGpIbLwkO3uhUaaNC6tQqq2C9hXOxm+dEdGScz4v o2E/4ShaiQZDzpu/7bLMS+M6rYyn7j6CeOMzbOVgpAjWFc2RMDsHAGdKbYo5+hfjz0vD AQxjX47U80DCB80zZu6HWt02gkJxjTTzJxUwxE10y8mB8Onz/7ggv13jpuG3P55A6tMv hrEwOhC+YpMxzuAwbciOfOhShQnA0B0tBG00zuR+sOHv/LGY4NFD4qiTHLn+8quPKlaH P+qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=polUUBSXIrPDzfaLNvwqbV1n9CXzdzzfIg2axajAqqs=; b=EnXiYBlZtfpq+c6onLqFQdDGa9pr37ckdmDDDqezTxEP0KVO/iUNctxkDWsbzFEj4P O81woxgHAzlJ63khgsb4Ar7/+c5hTNvO7OwJ2ZDy+uc/UXcosrizRMdTmCd7q5W3Jcwa smJP/+e87ZozjySVBQpxqTnXKW75qCVnAmrNFPtMTzI1Xm/Y68vgcgrQ3HIsPdug5u25 EwlX3Ea5oAOzZfM5BnvZ22cdbtsLCRWZ1Jcj/nHwmZ/cPvt9VMEp7QNtpfC065IX3U+7 uQB4Lp0B5muZMVFBcKD+OoRACHfj5gR4Sfve5Sa1GzzjDch0rfTX5icYZ1xqbYlSBbBL Ez1g== X-Gm-Message-State: AOAM532WA0HQfoY1RyvRPA33YwpS0CE925ytXi1KwQKVa7OiW2IQ4LJZ 96Y5mjDOkM5Vtz6fD7msVeFGqGfDxjs= X-Google-Smtp-Source: ABdhPJxMi/B38Rst6SWSbAVTNBqjrv9gBBMVjmdUn0muB1lJalTxfwZdSXA87BO2ViS0D+WjPy2VGA== X-Received: by 2002:a05:600c:3641:: with SMTP id y1mr751830wmq.181.1631060654968; Tue, 07 Sep 2021 17:24:14 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n1sm444825wrp.49.2021.09.07.17.24.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Sep 2021 17:24:14 -0700 (PDT) In-Reply-To: <8335qgpd64.fsf@gnu.org> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-2.332, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:274298 Archived-At: This is a multi-part message in MIME format. --------------80F4CDF9283A7E0D05B12E71 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------80F4CDF9283A7E0D05B12E71 Content-Type: text/x-patch; charset=UTF-8; name="xref-emacs-additional-apropos.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xref-emacs-additional-apropos.diff" 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)))) + (provide 'etags) --------------80F4CDF9283A7E0D05B12E71--