From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Harald =?UTF-8?Q?J=C3=B6rg?= Newsgroups: gmane.emacs.bugs Subject: bug#43622: 28.0.50; [CLEANUP][PATCH] cperl-mode: Eliminate dead code Date: Sat, 26 Sep 2020 02:35:15 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BB1F5CE1F20029C613A689C9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34122"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 To: 43622@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 26 02:36:17 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 1kLyCH-0008mD-07 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Sep 2020 02:36:17 +0200 Original-Received: from localhost ([::1]:46922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLyCF-0008Aw-Vz for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Sep 2020 20:36:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLyC2-0008Ak-KY for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 20:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLyC2-0007QJ-BU for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 20:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLyC2-0006C6-3s for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 20:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Harald =?UTF-8?Q?J=C3=B6rg?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Sep 2020 00:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43622 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.160108052923768 (code B ref -1); Sat, 26 Sep 2020 00:36:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Sep 2020 00:35:29 +0000 Original-Received: from localhost ([127.0.0.1]:45505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLyBU-0006BH-Ot for submit@debbugs.gnu.org; Fri, 25 Sep 2020 20:35:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLyBR-0006B7-Fi for submit@debbugs.gnu.org; Fri, 25 Sep 2020 20:35:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLyBR-00088d-7f for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 20:35:25 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:41351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLyBN-0007Du-ON for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 20:35:24 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id AE3F32400FB for ; Sat, 26 Sep 2020 02:35:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1601080516; bh=7wH3xnanQDBbdYKriGmtwieKRcT05CrMHxFpU1NCFpc=; h=To:From:Subject:Autocrypt:Date:From; b=SOc+KGuWXyU5ED67TBkvNMB5BuuWDAjBtp+uQwmGNwhZwVF3wCMr2Oo5e4J0L7uld /88Gautea+EIDCqhp7VftuQia0KZvYpcDZn0B0xKrhGS0pwG/dLeFkn4Heq8zuIddx BofVr8Lk1RXenoiOw9a5UyjzBnOMKXRh8JmF/O6zHejAzMv3UW0Hn8I+4eRxw0eQyw H47xAweyVNhz7COCsN0I52XJvhnzNOpu3OMIz/rFLpKNx1vnjCP7nnjYz2viXrdyBD +xlykd+TgWnuw7EUzfzksjP9sTMkO6F7rSrivEN5SZZ436yuYBq9fAPxJfAXhd8ZiS TlheKBZFB22lA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4ByqYw05xBz9rxK for ; Sat, 26 Sep 2020 02:35:15 +0200 (CEST) Autocrypt: addr=haj@posteo.de; keydata= mQINBF0DVrIBEAC7TRlIilBg/5Dx7R2rV4FBDEavbyMT2cS2wWyksh7JA8e17LNmTdakf+Bm u6C2m6+frolteYRlkreoyAg0fj/5tDw/s5dJDw3tM0b+m/pj2HcwTSRpQSEy5lBiCg11E6Mt F9UngCfkGtJzu8PBWXc1RDQVBwRn5MZbpMZZatE8NOq9AA3Yg6sY11Ez3xIvYU2R7a4OSxmc RJV2+dhdQ4oOTBIGQ2urQSU81kyRtkx+/Yh8WefMrk9nF3nzYziLS53euCAXyzklwYmD6Li3 XSu7wYp5fISky9DK6DPFK7h4RXEL4GFAhy31ehrVnNTcGRohM1Dm9BV9dwXkwlaeT3q0X+nE SXVqPDHtv748bXNIg2WVCZ0WgShcA46XVlSE9Fm+w0HI/1m1L4BaMmQ7gyK5dEchbhxohkk0 AqC3hEJ4ULRidrsCoCWGMFKiOIb9rjeC00vhrUkVJDkPWEGLXjhnRQykb6cESko0rPrSDLqX 9YqaNQ6KO9Un6uogE7YnXYg35EXJ8ORdX257IbXNbFVpgM8FFsl48WV3Pl9WNdADhnnOrz3O wzyK58i/BTsnjVX8ghbWkQcPQ2Kprt+4YR2trEi7TM5Uqzzrg0vp7Oe/9KZBxdxCE67thV7h ElW3CHb4q6o31b4cFmLbtFesSy+hnUU4UymgHgi/hvhxioBxIQARAQABtBxIYXJhbGQgSsO2 cmcgPGhhakBwb3N0ZW8uZGU+iQJOBBMBCAA4FiEEIpYEZLQynxF8Q17KN4XzzzqAcpsFAl0D VrICGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQN Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=haj@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/25 20:35:17 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:188998 Archived-At: This is a multi-part message in MIME format. --------------BB1F5CE1F20029C613A689C9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit As recently discussed on the emacs-devel list, I'd like to eradicate conditional code from cperl-mode where the conditionals evaluate to nil. This is a rather large part of the cleanup, related to all that stuff which has changed in the last years with regard to font-lock-mode and cperl-mode's homegrown fontification based on features which are no longer available. I tested Perl code on my repositories (twiki.org code and https://github.com/act-psgi/Act), written by different authors in different styles, and could not find any change in fontification. The conditionals leading to dead code are: - (featurep 'choose-color) is nil - (featurep 'font-lock-extra) is nil - (facep 'font-lock-constant-face) is t and (boundp 'font-lock-constant-face) is t ...same for other faces provided by font-lock-mode. Once this dead code is eliminated, the macro cperl-force-face and the function cperl-init-faces-weak (both undocumented) lose their purpose and are also deleted. There should be no user-visible changes, so I have made no entry in etc/NEWS. -- Cheers, haj --------------BB1F5CE1F20029C613A689C9 Content-Type: text/x-patch; charset=UTF-8; name="0001-cperl-mode-Delete-conditional-code-where-conditions-.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-cperl-mode-Delete-conditional-code-where-conditions-.pa"; filename*1="tch" =46rom e7e810675f32f43e3f2ac0ef90bc982fc5e8a787 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Harald=3D20J=3DC3=3DB6rg?=3D Date: Sat, 26 Sep 2020 01:58:54 +0200 Subject: [PATCH] cperl-mode: Delete conditional code where conditions eva= luate to nil The features font-lock-extra and choose-color are no longer available. Faces defined by font-lock-mode are always defined. Therefore, conditional code which checks on these is dead code and deleted. * lisp/progmodes/cperl-mode.el (cperl-force-face): This macro's single effect is now inlined, and the macro is gone. (cperl-problems): The reference to choose-color.el, which is no longer available for download, is deleted. (no function): A list of unnecessary empty variable definitions is gone. They were needed for Emacs v19 and below. (cperl-init-faces-weak): This function does no longer do anything and is therefore deleted. (cperl-init-faces): Some bodies of conditional code is deleted because as of today the conditions evaluate to constants. The face cperl-nonoverridable-face is no longer available as variable and needs to be doubly-quoted in one place. --- lisp/progmodes/cperl-mode.el | 211 +---------------------------------- 1 file changed, 3 insertions(+), 208 deletions(-) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 468ffc949a..1e31a5fa40 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -82,13 +82,6 @@ gud-perldb-history (defvar vc-rcs-header) (defvar vc-sccs-header) =20 -(defmacro cperl-force-face (arg descr) ; Takes unquoted arg - `(progn - (or (facep (quote ,arg)) - (make-face ,arg)) - (or (boundp (quote ,arg)) ; We use unquoted variants too - (defvar ,arg (quote ,arg) ,descr)))) - (defun cperl-choose-color (&rest list) (let (answer) (while list @@ -663,10 +656,6 @@ cperl-tips =20 (defvar cperl-problems 'please-ignore-this-line "Description of problems in CPerl mode. -Some faces will not be shown on some versions of Emacs unless you -install choose-color.el, available from - http://ilyaz.org/software/emacs - `fill-paragraph' on a comment may leave the point behind the paragraph. It also triggers a bug in some versions of Emacs (CPerl trie= s to detect it and bulk out). @@ -3262,9 +3251,6 @@ cperl-forward-group-in-re result)) =20 =20 -(defvar font-lock-string-face) -;;(defvar font-lock-reference-face) -(defvar font-lock-constant-face) (defsubst cperl-postpone-fontification (b e type val &optional now) ;; Do after syntactic fontification? (if cperl-syntaxify-by-font-lock @@ -3330,16 +3316,6 @@ cperl-unwind-to-safe (setq end (point))))) (or end pos))))) =20 -;; These are needed for byte-compile (at least with v19) -(defvar cperl-nonoverridable-face) -(defvar font-lock-variable-name-face) -(defvar font-lock-function-name-face) -(defvar font-lock-keyword-face) -(defvar font-lock-builtin-face) -(defvar font-lock-type-face) -(defvar font-lock-comment-face) -(defvar font-lock-warning-face) - (defun cperl-find-sub-attrs (&optional st-l b-fname e-fname pos) "Syntactically mark (and fontify) attributes of a subroutine. Should be called with the point before leading colon of an attribute." @@ -5474,17 +5450,6 @@ cperl-load-font-lock-keywords-2 (or cperl-faces-init (cperl-init-faces)) cperl-font-lock-keywords-2) =20 -(defun cperl-init-faces-weak () - ;; Allow `cperl-find-pods-heres' to run. - (or (boundp 'font-lock-constant-face) - (cperl-force-face font-lock-constant-face - "Face for constant and label names")) - (or (boundp 'font-lock-warning-face) - (cperl-force-face font-lock-warning-face - "Face for things which should stand out")) - ;;(setq font-lock-constant-face 'font-lock-constant-face) - ) - (defun cperl-init-faces () (condition-case errs (progn @@ -5612,7 +5577,7 @@ cperl-init-faces "wh\\(en\\|ile\\)\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added man= ually "\\|[sm]" ; Added manually "\\)\\>") - 2 'cperl-nonoverridable-face) + 2 ''cperl-nonoverridable-face) ; unbound as var, so: doubly quoted= ;; (mapconcat #'identity ;; '("#endif" "#else" "#ifdef" "#ifndef" "#if" ;; "#include" "#define" "#undef") @@ -5648,11 +5613,7 @@ cperl-init-faces 2 font-lock-function-name-face) '("^[ \t]*format[ \t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t]*=3D[ \t]*$= " 1 font-lock-function-name-face) - (cond ((featurep 'font-lock-extra) - '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-= 9_:]+\\)[ \t]*}" - (2 font-lock-string-face t) - (0 '(restart 2 t)))) ; To highlight $a{bc}{ef} - (font-lock-anchored + (cond (font-lock-anchored '("\\([]}\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ \t]*\\(-?[a-zA-Z0-= 9_:]+\\)[ \t]*}" (2 font-lock-string-face t) ("\\=3D[ \t]*{[ \t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}" @@ -5670,15 +5631,7 @@ cperl-init-faces ;;; '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face) ;;; '("\\([@%]\\|\\$#\\)\\(\\sw+\\)" ;;; (2 (cons font-lock-variable-name-face '(underline)))) - (cond ((featurep 'font-lock-extra) - '("^[ \t]*\\(state\\|my\\|local\\|our\\)[ \t]*\\(([ \t]*\\)?\\([$@%= *][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?" - (3 font-lock-variable-name-face) - (4 '(another 4 nil - ("\\=3D[ \t]*,[ \t]*\\([$@%*][a-zA-Z0-9_:]+\\)\\([ \t]*,\\)?" - (1 font-lock-variable-name-face) - (2 '(restart 2 nil) nil t))) - nil t))) ; local variables, multiple - (font-lock-anchored + (cond (font-lock-anchored ;; 1=3Dmy_etc, 2=3Dwhite? 3=3D(+white? 4=3Dwhite? 5=3Dvar `(,(concat "\\<\\(state\\|my\\|local\\|our\\)" cperl-maybe-white-and-comment-rex @@ -5780,164 +5733,6 @@ cperl-init-faces t-font-lock-keywords-1 cperl-font-lock-keywords-1))) (if (fboundp 'ps-print-buffer) (cperl-ps-print-init)) - (if (or (featurep 'choose-color) (featurep 'font-lock-extra)) - (eval ; Avoid a warning - '(font-lock-require-faces - (list - ;; Color-light Color-dark Gray-light Gray-dark Mono - (list 'font-lock-comment-face - ["Firebrick" "OrangeRed" "DimGray" "Gray80"] - nil - [nil nil t t t] - [nil nil t t t] - nil) - (list 'font-lock-string-face - ["RosyBrown" "LightSalmon" "Gray50" "LightGray"] - nil - nil - [nil nil t t t] - nil) - (list 'font-lock-function-name-face - (vector - "Blue" "LightSkyBlue" "Gray50" "LightGray" - (cdr (assq 'background-color ; if mono - (frame-parameters)))) - (vector - nil nil nil nil - (cdr (assq 'foreground-color ; if mono - (frame-parameters)))) - [nil nil t t t] - nil - nil) - (list 'font-lock-variable-name-face - ["DarkGoldenrod" "LightGoldenrod" "DimGray" "Gray90"] - nil - [nil nil t t t] - [nil nil t t t] - nil) - (list 'font-lock-type-face - ["DarkOliveGreen" "PaleGreen" "DimGray" "Gray80"] - nil - [nil nil t t t] - nil - [nil nil t t t]) - (list 'font-lock-warning-face - ["Pink" "Red" "Gray50" "LightGray"] - ["gray20" "gray90" - "gray80" "gray20"] - [nil nil t t t] - nil - [nil nil t t t] - ) - (list 'font-lock-constant-face - ["CadetBlue" "Aquamarine" "Gray50" "LightGray"] - nil - [nil nil t t t] - nil - [nil nil t t t]) - (list 'cperl-nonoverridable-face - ["chartreuse3" ("orchid1" "orange") - nil "Gray80"] - [nil nil "gray90"] - [nil nil nil t t] - [nil nil t t] - [nil nil t t t]) - (list 'cperl-array-face - ["blue" "yellow" nil "Gray80"] - ["lightyellow2" ("navy" "os2blue" "darkgreen") - "gray90"] - t - nil - nil) - (list 'cperl-hash-face - ["red" "red" nil "Gray80"] - ["lightyellow2" ("navy" "os2blue" "darkgreen") - "gray90"] - t - t - nil)))) - ;; Do it the dull way, without choose-color - (cperl-force-face font-lock-constant-face - "Face for constant and label names") - (cperl-force-face font-lock-variable-name-face - "Face for variable names") - (cperl-force-face font-lock-type-face - "Face for data types") - (cperl-force-face cperl-nonoverridable-face - "Face for data types from another group") - (cperl-force-face font-lock-warning-face - "Face for things which should stand out") - (cperl-force-face font-lock-comment-face - "Face for comments") - (cperl-force-face font-lock-function-name-face - "Face for function names") - ;;(defvar font-lock-constant-face 'font-lock-constant-face) - ;;(defvar font-lock-variable-name-face 'font-lock-variable-name-face)= - ;;(or (boundp 'font-lock-type-face) - ;; (defconst font-lock-type-face - ;; 'font-lock-type-face - ;; "Face to use for data types.")) - ;;(or (boundp 'cperl-nonoverridable-face) - ;; (defconst cperl-nonoverridable-face - ;; 'cperl-nonoverridable-face - ;; "Face to use for data types from another group.")) - (if (and - (not (facep 'cperl-array-face)) - (facep 'font-lock-emphasized-face)) - (copy-face 'font-lock-emphasized-face 'cperl-array-face)) - (if (and - (not (facep 'cperl-hash-face)) - (facep 'font-lock-other-emphasized-face)) - (copy-face 'font-lock-other-emphasized-face 'cperl-hash-face)) - (if (and - (not (facep 'cperl-nonoverridable-face)) - (facep 'font-lock-other-type-face)) - (copy-face 'font-lock-other-type-face 'cperl-nonoverridable-face)= ) - ;;(or (boundp 'cperl-hash-face) - ;; (defconst cperl-hash-face - ;; 'cperl-hash-face - ;; "Face to use for hashes.")) - ;;(or (boundp 'cperl-array-face) - ;; (defconst cperl-array-face - ;; 'cperl-array-face - ;; "Face to use for arrays.")) - (let ((background 'light)) - (and (not (facep 'font-lock-constant-face)) - (facep 'font-lock-reference-face) - (copy-face 'font-lock-reference-face 'font-lock-constant-face)) - (if (facep 'font-lock-type-face) nil - (copy-face 'default 'font-lock-type-face) - (cond - ((eq background 'light) - (set-face-foreground 'font-lock-type-face - (if (x-color-defined-p "seagreen") - "seagreen" - "sea green"))) - ((eq background 'dark) - (set-face-foreground 'font-lock-type-face - (if (x-color-defined-p "os2pink") - "os2pink" - "pink"))) - (t - (set-face-background 'font-lock-type-face "gray90")))) - (if (facep 'cperl-nonoverridable-face) - nil - (copy-face 'font-lock-type-face 'cperl-nonoverridable-face) - (cond - ((eq background 'light) - (set-face-foreground 'cperl-nonoverridable-face - (if (x-color-defined-p "chartreuse3") - "chartreuse3" - "chartreuse"))) - ((eq background 'dark) - (set-face-foreground 'cperl-nonoverridable-face - (if (x-color-defined-p "orchid1") - "orchid1" - "orange"))))) - (if (facep 'font-lock-variable-name-face) nil - (copy-face 'italic 'font-lock-variable-name-face)) - (if (facep 'font-lock-constant-face) nil - (copy-face 'italic 'font-lock-constant-face)))) (setq cperl-faces-init t)) (error (message "cperl-init-faces (ignored): %s" errs)))) =20 --=20 2.20.1 --------------BB1F5CE1F20029C613A689C9--