From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#24309: 25.1; Problem in variable reference in docstrings. Date: Sun, 27 Dec 2020 19:51:08 +0000 Message-ID: <877dp3rpsj.fsf@tcd.ie> References: <87poowfnxh.fsf@reisefreund.localdomain> <83vayndi3p.fsf@gnu.org> <877e4bvxj0.fsf@marxist.se> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4425"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Nathanael Schweers , 24309@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 27 20:52:26 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ktc5Z-00010V-B6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 20:52:25 +0100 Original-Received: from localhost ([::1]:49136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktc5X-0002GH-Qw for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 14:52:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktc5C-0002Fx-UC for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 14:52:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktc5C-0007be-Fy for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 14:52:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ktc5C-000214-E5 for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 14:52:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87poowfnxh.fsf@reisefreund.localdomain> Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Dec 2020 19:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24309 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 24309-submit@debbugs.gnu.org id=B24309.16090986787693 (code B ref 24309); Sun, 27 Dec 2020 19:52:02 +0000 Original-Received: (at 24309) by debbugs.gnu.org; 27 Dec 2020 19:51:18 +0000 Original-Received: from localhost ([127.0.0.1]:33584 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktc4U-0001zv-5A for submit@debbugs.gnu.org; Sun, 27 Dec 2020 14:51:18 -0500 Original-Received: from mail-wr1-f53.google.com ([209.85.221.53]:40965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktc4S-0001zZ-Cx for 24309@debbugs.gnu.org; Sun, 27 Dec 2020 14:51:17 -0500 Original-Received: by mail-wr1-f53.google.com with SMTP id a12so8778576wrv.8 for <24309@debbugs.gnu.org>; Sun, 27 Dec 2020 11:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version; bh=v4B2kSgf0eQf4bEvi5kmTOdzFsjQ+q0lt0/Temd5qOQ=; b=xWJCSN2bBoVDPCHNP3i16R6q63I0hfx+yO3nwj0rYFQIL2bL3KpaH9jvxRNMbnCoUE wzz3ZeVNjQBWKRuaYzykfPpmP6CfSHLkSu5BTbPmLB6CKw7NpiZEKwnjliDSU9LRVFnq 6MoJLMhtZhK94wiK2VXKFVRs1Wg0GKQ6VzCKaOd6iCUGvAb9f1ZJAjBv1Mssg7aYcwve saUHXJ0ZTQ5KbbL/pjpoSSOh5pWIUbY9dfsZb9c1M+QVVKSSXGBsLmaJXjNR91/8OqjE yr5Nll/TEmmHVZVukxYVH1MOUnAdavu44J6W46xP7WXRvb9ryvC9C0ytUp8rgOjdP11r Ou2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:message-id :user-agent:mime-version; bh=v4B2kSgf0eQf4bEvi5kmTOdzFsjQ+q0lt0/Temd5qOQ=; b=pa0JvqJxW5XIbnr2i2J4f3yPHsAFYl0xv0AY2rrquKobe4iDNwAQ53fNCf5eFLKNcK d06rPKxOLBXJMq4OUELW4kjFgXHYVP8Nn8wW8y151cyS/T5iblhsgLPYL3VpevnVlslP ez0MbiHso+z5l5PQKsSynHxSzIb9U4ov2oovHLerKMPz+IJyPNDzshqShiWaA2AAIWAz Wng4df0LlBwe6d83f8RiD55wIGatpiIZ97E3sgGtlYvcT9gTR2heLksswxC14w8lzF0d PfxWkyVuOcB/rBNec8LNyePnWttQh3PusskuVemEoUdeRpeK+OXEkXnliI0AywmOwXQb fdBg== X-Gm-Message-State: AOAM533iKikOxm/n9GvsAVcDR0YNX1w5v7dYf8kiOrDLnsgPgTa+Tbzn YV1xwNp3OjlvYL2zwmPqxNMyJQ== X-Google-Smtp-Source: ABdhPJx+tvPCF7DN9xAkUi5/H9cosTFwdZoGSZ2BwL3N/1PGBSS/mIXNpE1lccDFdErCGWxcXHNdjg== X-Received: by 2002:adf:aad3:: with SMTP id i19mr47368142wrc.119.1609098670451; Sun, 27 Dec 2020 11:51:10 -0800 (PST) Original-Received: from localhost ([51.37.13.75]) by smtp.gmail.com with ESMTPSA id o83sm16354402wme.21.2020.12.27.11.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Dec 2020 11:51:09 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:196821 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable forcemerge 24309 6601 tags 24309 - wontfix tags 24309 + patch quit Stefan Kangas writes: > Eli Zaretskii writes: > >>> From: Nathanael Schweers >>> Date: Fri, 26 Aug 2016 01:07:06 +0200 >>>=20 >>>=20 >>> This bug applies to both the version given in the description >>> (i.e. 25.1-RC2) and version 24.5 distributed on fedora. >> >> Actually, Emacs has behaved like that since creation of hyper-links to >> quoted symbols in doc strings was introduced in Emacs 20.3. >> >>> - Start Emacs with =E2=80=9Cemacs -Q=E2=80=9D. >>> - evaluate these forms: >>> (defvar var "var" "docstring of var") >>> (defvar var* "var*" "docstring of var*") >>> (defvar *var "*var" "docstring of *var") >>> (defvar *var* "*var*" "docstring of *var*") >>>=20 >>> (defun fun0 () "see variable =E2=80=98var=E2=80=99." var) >>> (defun fun1 () "see var*iable =E2=80=98var*=E2=80=99." var*) >>> (defun fun2 () "see *variable =E2=80=98*var=E2=80=99." *var) >>> (defun fun3 () "see *var*iable =E2=80=98*var*=E2=80=99." *var*) >>> - See the docstrings of the defined functions. For fun0 and fun1 the >>> reference to the variable is correct, for fun2 and fun3 they are not. >> >> See help-xref-symbol-regexp, it requires that the first character >> after the opening quote has the word syntax, not the symbol syntax. I >> don't know why is that, perhaps to avoid too many false positives or >> something. The comment there says this was done deliberately. > > That was three years ago, and this discussion has seen no further > replies. I take the above to mean that we don't want to change the > current behaviour, and I'm therefore closing this bug. > > If anyone feels that this is indeed something we would like to > reconsider, please reopen the bug report. I would like valid symbol names to be recognised more reliably, and I don't see why allowing xrefs to start with symbol syntax would lead to too many false positives, so long as help-make-xrefs filters matches appropriately. My personal motivation is that I would like functions from the Dash package (that start with hyphens), as well as built-in arithmetic operators, hyperlinked in Help buffers. The attached patch matches quoted symbol names with one or more characters starting with either word or symbol syntax in Lisp docstrings and Help buffers. WDYT? Thanks, --=20 Basil --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Hyperlink-symbol-names-without-word-syntax-in-Help.patch Content-Transfer-Encoding: quoted-printable >From 90213663582a9be9853209a49b2a9f977ead48c8 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 27 Dec 2020 14:21:50 +0000 Subject: [PATCH] Hyperlink symbol names without word syntax in Help * lisp/emacs-lisp/lisp-mode.el (lisp-el-font-lock-keywords-2) (lisp-cl-font-lock-keywords-2): Allow single-character symbol names. * lisp/help-mode.el (help-xref-symbol-regexp): Also match symbol names starting with symbol syntax (bug#6601, bug#24309). * test/lisp/help-mode-tests.el (help-mode-tests-xref-button): Test hyperlink creation for function names without symbol syntax. --- lisp/emacs-lisp/lisp-mode.el | 6 ++---- lisp/help-mode.el | 3 +-- test/lisp/help-mode-tests.el | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index e477ef1700..85309b3501 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -456,8 +456,7 @@ lisp--match-confusable-symbol-character ("\\(\\\\\\)\\([^\"\\]\\)" (1 (elisp--font-lock-backslash) prepend)) ;; Words inside =E2=80=98=E2=80=99 and `' tend to be symbol names. - (,(concat "[`=E2=80=98]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)" - lisp-mode-symbol-regexp "\\)['=E2=80=99]") + (,(concat "[`=E2=80=98]\\(" lisp-mode-symbol-regexp "\\)['=E2=80= =99]") (1 font-lock-constant-face prepend)) ;; Constant values. (,(concat "\\_<:" lisp-mode-symbol-regexp "\\_>") @@ -507,8 +506,7 @@ lisp--match-confusable-symbol-character (,(concat "(" cl-errs-re "\\_>") (1 font-lock-warning-face)) ;; Words inside =E2=80=98=E2=80=99 and `' tend to be symbol names. - (,(concat "[`=E2=80=98]\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)" - lisp-mode-symbol-regexp "\\)['=E2=80=99]") + (,(concat "[`=E2=80=98]\\(" lisp-mode-symbol-regexp "\\)['=E2=80= =99]") (1 font-lock-constant-face prepend)) ;; Uninterned symbols, e.g., (defpackage #:my-package ...) ;; must come before keywords below to have effect diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 025a67016b..e99df4a971 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -357,8 +357,7 @@ help-xref-symbol-regexp "\\(symbol\\|program\\|property\\)\\|" ; Don't link "\\(source \\(?:code \\)?\\(?:of\\|for\\)\\)\\)" "[ \t\n]+\\)?" - ;; Note starting with word-syntax character: - "['`=E2=80=98]\\(\\sw\\(\\sw\\|\\s_\\)+\\|`\\)['=E2=80=99]")) + "['`=E2=80=98]\\(\\(?:\\sw\\|\\s_\\)+\\|`\\)['=E2=80= =99]")) "Regexp matching doc string references to symbols. =20 The words preceding the quoted symbol can be used in doc strings to diff --git a/test/lisp/help-mode-tests.el b/test/lisp/help-mode-tests.el index 2b9552a8d8..016f4d4965 100644 --- a/test/lisp/help-mode-tests.el +++ b/test/lisp/help-mode-tests.el @@ -72,14 +72,20 @@ help-mode-tests-make-xrefs #'info))))) =20 (ert-deftest help-mode-tests-xref-button () - (with-temp-buffer - (insert "See also the function =E2=80=98interactive=E2=80=99.") - (string-match help-xref-symbol-regexp (buffer-string)) - (help-xref-button 8 'help-function) - (should-not (button-at 22)) - (should-not (button-at 35)) - (let ((button (button-at 30))) - (should (eq (button-type button) 'help-function))))) + (let* ((fmt "See also the function =E2=80=98%s=E2=80=99.") + ;; 1+ translates string index to buffer position. + (beg (1+ (string-search "%" fmt)))) + (with-temp-buffer + ;; (display-buffer (current-buffer)) + (dolist (fn '(interactive \` =3D + - * / %)) + (erase-buffer) + (insert (format fmt fn)) + (goto-char (point-min)) + (re-search-forward help-xref-symbol-regexp) + (help-xref-button 8 'help-function) + (should-not (button-at (1- beg))) + (should-not (button-at (+ beg (length (symbol-name fn))))) + (should (eq (button-type (button-at beg)) 'help-function)))))) =20 (ert-deftest help-mode-tests-insert-xref-button () (with-temp-buffer --=20 2.29.2 --=-=-=--