From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58518: 29.0.50; [PATCH] Turning off compilation-minor-mode removes fontification of other modes Date: Fri, 14 Oct 2022 17:15:24 +0200 Message-ID: <87pmeue8s3.fsf@miha-pc> Reply-To: miha@kamnitnik.top Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="476"; mail-complaints-to="usenet@ciao.gmane.io" To: 58518@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 14 17:16:44 2022 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 1ojMQT-000AVY-R8 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Oct 2022 17:16:42 +0200 Original-Received: from localhost ([::1]:47550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojMQS-0007ix-H4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Oct 2022 11:16:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMPs-0007eB-5j for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:16:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojMPq-00082A-EA for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ojMPq-0006ep-8N for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: miha@kamnitnik.top Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Oct 2022 15:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58518 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.166576055525566 (code B ref -1); Fri, 14 Oct 2022 15:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Oct 2022 15:15:55 +0000 Original-Received: from localhost ([127.0.0.1]:38340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojMPi-0006eI-Tr for submit@debbugs.gnu.org; Fri, 14 Oct 2022 11:15:55 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojMPg-0006e8-5D for submit@debbugs.gnu.org; Fri, 14 Oct 2022 11:15:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMPb-0007Y1-6g for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:15:47 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:48332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMPH-0007z4-RC for bug-gnu-emacs@gnu.org; Fri, 14 Oct 2022 11:15:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1665760524; bh=Q9Xenp0MfdQ+oLzHraPzEPVHklToSlBgjIyd0amhhzc=; h=From:To:Subject:Date:From; b=pgjWvCJseXQ5YkhvIyiTLgP1qIgc3YZKLaXrU1Ge1uKn81sdV1KBLtw9hCeW4b/yf NZVgWda5vvi2/rDVCaNdx/Tra1+84P33EQhKTt7Tq6nxzMx0yirzlpxn1UlhbArhip 0MyuzR4fzDy19QRCxEo6N5mqvetKnM41njZ7qDN1/gsaFwfzpLVwGRDKW/y5DruEx2 pcDfqKcwPdNTxM52afNW8ZXH4wvNMkW2+YyCpOGTWWtktrVwR0eQx7g5XmMtVB+t7I IadI3IUdIrHmIFpgTSeQk/2YzNEwou5clsW3KVWvmqeN6i60MBSaWlJ4lIOos46kIP VMDbi8oDOJy5w== Received-SPF: pass client-ip=209.250.245.214; envelope-from=miha@kamnitnik.top; helo=kamnitnik.top X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 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, FROM_SUSPICIOUS_NTLD=0.082, FROM_SUSPICIOUS_NTLD_FP=1.999, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=no 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:245454 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain I propose the attached patch, which fixes the following problem: 1. M-x shell 2. grep -R -n --color=always 'some-search-string-which-yeilds-resuts' File names and line numbers output by grep should be in color 3. M-x compilation-shell-minor-mode File names and line numbers are now underlined by compile.el 4. M-x compilation-shell-minor-mode, to turn it back off File names and line numbers lose their fontification completely, that is, they are now in the default face. The attached patch makes them return to the face they had after step 2, as specified by the grep command. It also "name-spaces" other text properties used by compile.el, such as keymap and mouse-face. If other minor or major modes make use of these text properties, turning off compilation-shell-minor-mode or compilation-minor-mode should now leave them alone. (Though the ones from compile.el take precedence as long as compilation-*-mode is active.) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-compile-Don-t-clobber-text-properties-of-other-modes.patch Content-Transfer-Encoding: quoted-printable From=200b60dc0bfbe22dd8c570fab25b6ae1087da76022 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Fri, 14 Oct 2022 14:58:44 +0200 Subject: [PATCH] compile.el: Don't clobber text properties of other modes * lisp/progmodes/compile.el (compilation-mode-font-lock-keywords): (compilation-directory-properties): (compilation-internal-error-properties): (compilation-parse-errors): (compilation--remove-properties): Don't modify 'font-lock-face' and other public text properties directly. Modify the private 'compilation-face' property instead. (compilation-setup): Set up 'compilation-face' text property up as an alias to the 'font-lock-face', and similarly for the other private compilation text properties. (compilation--unsetup): Remove the text property aliases. =2D-- lisp/progmodes/compile.el | 90 ++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 6473b50778..c543d40d64 100644 =2D-- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -762,10 +762,10 @@ compilation-mode-font-lock-keywords (1 font-lock-function-name-face) (3 compilation-line-face nil t)) (" --?o\\(?:utfile\\|utput\\)?[=3D ]\\(\\S +\\)" . 1) ("^Compilation \\(finished\\).*" =2D (0 '(face nil compilation-message nil help-echo nil mouse-face nil= ) t) + (0 '(face nil compilation-message nil compilation-help-echo nil comp= ilation-mouse-face nil) t) (1 compilation-info-face)) ("^Compilation \\(exited abnormally\\|interrupt\\|killed\\|terminated= \\|segmentation fault\\)\\(?:.*with code \\([0-9]+\\)\\)?.*" =2D (0 '(face nil compilation-message nil help-echo nil mouse-face nil= ) t) + (0 '(face nil compilation-message nil compilation-help-echo nil comp= ilation-mouse-face nil) t) (1 compilation-error-face) (2 compilation-error-face nil t))) "Additional things to highlight in Compilation mode. @@ -1185,9 +1185,9 @@ compilation-directory-properties (let ((dir (compilation--previous-directory (match-beginning 0)))) (setq dir (if dir (or (get-text-property (1- dir) 'compilation-directo= ry) (get-text-property dir 'compilation-directory)))) =2D `(font-lock-face ,(if leave =2D compilation-leave-directory-face =2D compilation-enter-directory-face) + `(compilation-face ,(if leave + compilation-leave-directory-face + compilation-enter-directory-face) compilation-directory ,(if leave (or (cdr dir) '(nil)) ; nil only isn't a property-c= hange @@ -1195,9 +1195,9 @@ compilation-directory-properties ;; Place a `compilation-message' everywhere we change text-properties ;; so compilation--remove-properties can know what to remove. compilation-message ,(compilation--make-message nil 0 nil nil) =2D mouse-face highlight =2D keymap compilation-button-map =2D help-echo "mouse-2: visit destination directory"))) + compilation-mouse-face highlight + compilation-keymap compilation-button-map + compilation-help-echo "mouse-2: visit destination directory"))) =20 ;; Data type `reverse-ordered-alist' retriever. This function retrieves t= he ;; KEY element from the ALIST, creating it in the right position if not al= ready @@ -1467,15 +1467,15 @@ compilation-internal-error-properties end-marker)))) =20 ;; Must start with face =2D `(font-lock-face ,compilation-message-face + `(compilation-face ,compilation-message-face compilation-message ,(compilation--make-message loc type end-loc rul= e) =2D help-echo ,(if col =2D "mouse-2: visit this file, line and column" =2D (if line =2D "mouse-2: visit this file and line" =2D "mouse-2: visit this file")) =2D keymap compilation-button-map =2D mouse-face highlight))) + compilation-help-echo ,(if col + "mouse-2: visit this file, line and colum= n" + (if line + "mouse-2: visit this file and line" + "mouse-2: visit this file")) + compilation-keymap compilation-button-map + compilation-mouse-face highlight))) =20 (defun compilation--put-prop (matchnum prop val) (when (and (integerp matchnum) (match-beginning matchnum)) @@ -1485,30 +1485,11 @@ compilation--put-prop =20 (defun compilation--remove-properties (&optional start end) (with-silent-modifications =2D ;; When compile.el used font-lock directly, we could just remove all =2D ;; our text-properties in one go, but now that we manually place =2D ;; font-lock-face, we have to be careful to only remove the font-loc= k-face =2D ;; we placed. =2D ;; (remove-list-of-text-properties =2D ;; (or start (point-min)) (or end (point-max)) =2D ;; '(compilation-debug compilation-directory compilation-message =2D ;; font-lock-face help-echo mouse-face)) =2D (let (next) =2D (unless start (setq start (point-min))) =2D (unless end (setq end (point-max))) =2D (compilation--flush-directory-cache start end) =2D (while =2D (progn =2D (setq next (or (next-single-property-change =2D start 'compilation-message nil end) =2D end)) =2D (when (get-text-property start 'compilation-message) =2D (remove-list-of-text-properties =2D start next =2D '(compilation-debug compilation-directory compilation-mes= sage =2D font-lock-face help-echo mouse-face))) =2D (< next end)) =2D (setq start next))))) + (remove-list-of-text-properties + (or start (point-min)) (or end (point-max)) + '( compilation-debug compilation-directory compilation-message + compilation-face compilation-help-echo compilation-keymap + compilation-mouse-face)))) =20 (defun compilation--parse-region (start end) (goto-char end) @@ -1609,21 +1590,21 @@ compilation-parse-errors (compilation--note-type this-type) =20 (compilation--put-prop =2D file 'font-lock-face + file 'compilation-face (symbol-value (aref [compilation-info-face compilation-warning-face compilation-error-face] this-type))))) =20 (compilation--put-prop =2D line 'font-lock-face compilation-line-face) + line 'compilation-face compilation-line-face) (compilation--put-prop =2D end-line 'font-lock-face compilation-line-face) + end-line 'compilation-face compilation-line-face) =20 (compilation--put-prop =2D col 'font-lock-face compilation-column-face) + col 'compilation-face compilation-column-face) (compilation--put-prop =2D end-col 'font-lock-face compilation-column-face) + end-col 'compilation-face compilation-column-face) =20 ;; Obey HIGHLIGHT. (dolist (extra-item (nthcdr 6 item)) @@ -1635,12 +1616,12 @@ compilation-parse-errors ((or (symbolp face) (stringp face)) (put-text-property (match-beginning mn) (match-end mn) =2D 'font-lock-face face)) + 'compilation-face face)) ((and (listp face) (eq (car face) 'face) (or (symbolp (cadr face)) (stringp (cadr face)))) =2D (compilation--put-prop mn 'font-lock-face (cadr fa= ce)) + (compilation--put-prop mn 'compilation-face (cadr fa= ce)) (add-text-properties (match-beginning mn) (match-end mn) (nthcdr 2 face))) @@ -1657,7 +1638,7 @@ compilation-parse-errors (cddr props)) (font-lock-append-text-property (match-beginning mn) (match-end mn) =2D 'font-lock-face (cadr props))))))))) + 'compilation-face (cadr props))))))))) =20 (defvar-local compilation--parsed -1) =20 @@ -2385,6 +2366,13 @@ compilation-setup (add-hook 'before-change-functions #'compilation--flush-parse nil t) ;; Also for minor mode, since it's not permanent-local. (add-hook 'change-major-mode-hook #'compilation--remove-properties nil t) + + (let ((alist (copy-alist char-property-alias-alist))) + (cl-pushnew 'compilation-face (alist-get 'face alist)) + (cl-pushnew 'compilation-mouse-face (alist-get 'mouse-face alist)) + (cl-pushnew 'compilation-help-echo (alist-get 'help-echo alist)) + (cl-pushnew 'compilation-keymap (alist-get 'keymap alist)) + (setq-local char-property-alias-alist alist)) (if minor (progn (font-lock-add-keywords nil (compilation-mode-font-lock-keywords)) @@ -2394,6 +2382,12 @@ compilation-setup (defun compilation--unsetup () ;; Only for minor mode. (font-lock-remove-keywords nil (compilation-mode-font-lock-keywords)) + (let ((alist (copy-alist char-property-alias-alist))) + (when-let ((as (assq 'face alist))) (delq 'compilation-face as)) + (when-let ((as (assq 'mouse-face alist))) (delq 'compilation-mose-face= as)) + (when-let ((as (assq 'help-echo alist))) (delq 'compilation-help-echo = as)) + (when-let ((as (assq 'keymap alist))) (delq 'compilation-keymap as)) + (setq-local char-property-alias-alist alist)) (remove-hook 'before-change-functions #'compilation--flush-parse t) (kill-local-variable 'compilation--parsed) (compilation--remove-properties) =2D-=20 2.38.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmNJfQwTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP0zLD/99mVm8UbGOR748LwzVD+TAQ9QvifCq NpRL3BsxiybiTNjVCR1G9QjD57jIeeqP1XgTmZHAVdEgTfLwze0hs19VB7txIShG yHadm86kYfNBbjYWb+vZRiMROB4gFjQiM1D4xAAaq8KTzyYK3a6HartGqol1CU4N HPc+jidKXkZPdVVJGtxQC0E1VZqeogeKVu3oixw3Rpj0Q5qw44IRh8nc0ybLG4d/ g8TYq1IGp2AlphdVhhUjoHKyEtHXvEbj91Z1QBb252qLGSZmY1LnIaEvYWhHpC5t 237r3WJdMQfi9d9uehwjdT/7GEZQ5rUvYJxvwBvLYQNU7JUxA+hh7yIHC1NtGiHh PesGqHBlkBITWJZecdiPzz4jgJ/zFa2Gek3HhNBs8xQpDvgr+iC4wC01ricn70dY IYgiIXcNCYO9FBAx2PozyJ6WPTvLbGmh2dHsv52xukg4r+09ezMi6M/2LfFeFLuv YcDpErUuUreZVaP4hiqq4nzOYZngbr5envRpzUVwcWwMoALEoq/AauDw7hI7p0n3 znMLRmTdA85jTi3sgpjnNBlMELvNpB2NDv6eQlxbiS31+sgG9qVmXB1pqqlIQ7k1 wFHlEv8fiviTNymhz8yep0QrZ5IlWhDK1oxGnI4JewduBHDOrl52XAXig9hKPg00 ypLj1XG1FXD+Ng== =9rR6 -----END PGP SIGNATURE----- --==-=-=--