GNU bug report logs - #67523
check-declare doesn't account for shorthands

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Joseph Turner <joseph@HIDDEN>; dated Wed, 29 Nov 2023 09:13:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 67523 <at> debbugs.gnu.org:


Received: (at 67523) by debbugs.gnu.org; 10 Dec 2023 10:58:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 10 05:58:32 2023
Received: from localhost ([127.0.0.1]:49578 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rCHW4-0007Qb-1C
	for submit <at> debbugs.gnu.org; Sun, 10 Dec 2023 05:58:32 -0500
Received: from out-183.mta1.migadu.com ([95.215.58.183]:49357)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joseph@HIDDEN>) id 1rCHW1-0007QR-A6
 for 67523 <at> debbugs.gnu.org; Sun, 10 Dec 2023 05:58:30 -0500
References: <87o7fcgbyx.fsf@HIDDEN>
 <CALDnm53x-_h3WtVDaCnkAv=EQJWaSh6+=fmAAhpn0H90AnmkzA@HIDDEN>
 <CALDnm517n3CDSq-nuLgxg_mDr3Jt9o8sW+7w7_HZC11WTCfuiw@HIDDEN>
 <CALDnm51FCXrv=N53HmihTC0-j2HHUoC75qSvEaRjt8Qt97j_fg@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1;
 t=1702205894;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=c0PAf4hgll/dYGs49fGAIW+1akBw9q5kRT4EzmKn2z8=;
 b=WnLJYfEsFP3XgzQi3K1IvXBQ8xP+3z1yB/6zbfUTh/d9neqznzNExPCittZbU4C84OovvB
 u4UVHnmLJ8Kb4922eKvsGrHqt8kZrl+/wr95DcdNQ28iMlS76NBXTaVYnNKv1068IG8NyR
 o5ng+AF8Zu6yasP9dwiG/yZgcY0XzHqcKBNiOYXlnyaFvDdeDkBa+pnNGCRW1taRyIEjQn
 Y/6TCL4peGE0T6Ag/Gb3x1HQK42LmRyJh2SUZM8ITKCEuqVcFZ5lFY5SpagheNacs7SxW7
 XU1zQQTJKnb39we1vOS26IVyfP5FFJzn9KMzGVkWvpTPq9+wEU6I+VoLtz3eqg==
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Joseph Turner <joseph@HIDDEN>
To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Subject: Re: bug#67523: check-declare doesn't account for shorthands
Date: Sun, 10 Dec 2023 02:57:50 -0800
In-reply-to: <CALDnm51FCXrv=N53HmihTC0-j2HHUoC75qSvEaRjt8Qt97j_fg@HIDDEN>
Message-ID: <87plzenx30.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 2.7 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  João Távora <joaotavora@HIDDEN> writes: > On Wed, Nov
    29, 2023 at 10:35 AM João Távora <joaotavora@HIDDEN> wrote: >> >>
   On Wed, Nov 29, 2023 at 9:56 AM João Távora <joaotavora@HIDDEN> wrote:
    >> > >> > On Wed, Nov 29, 2023 at 9 [...] 
 
 Content analysis details:   (2.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-Debbugs-Envelope-To: 67523
Cc: 67523 <at> debbugs.gnu.org, Adam Porter <adam@HIDDEN>,
 Jonas Bernoulli <jonas@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  João Távora <joaotavora@HIDDEN> writes: > On Wed, Nov
    29, 2023 at 10:35 AM João Távora <joaotavora@HIDDEN> wrote: >> >>
   On Wed, Nov 29, 2023 at 9:56 AM João Távora <joaotavora@HIDDEN> wrote:
    >> > >> > On Wed, Nov 29, 2023 at 9 [...] 
 
 Content analysis details:   (1.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager


Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> writes:

> On Wed, Nov 29, 2023 at 10:35=E2=80=AFAM Jo=C3=A3o T=C3=A1vora <joaotavor=
a@HIDDEN> wrote:
>>
>> On Wed, Nov 29, 2023 at 9:56=E2=80=AFAM Jo=C3=A3o T=C3=A1vora <joaotavor=
a@HIDDEN> wrote:
>> >
>> > On Wed, Nov 29, 2023 at 9:12=E2=80=AFAM Joseph Turner <joseph@HIDDEN=
g> wrote:
>> >
>> > > A potential solution could be to convert the longhand symbol into its
>> > > shorthand form and pass that into re-search-forward.  This is tricky
>> > > since there may be multiple different shorthands which could yield t=
he
>> > > same longhand form.  It might be more feasible to run re-search-forw=
ard
>> > > on a known common suffix portion of the symbol name, then with point=
 on
>> > > the suspected definition, run `intern-soft' to get the full symbol n=
ame.
>> >
>> > No, this is brittle.  Check-declare, if it's to be useful (is it?)
>> > is probably meant to be as precise as possible.
>> >
>> > > A workaround is to not use shorthands in function definitions.
>> >
>> > That's letting the bad guys win :-)
>> >
>> > > Thoughts?
>> >
>> > As usual, my thoughts are that tools that read Lisp code
>> > should use the Lisp reader, not regular expressions.
>> >
>> > Here, check-declare should just walk the whole file.
>>
>> Or maybe just this 100% guaranteed untested patch would work:
>
> Sorry, that was 100% untested indeed.  This patch seems to work:
>
> diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-dec=
lare.el
> index c887d95210c..bc3844ca9be 100644
> --- a/lisp/emacs-lisp/check-declare.el
> +++ b/lisp/emacs-lisp/check-declare.el
> @@ -145,21 +145,26 @@ check-declare-verify
>      (if (file-regular-p fnfile)
>          (with-temp-buffer
>            (insert-file-contents fnfile)
> +          (unless cflag
> +            ;; for syntax and shorthands
> +            (lisp-data-mode)
> +            (hack-local-variables))
>            ;; defsubst's don't _have_ to be known at compile time.
> -          (setq re (format (if cflag
> -                               "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
> -                             "^[ \t]*(\\(fset[ \t]+'\\|\
> +          (setq re (if cflag
> +                       (format "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
> +                               (regexp-opt (mapcar 'cadr fnlist) t))
> +                     "^[ \t]*(\\(fset[ \t]+'\\|\
>  cl-def\\(?:generic\\|method\\|un\\)\\|\
>  def\\(?:un\\|subst\\|foo\\|method\\|class\\|\
>  ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\=
\|\
>  \\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\
>  ine-overloadable-function\\)\\)\
> -[ \t]*%s\\([ \t;]+\\|$\\)")
> -                           (regexp-opt (mapcar 'cadr fnlist) t)))
> +[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)"))
>            (while (re-search-forward re nil t)
>              (skip-chars-forward " \t\n")
> -            (setq fn (match-string 2)
> -                  type (match-string 1)
> +            (setq fn (symbol-name (car (read-from-string (match-string 2=
)))))
> +            (when (member fn (mapcar 'cadr fnlist))
> +            (setq type (match-string 1)
>                    ;; (min . max) for a fixed number of arguments, or
>                    ;; arglists with optional elements.
>                    ;; (min) for arglists with &rest.
> @@ -202,7 +207,7 @@ check-declare-verify
>                              (t
>                               'err))
>                    ;; alist of functions and arglist signatures.
> -                  siglist (cons (cons fn sig) siglist)))))
> +                  siglist (cons (cons fn sig) siglist))))))
>      (dolist (e fnlist)
>        (setq arglist (nth 2 e)
>              type

IIUC, this patch is being merged in response to bug#67390.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67523; Package emacs. Full text available.

Message received at 67523 <at> debbugs.gnu.org:


Received: (at 67523) by debbugs.gnu.org; 29 Nov 2023 11:12:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 29 06:12:39 2023
Received: from localhost ([127.0.0.1]:49017 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8IUh-0003KA-DL
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 06:12:39 -0500
Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]:42485)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1r8IUe-0003Jw-PL
 for 67523 <at> debbugs.gnu.org; Wed, 29 Nov 2023 06:12:38 -0500
Received: by mail-lf1-x136.google.com with SMTP id
 2adb3069b0e04-50bb92811c0so777120e87.1
 for <67523 <at> debbugs.gnu.org>; Wed, 29 Nov 2023 03:12:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701256343; x=1701861143; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=RPfzgL4OGrX6Y/Ig6PGdu2MhQrxSPrW3igRlicJ1fL8=;
 b=gZaDQn5OvBHwv8WPULomghcGqG56JUh8rF1RWmWC7poKByepNoXI1z9cdYC3KWyn+b
 TqidgDN1/uJc+5u8tTaDKQxZRMM6PmxZM6hQfk0l1DRODEv3hBz7vsF4XerZmMQPCAv6
 Ode7b3JDuR8e5j+GYIC/uUuOznfkwG9zNdy7RRwbXnc8z9309gqvBtDLGc/iNRrUiO3d
 fEupEUEUi1421Ot5EmS/ky88KpJbUv1uJ/ViFM6XsxIMZO5FtGXyYUc5aT6whqvMxbnk
 Qg6/q6FPgMWt2dRYGcLophvk53nrYdflzRyGDP4IaoOQT92JNZT8LYVMLumDn1s1uuSi
 k2Tw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701256343; x=1701861143;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=RPfzgL4OGrX6Y/Ig6PGdu2MhQrxSPrW3igRlicJ1fL8=;
 b=w4EDoEyo7rBuq8BSHnNiZrRnhsVAsE82u4vhG36dkhh+AA6D1HXg3fjPI0aaZcBX1v
 3Hkbp2GFRCPox/4WA1xQFvvAThDNMQppOO/drEfoFDho9n3iDs34WC+hvnVTWjy7Kj9Q
 ZklqLxKeTvOZwPKNqqpkJ1vNCbZZ/nM/x1YEiBR9Vtq+m1ZFp7MBScfGZu+0MS13JBf0
 7xy/e4s1i+q5Y8864A/7kzJWJoKB+Ad2qUNBO+qhMLZxiwViZBTI8ZdPWf/qDmPfkFwW
 cZHzAnjhrbSpQaucsyFYHVdQLyzsBlkr/WEPeNXdQ6TGyP4THSBiPAjfMW8rJ+N1E57T
 dDsA==
X-Gm-Message-State: AOJu0YxjNy1pzFEJa0h3LZXlsf8JE6FhRNPLjd3hfF8bMHGO57jrWrXO
 4cJJe1skeV4UO1SaMuvQ86fPkqXy5CgNlRsMDqg=
X-Google-Smtp-Source: AGHT+IEIGBn2wJ4Za0dft4Uf8vXL9QpiDJoBcnfFOYdeF6yJel2qDqyxeW4/NjcoI7i/NvdYMjPpaRWE07IqjkqricA=
X-Received: by 2002:a05:6512:108d:b0:50b:c8c3:4580 with SMTP id
 j13-20020a056512108d00b0050bc8c34580mr95418lfg.10.1701256342915; Wed, 29 Nov
 2023 03:12:22 -0800 (PST)
MIME-Version: 1.0
References: <87o7fcgbyx.fsf@HIDDEN>
 <CALDnm53x-_h3WtVDaCnkAv=EQJWaSh6+=fmAAhpn0H90AnmkzA@HIDDEN>
 <CALDnm517n3CDSq-nuLgxg_mDr3Jt9o8sW+7w7_HZC11WTCfuiw@HIDDEN>
In-Reply-To: <CALDnm517n3CDSq-nuLgxg_mDr3Jt9o8sW+7w7_HZC11WTCfuiw@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Wed, 29 Nov 2023 11:12:11 +0000
Message-ID: <CALDnm51FCXrv=N53HmihTC0-j2HHUoC75qSvEaRjt8Qt97j_fg@HIDDEN>
Subject: Re: bug#67523: check-declare doesn't account for shorthands
To: Joseph Turner <joseph@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 2.7 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Wed, Nov 29, 2023 at 10:35 AM João Távora wrote: >
   > On Wed, Nov 29, 2023 at 9:56 AM João Távora wrote: > > > > On Wed, Nov
    29, 2023 at 9:12 AM Joseph Turner wrote: > > > > > A pote [...] 
 
 Content analysis details:   (2.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (joaotavora[at]gmail.com)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [2a00:1450:4864:20:0:0:0:136 listed in]
                             [list.dnswl.org]
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-Debbugs-Envelope-To: 67523
Cc: 67523 <at> debbugs.gnu.org, Adam Porter <adam@HIDDEN>,
 Jonas Bernoulli <jonas@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Wed, Nov 29, 2023 at 10:35 AM João Távora wrote: >
   > On Wed, Nov 29, 2023 at 9:56 AM João Távora wrote: > > > > On Wed, Nov
    29, 2023 at 9:12 AM Joseph Turner wrote: > > > > > A pote [...] 
 
 Content analysis details:   (1.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [2a00:1450:4864:20:0:0:0:136 listed in]
                             [list.dnswl.org]
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (joaotavora[at]gmail.com)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

On Wed, Nov 29, 2023 at 10:35=E2=80=AFAM Jo=C3=A3o T=C3=A1vora <joaotavora@=
gmail.com> wrote:
>
> On Wed, Nov 29, 2023 at 9:56=E2=80=AFAM Jo=C3=A3o T=C3=A1vora <joaotavora=
@gmail.com> wrote:
> >
> > On Wed, Nov 29, 2023 at 9:12=E2=80=AFAM Joseph Turner <joseph@HIDDEN=
> wrote:
> >
> > > A potential solution could be to convert the longhand symbol into its
> > > shorthand form and pass that into re-search-forward.  This is tricky
> > > since there may be multiple different shorthands which could yield th=
e
> > > same longhand form.  It might be more feasible to run re-search-forwa=
rd
> > > on a known common suffix portion of the symbol name, then with point =
on
> > > the suspected definition, run `intern-soft' to get the full symbol na=
me.
> >
> > No, this is brittle.  Check-declare, if it's to be useful (is it?)
> > is probably meant to be as precise as possible.
> >
> > > A workaround is to not use shorthands in function definitions.
> >
> > That's letting the bad guys win :-)
> >
> > > Thoughts?
> >
> > As usual, my thoughts are that tools that read Lisp code
> > should use the Lisp reader, not regular expressions.
> >
> > Here, check-declare should just walk the whole file.
>
> Or maybe just this 100% guaranteed untested patch would work:

Sorry, that was 100% untested indeed.  This patch seems to work:

diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-decla=
re.el
index c887d95210c..bc3844ca9be 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -145,21 +145,26 @@ check-declare-verify
     (if (file-regular-p fnfile)
         (with-temp-buffer
           (insert-file-contents fnfile)
+          (unless cflag
+            ;; for syntax and shorthands
+            (lisp-data-mode)
+            (hack-local-variables))
           ;; defsubst's don't _have_ to be known at compile time.
-          (setq re (format (if cflag
-                               "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
-                             "^[ \t]*(\\(fset[ \t]+'\\|\
+          (setq re (if cflag
+                       (format "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
+                               (regexp-opt (mapcar 'cadr fnlist) t))
+                     "^[ \t]*(\\(fset[ \t]+'\\|\
 cl-def\\(?:generic\\|method\\|un\\)\\|\
 def\\(?:un\\|subst\\|foo\\|method\\|class\\|\
 ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\\|=
\
 \\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\
 ine-overloadable-function\\)\\)\
-[ \t]*%s\\([ \t;]+\\|$\\)")
-                           (regexp-opt (mapcar 'cadr fnlist) t)))
+[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\([ \t;]+\\|$\\)"))
           (while (re-search-forward re nil t)
             (skip-chars-forward " \t\n")
-            (setq fn (match-string 2)
-                  type (match-string 1)
+            (setq fn (symbol-name (car (read-from-string (match-string 2))=
)))
+            (when (member fn (mapcar 'cadr fnlist))
+            (setq type (match-string 1)
                   ;; (min . max) for a fixed number of arguments, or
                   ;; arglists with optional elements.
                   ;; (min) for arglists with &rest.
@@ -202,7 +207,7 @@ check-declare-verify
                             (t
                              'err))
                   ;; alist of functions and arglist signatures.
-                  siglist (cons (cons fn sig) siglist)))))
+                  siglist (cons (cons fn sig) siglist))))))
     (dolist (e fnlist)
       (setq arglist (nth 2 e)
             type




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67523; Package emacs. Full text available.

Message received at 67523 <at> debbugs.gnu.org:


Received: (at 67523) by debbugs.gnu.org; 29 Nov 2023 10:36:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 29 05:36:02 2023
Received: from localhost ([127.0.0.1]:48975 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8HvF-0002H2-U3
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 05:36:02 -0500
Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:45539)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1r8HvD-0002GX-Kc
 for 67523 <at> debbugs.gnu.org; Wed, 29 Nov 2023 05:36:00 -0500
Received: by mail-lf1-x12a.google.com with SMTP id
 2adb3069b0e04-50aabfa1b75so9211361e87.3
 for <67523 <at> debbugs.gnu.org>; Wed, 29 Nov 2023 02:35:52 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701254146; x=1701858946; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Jb+MwMVr7RmVPZzfojTAcGTn0bfrrKiSDFZX0ecetIU=;
 b=VA+ZdcP0ZLIaCpeImqJZdthR9kX6TYZ8redqYaSnfUquKrPwI8yMlys+t9upMDzrvU
 pOzQLIKi617jgfJsOVyVsKmG9YPZAhdevZif2OWgGJHlWa4IAl8PJIIK63LUdpCFSx42
 VBi4QYJQ3jhdMguTF0HAJvoDhTpUmAGhJVF4q3cOLsGgYnAaFQaUZucqu3kQKDB0HKer
 ey1SzeRrnWZ6yyjvWMIqHSxBTsG+CXxwOe/Lg7tRkD5GXLaKj183kChqNFoX7hiPSCMA
 +Jl5UudcuA/g7jAdFxrt1rFRg2GAl7ueq2Bh7WmaHF+BW3m+QLAkfrIi/swC4AbVvFNk
 6l9A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701254146; x=1701858946;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Jb+MwMVr7RmVPZzfojTAcGTn0bfrrKiSDFZX0ecetIU=;
 b=lENgl6Lwad/73j9BPQsYbHP3+oyDlKdPLOmSt9ApFHk+hUHx2YoCB1hfNpqj5iysd/
 MClB83Qp/ug3t0jRahGaYilwmqcuwcgdH+rdiyQ7XvkgOGbsD7ksh8N0wFd5O6CjIYaT
 W8Nv09LbsFtbyuVV7SeDaa2+b35Z2kgjdL12ojkWFVeq+LfuyVHP8R366TpuRsMEFc8V
 Mi2uTp8Vta2K1OVaJbN8Wa4cquYopyp3XBWPp/rGjVY/C+8UcnB46U2O3s5z1vMakWIi
 bV2yQGaiYQZc013eLaszwYEPvJljkOE6VHO33R28WhdjZJmu5m/2zxP7ECMz3ONsKMfV
 5Igw==
X-Gm-Message-State: AOJu0YyKOxAmEqe1tCkJUoAPVVYutarqQ+P/yWq3ToDh3i0PLPwDn4ve
 yTtW1d+XR7OrUwMzKbutwYG/xwIBcEQpco0TcsU=
X-Google-Smtp-Source: AGHT+IEvVtxOW++Jrbe4/LIUr5TE/rEUGE4ny6p64jQN2DSIZHUe8XMOb9y2SHaB5ncvVizr/MuuW3DUwqeenm2SNyU=
X-Received: by 2002:a05:6512:3a85:b0:50b:a6c7:e8b0 with SMTP id
 q5-20020a0565123a8500b0050ba6c7e8b0mr11073513lfu.26.1701254146019; Wed, 29
 Nov 2023 02:35:46 -0800 (PST)
MIME-Version: 1.0
References: <87o7fcgbyx.fsf@HIDDEN>
 <CALDnm53x-_h3WtVDaCnkAv=EQJWaSh6+=fmAAhpn0H90AnmkzA@HIDDEN>
In-Reply-To: <CALDnm53x-_h3WtVDaCnkAv=EQJWaSh6+=fmAAhpn0H90AnmkzA@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Wed, 29 Nov 2023 10:35:34 +0000
Message-ID: <CALDnm517n3CDSq-nuLgxg_mDr3Jt9o8sW+7w7_HZC11WTCfuiw@HIDDEN>
Subject: Re: bug#67523: check-declare doesn't account for shorthands
To: Joseph Turner <joseph@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 2.7 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Wed, Nov 29, 2023 at 9:56 AM João Távora wrote: > >
    On Wed, Nov 29, 2023 at 9:12 AM Joseph Turner wrote: > > > A potential
   solution could be to convert the longhand symbol into its > > sh [...] 
 
 Content analysis details:   (2.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (joaotavora[at]gmail.com)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-Debbugs-Envelope-To: 67523
Cc: 67523 <at> debbugs.gnu.org, Adam Porter <adam@HIDDEN>,
 Jonas Bernoulli <jonas@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Wed, Nov 29, 2023 at 9:56 AM João Távora wrote: > >
    On Wed, Nov 29, 2023 at 9:12 AM Joseph Turner wrote: > > > A potential
   solution could be to convert the longhand symbol into its > > sh [...] 
 
 Content analysis details:   (1.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.7 GUARANTEED_100_PERCENT BODY: One hundred percent guaranteed
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (joaotavora[at]gmail.com)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
                              no trust
                             [2a00:1450:4864:20:0:0:0:12a listed in]
                             [list.dnswl.org]
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

On Wed, Nov 29, 2023 at 9:56=E2=80=AFAM Jo=C3=A3o T=C3=A1vora <joaotavora@g=
mail.com> wrote:
>
> On Wed, Nov 29, 2023 at 9:12=E2=80=AFAM Joseph Turner <joseph@HIDDEN> =
wrote:
>
> > A potential solution could be to convert the longhand symbol into its
> > shorthand form and pass that into re-search-forward.  This is tricky
> > since there may be multiple different shorthands which could yield the
> > same longhand form.  It might be more feasible to run re-search-forward
> > on a known common suffix portion of the symbol name, then with point on
> > the suspected definition, run `intern-soft' to get the full symbol name=
.
>
> No, this is brittle.  Check-declare, if it's to be useful (is it?)
> is probably meant to be as precise as possible.
>
> > A workaround is to not use shorthands in function definitions.
>
> That's letting the bad guys win :-)
>
> > Thoughts?
>
> As usual, my thoughts are that tools that read Lisp code
> should use the Lisp reader, not regular expressions.
>
> Here, check-declare should just walk the whole file.

Or maybe just this 100% guaranteed untested patch would work:

diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-decla=
re.el
index c887d95210c..00440276643 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -145,6 +145,7 @@ check-declare-verify
     (if (file-regular-p fnfile)
         (with-temp-buffer
           (insert-file-contents fnfile)
+          (hack-local-variables) ;; for shorthands
           ;; defsubst's don't _have_ to be known at compile time.
           (setq re (format (if cflag
                                "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
@@ -158,7 +159,7 @@ check-declare-verify
                            (regexp-opt (mapcar 'cadr fnlist) t)))
           (while (re-search-forward re nil t)
             (skip-chars-forward " \t\n")
-            (setq fn (match-string 2)
+            (setq fn (symbol-name (car (read-from-string (match-string 2))=
))
                   type (match-string 1)
                   ;; (min . max) for a fixed number of arguments, or
                   ;; arglists with optional elements.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67523; Package emacs. Full text available.

Message received at 67523 <at> debbugs.gnu.org:


Received: (at 67523) by debbugs.gnu.org; 29 Nov 2023 09:57:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 29 04:57:02 2023
Received: from localhost ([127.0.0.1]:48923 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8HJV-0001E2-Qw
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 04:57:02 -0500
Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:54522)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1r8HJS-0001Di-N9
 for 67523 <at> debbugs.gnu.org; Wed, 29 Nov 2023 04:56:59 -0500
Received: by mail-lf1-x12b.google.com with SMTP id
 2adb3069b0e04-50bc21821a1so1473947e87.0
 for <67523 <at> debbugs.gnu.org>; Wed, 29 Nov 2023 01:56:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1701251805; x=1701856605; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=5paSbJE2YwDBrWUB2qbqeni5mVihNnbcgiLgzX3udsc=;
 b=h+6Wr11vtldTzixVM8hzFevQWIh44jaxKplLR43dqR1WcKFWX5f3pYz1IjeB2zZegI
 HXc1oo++zQEP+w8XTCkbt8OWkj/PgkldelcLbAM9ghTLOkltTSGpWrYdZ5q3GLTXAcWj
 Uw9O/ME1itBWCFjRDaQW/sOoqwJtDs7l+of46/1A1hkZTKILcfPMXx+ghtPq0RYHFVkn
 A788884hbEd1miBxCEptpoawfzxBiju1EJAMySkzi4EvLms4p/IeHMdwb1n6vjYru85L
 J9awPtale50XdqUCT0p8gZTpQWq3TRIQdusOdv6VZpaL3ygL8ZQlsimXF1Ne8FPc0PI1
 UH7A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1701251805; x=1701856605;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=5paSbJE2YwDBrWUB2qbqeni5mVihNnbcgiLgzX3udsc=;
 b=FSY0qtOuwPS356zMDbEDdeIRlecZGH6WgcqVDXMIi1klWhA5XLk1WZ5KVP7TCB/rIK
 1tkHLNOQUC7Edw6JS5uPlcOcEbSw7lGJmzVLD+OU9I0/H3uzOHwQ9Kqnx+ZbtAUpDFfk
 FuaHsCwJ+2T5xTDU9DEZHnJC6xkOvjDqk8hXyjHWPrR2rvWhwgF8QAfXNAUvZArA89VY
 ZeeSKb2hIjfDJ3PCaQZTROxxIuNnsUZnfV84oNNiLbwlc/6QOhDdG5iFndva5kt0MxJP
 KpUyZekz7ESswnzSVUGeGrL7RrZCPfNzeTB6NIuP41d+Yik/UNeSTPb4+VGp6RJRaCJm
 xELA==
X-Gm-Message-State: AOJu0YymLJ5rIt47dZg6Wx9JwiEQs9/wGoz3jMwAXECkufJN3yVS++Yb
 SNMcbjBooVvQ8Onb+SgW8/ffiWAUakNKOLdDBZg=
X-Google-Smtp-Source: AGHT+IF2NU3SIhttUhzx/C98Ho6CC2UUdtpjcKgK28UHsFGPW1U0B5oCg0PS01FigbweAHTmkG6FOxCD5GiWNkKZTmk=
X-Received: by 2002:a05:6512:280d:b0:500:ac10:1641 with SMTP id
 cf13-20020a056512280d00b00500ac101641mr10650970lfb.46.1701251805072; Wed, 29
 Nov 2023 01:56:45 -0800 (PST)
MIME-Version: 1.0
References: <87o7fcgbyx.fsf@HIDDEN>
In-Reply-To: <87o7fcgbyx.fsf@HIDDEN>
From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Date: Wed, 29 Nov 2023 09:56:32 +0000
Message-ID: <CALDnm53x-_h3WtVDaCnkAv=EQJWaSh6+=fmAAhpn0H90AnmkzA@HIDDEN>
Subject: Re: bug#67523: check-declare doesn't account for shorthands
To: Joseph Turner <joseph@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67523
Cc: 67523 <at> debbugs.gnu.org, Adam Porter <adam@HIDDEN>,
 Jonas Bernoulli <jonas@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Wed, Nov 29, 2023 at 9:12=E2=80=AFAM Joseph Turner <joseph@HIDDEN> wr=
ote:

> A potential solution could be to convert the longhand symbol into its
> shorthand form and pass that into re-search-forward.  This is tricky
> since there may be multiple different shorthands which could yield the
> same longhand form.  It might be more feasible to run re-search-forward
> on a known common suffix portion of the symbol name, then with point on
> the suspected definition, run `intern-soft' to get the full symbol name.

No, this is brittle.  Check-declare, if it's to be useful (is it?)
is probably meant to be as precise as possible.

> A workaround is to not use shorthands in function definitions.

That's letting the bad guys win :-)

> Thoughts?

As usual, my thoughts are that tools that read Lisp code
should use the Lisp reader, not regular expressions.

Here, check-declare should just walk the whole file.
When it finds a a symbol atom that matches a definition
form,  look in the next atom and check if it matches the probe.
If you don't want to intern all the symbols in the you can read
to a separate obarray I think.

Jo=C3=A3o




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67523; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Nov 2023 09:12:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 29 04:12:45 2023
Received: from localhost ([127.0.0.1]:48874 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8Gce-0008KW-RN
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 04:12:45 -0500
Received: from lists.gnu.org ([2001:470:142::17]:40602)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joseph@HIDDEN>) id 1r8Gcc-0008K9-L2
 for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 04:12:43 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <joseph@HIDDEN>) id 1r8GcD-0002vq-P0
 for bug-gnu-emacs@HIDDEN; Wed, 29 Nov 2023 04:12:18 -0500
Received: from out-175.mta1.migadu.com ([95.215.58.175])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <joseph@HIDDEN>) id 1r8GcB-0007hT-56
 for bug-gnu-emacs@HIDDEN; Wed, 29 Nov 2023 04:12:17 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1;
 t=1701249130;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding;
 bh=Wv8lTwm4H+wpSzWssC0OJEy+tu3AuzsHw++1lHauOlM=;
 b=Z/VJhiFlkUjDTQecDdU8oUSbRBDjlY84Dk+EbiBn51K4MEWK4FIQI3ok6ct4X5lwCtns5J
 5bzE4lbqMHzOTK1COOkHpTirs4ssPXcmzcuaMbLt5vC9MAmLNexTNihFhaTLEzLf5V0ray
 /TFR4pagJmNEwmu0nirqWOja+Ao1wsdij1f9UGuu2XNg0+c3l7MMN7HM5ETGWgrMGxjj5z
 Raab0Gk7uQhZ69ozVELSKuy0o3qpcxaaDPlPlYtLXHJNw1NeuqghzfwF9EpvdNDqOJRNNY
 4n3sVChZf5bLoOfb8ajd5Ix7Ro65seBRBroqQ58fGkXrWqn/PBknp3rM0PBsCw==
From: Joseph Turner <joseph@HIDDEN>
To: Emacs Bugs Mailing List <bug-gnu-emacs@HIDDEN>
Subject: check-declare doesn't account for shorthands
Date: Wed, 29 Nov 2023 00:03:50 -0800
X-Debbugs-CC: Adam Porter <adam@HIDDEN>, Jonas Bernoulli
 <jonas@HIDDEN>, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>
Message-ID: <87o7fcgbyx.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
Received-SPF: pass client-ip=95.215.58.175; envelope-from=joseph@HIDDEN;
 helo=out-175.mta1.migadu.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

On Emacs 29.1, when running `check-declare-file' on a file with
`declare-function' forms, I get

Warning (check-declare): said =E2=80=98some-nice-string-utils-foobar=E2=80=
=99 was defined in
some-nice-string-utils.el: function not found

The problem is that `check-declare-verify' attempts to search for the
full symbol name using this regular expression:

(setq re (format (if cflag
                     "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
                   "^[ \t]*(\\(fset[ \t]+'\\|\
cl-def\\(?:generic\\|method\\|un\\)\\|\
def\\(?:un\\|subst\\|foo\\|method\\|class\\|\
ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\\|\
\\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\
ine-overloadable-function\\)\\)\
[ \t]*%s\\([ \t;]+\\|$\\)")
                 (regexp-opt (mapcar 'cadr fnlist) t)))
(while (re-search-forward re nil t)
  ...
  )

where (mapcar 'cadr fnlist) is the full symbol name.

Since the full symbol name never appears in the file in which it was
defined, re-search-forward never finds it, and so "function not found".

A potential solution could be to convert the longhand symbol into its
shorthand form and pass that into re-search-forward.  This is tricky
since there may be multiple different shorthands which could yield the
same longhand form.  It might be more feasible to run re-search-forward
on a known common suffix portion of the symbol name, then with point on
the suspected definition, run `intern-soft' to get the full symbol name.

A workaround is to not use shorthands in function definitions.

Thoughts?

Joseph




Acknowledgement sent to Joseph Turner <joseph@HIDDEN>:
New bug report received and forwarded. Copy sent to adam@HIDDEN, jonas@HIDDEN, joaotavora@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to adam@HIDDEN, jonas@HIDDEN, joaotavora@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#67523; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.