GNU bug report logs - #46302
28.0.50; cperl-mode cleanup: Eliminate dead code

Previous Next

Package: emacs;

Reported by: haj <at> posteo.de (Harald Jörg)

Date: Thu, 4 Feb 2021 19:22:02 UTC

Severity: normal

Tags: fixed

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 46302 in the body.
You can then email your comments to 46302 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#46302; Package emacs. (Thu, 04 Feb 2021 19:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to haj <at> posteo.de (Harald Jörg):
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 04 Feb 2021 19:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: haj <at> posteo.de (Harald Jörg)
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; cperl-mode cleanup: Eliminate dead code
Date: Thu, 04 Feb 2021 20:21:46 +0100
[Message part 1 (text/plain, inline)]
In two places, CPerl mode checks whether `syntax-propertize-rules` is
fboundp, which is always true as of today.  The attached patch
eliminates this check and the corresponding "else"-Branches.

Also, an (undocumented) debug trace doesn't work in current Emacs
because the function `edebug-backtrace` was eliminated, so this call is
removed by the patch.

Finally, a workaround to set `font-lock-syntactic-keywords` is no longer
needed.  This eliminates a warning when compiling cperl-mode.el under
current Emacs.

-- 
Cheers,
haj
[0001-cperl-mode-eliminate-dead-code.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46302; Package emacs. (Thu, 04 Feb 2021 19:54:03 GMT) Full text and rfc822 format available.

Message #8 received at 46302 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: haj <at> posteo.de (Harald Jörg)
Cc: 46302 <at> debbugs.gnu.org
Subject: Re: bug#46302: 28.0.50; cperl-mode cleanup: Eliminate dead code
Date: Thu, 04 Feb 2021 20:52:55 +0100
haj <at> posteo.de (Harald Jörg) writes:

> Finally, a workaround to set `font-lock-syntactic-keywords` is no longer
> needed.  This eliminates a warning when compiling cperl-mode.el under
> current Emacs.

I don't get any warnings when compiling cperl-mode.el?

Anyway, the patch looks good to me, so I've applied it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 04 Feb 2021 19:54:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 46302 <at> debbugs.gnu.org and haj <at> posteo.de (Harald Jörg) Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 04 Feb 2021 19:54:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46302; Package emacs. (Thu, 04 Feb 2021 22:29:02 GMT) Full text and rfc822 format available.

Message #15 received at 46302 <at> debbugs.gnu.org (full text, mbox):

From: haj <at> posteo.de (Harald Jörg)
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 46302 <at> debbugs.gnu.org
Subject: Re: bug#46302: 28.0.50; cperl-mode cleanup: Eliminate dead code
Date: Thu, 04 Feb 2021 23:28:28 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> haj <at> posteo.de (Harald Jörg) writes:
>
>> Finally, a workaround to set `font-lock-syntactic-keywords` is no longer
>> needed.  This eliminates a warning when compiling cperl-mode.el under
>> current Emacs.
>
> I don't get any warnings when compiling cperl-mode.el?

Ooops... Me neither.

I seem to recall a warning in the *Compile-Log* buffer that
`font-lock-syntactic.keywords' is an obsolete variable.  However, I
can't reproduce it :(

Did I hallucinate?  I had a look: The variable _is_ obsolete as of
font-lock.el:

(make-obsolete-variable 'font-lock-syntactic-keywords
                        'syntax-propertize-function "24.1")

Isn't `make-obsolete-variable` supposed to generate a compiler warning?
Or maybe I found the warning in C-h v font-lock-syntactic-keywords?
I'm confused.

> Anyway, the patch looks good to me, so I've applied it to Emacs 28.

Thanks!
-- 
Cheers,
haj




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46302; Package emacs. (Fri, 05 Feb 2021 08:58:02 GMT) Full text and rfc822 format available.

Message #18 received at 46302 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: haj <at> posteo.de (Harald Jörg)
Cc: 46302 <at> debbugs.gnu.org
Subject: Re: bug#46302: 28.0.50; cperl-mode cleanup: Eliminate dead code
Date: Fri, 05 Feb 2021 09:57:40 +0100
haj <at> posteo.de (Harald Jörg) writes:

> Did I hallucinate?  I had a look: The variable _is_ obsolete as of
> font-lock.el:
>
> (make-obsolete-variable 'font-lock-syntactic-keywords
>                         'syntax-propertize-function "24.1")
>
> Isn't `make-obsolete-variable` supposed to generate a compiler warning?

It is supposed to, but somehow it didn't...  I just tried putting a

        (setq-local font-lock-syntactic-keywords
                    (if cperl-syntaxify-by-font-lock
                        '((cperl-fontify-syntaxically))

into the function, and I got a 

cperl-mode.el:1678:15: Warning: ‘font-lock-syntactic-keywords’ is an obsolete
    variable (as of 24.1); use ‘syntax-propertize-function’ instead.

as expected.

Hm...  perhaps it's because of this?

-  (if cperl-use-syntax-table-text-property
-      (if (eval-when-compile (fboundp 'syntax-propertize-rules))
-          (progn

And the compiler got confused and didn't output a warning (always)?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46302; Package emacs. (Fri, 05 Feb 2021 10:55:02 GMT) Full text and rfc822 format available.

Message #21 received at 46302 <at> debbugs.gnu.org (full text, mbox):

From: haj <at> posteo.de (Harald Jörg)
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 46302 <at> debbugs.gnu.org
Subject: Re: bug#46302: 28.0.50; cperl-mode cleanup: Eliminate dead code
Date: Fri, 05 Feb 2021 11:54:37 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

>> Isn't `make-obsolete-variable` supposed to generate a compiler warning?
>
> It is supposed to, but somehow it didn't... [...]
>
> Hm...  perhaps it's because of this?
>
> -  (if cperl-use-syntax-table-text-property
> -      (if (eval-when-compile (fboundp 'syntax-propertize-rules))
> -          (progn
>
> And the compiler got confused and didn't output a warning (always)?

Ah, that reminds me of something... I did the elimination in several
steps, and in one of them killed the conditional and the if-branch, but
forget to kill the else-branch as well.  Apparently I ran the first
compilation test with that (bogus) intermediate version, and got the
warning.

As it turns out, the byte compiler shortcuts the conditional if it
eval-when-compiles to a constant and doesn't even touch the else-branch.
Digging into the commit logs reveals:

  commit 4813c453b22ff7b965e31a30d35b70f73d6bcbc7
  Author: Stefan Monnier <monnier <at> iro.umontreal.ca>
  Date:   Sun Feb 3 10:47:12 2013 -0500

      * lisp/progmodes/cperl-mode.el (cperl-mode): Avoid byte-compile
        warning.

Now it all makes sense :)
-- 
Cheers,
haj




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#46302; Package emacs. (Fri, 05 Feb 2021 11:04:01 GMT) Full text and rfc822 format available.

Message #24 received at 46302 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: haj <at> posteo.de (Harald Jörg)
Cc: 46302 <at> debbugs.gnu.org
Subject: Re: bug#46302: 28.0.50; cperl-mode cleanup: Eliminate dead code
Date: Fri, 05 Feb 2021 12:03:21 +0100
haj <at> posteo.de (Harald Jörg) writes:

> Now it all makes sense :)

Yup.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 05 Mar 2021 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 50 days ago.

Previous Next


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