From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#67523: check-declare doesn't account for shorthands Date: Wed, 29 Nov 2023 10:35:34 +0000 Message-ID: References: <87o7fcgbyx.fsf@ushin.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3818"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67523@debbugs.gnu.org, Adam Porter , Jonas Bernoulli To: Joseph Turner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 29 11:37:19 2023 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 1r8HwU-0000mu-UV for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Nov 2023 11:37:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8Hw8-0007dl-B9; Wed, 29 Nov 2023 05:36:56 -0500 Original-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 ) id 1r8Hw6-0007dY-OC for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 05:36:54 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8Hw6-0001vQ-G0 for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 05:36:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r8HwD-0002IP-TF for bug-gnu-emacs@gnu.org; Wed, 29 Nov 2023 05:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Nov 2023 10:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67523 X-GNU-PR-Package: emacs Original-Received: via spool by 67523-submit@debbugs.gnu.org id=B67523.17012541628749 (code B ref 67523); Wed, 29 Nov 2023 10:37:01 +0000 Original-Received: (at 67523) by debbugs.gnu.org; 29 Nov 2023 10:36:02 +0000 Original-Received: from localhost ([127.0.0.1]:48975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r8HvF-0002H2-U3 for submit@debbugs.gnu.org; Wed, 29 Nov 2023 05:36:02 -0500 Original-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 ) id 1r8HvD-0002GX-Kc for 67523@debbugs.gnu.org; Wed, 29 Nov 2023 05:36:00 -0500 Original-Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50aabfa1b75so9211361e87.3 for <67523@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) In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:275213 Archived-At: On Wed, Nov 29, 2023 at 9:56=E2=80=AFAM Jo=C3=A3o T=C3=A1vora wrote: > > On Wed, Nov 29, 2023 at 9:12=E2=80=AFAM Joseph Turner = 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.