From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.bugs Subject: bug#46302: 28.0.50; cperl-mode cleanup: Eliminate dead code Date: Thu, 04 Feb 2021 20:21:46 +0100 Message-ID: <87tuqrtz91.fsf@hajtower> 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="15480"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: 46302@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 04 20:45:58 2021 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 1l7kZi-0003s6-2w for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 20:45:58 +0100 Original-Received: from localhost ([::1]:40540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7kZg-0001Kt-Vy for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Feb 2021 14:45:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7kCY-00004v-VT for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 14:22:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7kCY-0007Ej-KM for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 14:22:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l7kCY-0008V9-Fs for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 14:22:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Feb 2021 19:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46302 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161246651832666 (code B ref -1); Thu, 04 Feb 2021 19:22:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Feb 2021 19:21:58 +0000 Original-Received: from localhost ([127.0.0.1]:42269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7kCT-0008Uo-V8 for submit@debbugs.gnu.org; Thu, 04 Feb 2021 14:21:58 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:58020) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7kCR-0008Ug-Tg for submit@debbugs.gnu.org; Thu, 04 Feb 2021 14:21:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7kCR-0008E0-93 for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 14:21:55 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:51199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7kCO-00076n-41 for bug-gnu-emacs@gnu.org; Thu, 04 Feb 2021 14:21:54 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 24D832400FB for ; Thu, 4 Feb 2021 20:21:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1612466508; bh=AbXL6/MwLIj1qcN2gMItBqsKCdBhtKaSySZxYc5XY9A=; h=From:To:Subject:Date:From; b=W3AvQhnVo4IG85egEC68UsISK8ctAq74GnXMiKCQ2U0mXM7FomBqADcV9ZHUOhNKS prp/Bf9WqhZBj/5M9S6q8TmuZKYvjnEsEqvR02R+7wKK7wBjxvYos6/RmQLAlc3j7J iKJVfD34ZFvkM50fh5aKfISboggl3Rm/LL1zK8hV2rkxRiTz2E3me9mGFKhmiqZKq0 0qKerH1ewVgwzPAZRyQD4hkIbDXAMU4YM0B9X37UIHjCa5qa+3U0ElBnUF9JER/oFv xltJWFPc7Kp4TpHsSagJxytkg808WESAmQJaUXlELnrU7E1arEvPHVttvC7IcQrmrX WA92gPOveE77Q== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DWpMH354pz6tmV for ; Thu, 4 Feb 2021 20:21:47 +0100 (CET) Received-SPF: pass client-ip=185.67.36.66; envelope-from=haj@posteo.de; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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:199325 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-cperl-mode-eliminate-dead-code.patch Content-Description: cperl-mode cleanup: Eliminate dead code >From cf9c369726819c1261e06a5f273c11b0a34b8576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Thu, 4 Feb 2021 20:10:03 +0100 Subject: [PATCH] ; cperl-mode: eliminate dead code * lisp/progmodes/cperl-mode.el (cperl-update-syntaxification): Eliminate check for `syntax-propertize-rules` (always true) and eliminate unused first parameter. (cperl-mode): Eliminate obsolete `font-lock-syntactic-keywords`, Eliminate check for `syntax-propertize-rules` (always true). (cperl-fontify-syntaxically): Eliminate call to no-longer-existing function `edebug-backtrace`. --- lisp/progmodes/cperl-mode.el | 90 ++++++++++++------------------------ 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index d401513646..a70e8e36c0 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1157,25 +1157,25 @@ cperl-old-style (get-text-property (point-min) 'in-pod) (< (progn (and cperl-syntaxify-for-menu - (cperl-update-syntaxification (point-max) (point-max))) + (cperl-update-syntaxification (point-max))) (next-single-property-change (point-min) 'in-pod nil (point-max))) (point-max)))] ["Ispell HERE-DOCs" cperl-here-doc-spell (< (progn (and cperl-syntaxify-for-menu - (cperl-update-syntaxification (point-max) (point-max))) + (cperl-update-syntaxification (point-max))) (next-single-property-change (point-min) 'here-doc-group nil (point-max))) (point-max))] ["Narrow to this HERE-DOC" cperl-narrow-to-here-doc (eq 'here-doc (progn (and cperl-syntaxify-for-menu - (cperl-update-syntaxification (point) (point))) + (cperl-update-syntaxification (point))) (get-text-property (point) 'syntax-type)))] ["Select this HERE-DOC or POD section" cperl-select-this-pod-or-here-doc (memq (progn (and cperl-syntaxify-for-menu - (cperl-update-syntaxification (point) (point))) + (cperl-update-syntaxification (point))) (get-text-property (point) 'syntax-type)) '(here-doc pod))] "----" @@ -1659,36 +1659,18 @@ cperl-mode nil nil ((?_ . "w")))) ;; Reset syntaxification cache. (setq-local cperl-syntax-state nil) - (if cperl-use-syntax-table-text-property - (if (eval-when-compile (fboundp 'syntax-propertize-rules)) - (progn - ;; Reset syntaxification cache. - (setq-local cperl-syntax-done-to nil) - (setq-local syntax-propertize-function - (lambda (start end) - (goto-char start) - ;; Even if cperl-fontify-syntaxically has already gone - ;; beyond `start', syntax-propertize has just removed - ;; syntax-table properties between start and end, so we have - ;; to re-apply them. - (setq cperl-syntax-done-to start) - (cperl-fontify-syntaxically end)))) - ;; Do not introduce variable if not needed, we check it! - (setq-local parse-sexp-lookup-properties t) - ;; Our: just a plug for wrong font-lock - (setq-local font-lock-unfontify-region-function - ;; not present with old Emacs - #'cperl-font-lock-unfontify-region-function) - ;; Reset syntaxification cache. - (setq-local cperl-syntax-done-to nil) - (setq-local font-lock-syntactic-keywords - (if cperl-syntaxify-by-font-lock - '((cperl-fontify-syntaxically)) - ;; unless font-lock-syntactic-keywords, font-lock (pre-22.1) - ;; used to ignore syntax-table text-properties. (t) is a hack - ;; to make font-lock think that font-lock-syntactic-keywords - ;; are defined. - '(t))))) + (when cperl-use-syntax-table-text-property + ;; Reset syntaxification cache. + (setq-local cperl-syntax-done-to nil) + (setq-local syntax-propertize-function + (lambda (start end) + (goto-char start) + ;; Even if cperl-fontify-syntaxically has already gone + ;; beyond `start', syntax-propertize has just removed + ;; syntax-table properties between start and end, so we have + ;; to re-apply them. + (setq cperl-syntax-done-to start) + (cperl-fontify-syntaxically end)))) (setq cperl-font-lock-multiline t) ; Not localized... (setq-local font-lock-multiline t) (setq-local font-lock-fontify-region-function @@ -2405,7 +2387,7 @@ cperl-indent-command so that this line becomes properly indented. The relative indentation among the lines of the expression are preserved." (interactive "P") - (cperl-update-syntaxification (point) (point)) + (cperl-update-syntaxification (point)) (if whole-exp ;; If arg, always indent this line as Perl ;; and shift remaining lines of expression the same amount. @@ -2533,7 +2515,7 @@ cperl-beginning-of-property (defun cperl-sniff-for-indent (&optional parse-data) ; was parse-start ;; the sniffer logic to understand what the current line MEANS. - (cperl-update-syntaxification (point) (point)) + (cperl-update-syntaxification (point)) (let ((res (get-text-property (point) 'syntax-type))) (save-excursion (cond @@ -3025,7 +3007,7 @@ cperl-to-comment-or-eol ;; then looks for literal # or end-of-line. (let (state stop-in cpoint (lim (point-at-eol)) pr e) (or cperl-font-locking - (cperl-update-syntaxification lim lim)) + (cperl-update-syntaxification lim)) (beginning-of-line) (if (setq pr (get-text-property (point) 'syntax-type)) (setq e (next-single-property-change (point) 'syntax-type nil (point-max)))) @@ -4640,7 +4622,7 @@ cperl-after-expr-p `}' is treated \"smartly\" if it is not in the list)." (let ((lim (or lim (point-min))) stop p) - (cperl-update-syntaxification (point) (point)) + (cperl-update-syntaxification (point)) (save-excursion (while (and (not stop) (> (point) lim)) (skip-chars-backward " \t\n\f" lim) @@ -5027,7 +5009,7 @@ cperl-indent-region If `cperl-indent-region-fix-constructs', will improve spacing on conditional/loop constructs." (interactive "r") - (cperl-update-syntaxification end end) + (cperl-update-syntaxification end) (save-excursion (let (cperl-update-start cperl-update-end (h-a-c after-change-functions)) (let ((indent-info (list nil nil nil) ; Cannot use '(), since will modify @@ -5233,7 +5215,7 @@ cperl-imenu--create-perl-index packages ends-ranges p marker is-proto is-pack index index1 name (end-range 0) package) (goto-char (point-min)) - (cperl-update-syntaxification (point-max) (point-max)) + (cperl-update-syntaxification (point-max)) ;; Search for the function (progn ;;save-match-data (while (re-search-forward @@ -8209,7 +8191,7 @@ cperl-map-pods-heres (or prop (setq prop 'in-pod)) (or s (setq s (point-min))) (or end (setq end (point-max))) - (cperl-update-syntaxification end end) + (cperl-update-syntaxification end) (save-excursion (goto-char (setq pos s)) (while (and cont (< pos end)) @@ -8225,7 +8207,7 @@ cperl-get-here-doc-region Return nil if the point is not in a HERE document region. If POD is non-nil, will return a POD section if point is in a POD section." (or pos (setq pos (point))) - (cperl-update-syntaxification pos pos) + (cperl-update-syntaxification pos) (if (or (eq 'here-doc (get-text-property pos 'syntax-type)) (and pod (eq 'pod (get-text-property pos 'syntax-type)))) @@ -8295,7 +8277,7 @@ cperl-time-fontification (forward-line step) (setq l (+ l step)) (setq c (1+ c)) - (cperl-update-syntaxification (point) (point)) + (cperl-update-syntaxification (point)) (setq delta (- (- tt (setq tt (funcall timems)))) tot (+ tot delta)) (message "to %s:%6s,%7s" l delta tot)) tot)) @@ -8405,19 +8387,12 @@ cperl-font-lock-fontify-region-function (setq end (point))) (font-lock-default-fontify-region beg end loudly)) -(defvar cperl-d-l nil) -(defvar edebug-backtrace-buffer) ;FIXME: Why? (defun cperl-fontify-syntaxically (end) ;; Some vars for debugging only ;; (message "Syntaxifying...") (let ((dbg (point)) (iend end) (idone cperl-syntax-done-to) (istate (car cperl-syntax-state)) - start from-start edebug-backtrace-buffer) - (if (eq cperl-syntaxify-by-font-lock 'backtrace) - (progn - (require 'edebug) - (let ((f 'edebug-backtrace)) - (funcall f)))) ; Avoid compile-time warning + start from-start) (or cperl-syntax-done-to (setq cperl-syntax-done-to (point-min) from-start t)) @@ -8473,16 +8448,9 @@ cperl-after-change-function (if cperl-syntax-done-to (setq cperl-syntax-done-to (min cperl-syntax-done-to beg)))) -(defun cperl-update-syntaxification (from to) - (cond - ((not cperl-use-syntax-table-text-property) nil) - ((fboundp 'syntax-propertize) (syntax-propertize to)) - ((and cperl-syntaxify-by-font-lock - (or (null cperl-syntax-done-to) - (< cperl-syntax-done-to to))) - (save-excursion - (goto-char from) - (cperl-fontify-syntaxically to))))) +(defun cperl-update-syntaxification (to) + (when cperl-use-syntax-table-text-property + (syntax-propertize to))) (defvar cperl-version (let ((v "Revision: 6.2")) -- 2.20.1 --=-=-=--