From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 10 03:25:46 2022 Received: (at submit) by debbugs.gnu.org; 10 Jan 2022 08:25:47 +0000 Received: from localhost ([127.0.0.1]:51751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6pzu-0006iu-Fu for submit@debbugs.gnu.org; Mon, 10 Jan 2022 03:25:46 -0500 Received: from lists.gnu.org ([209.51.188.17]:39516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n6pzs-0006ig-Op for submit@debbugs.gnu.org; Mon, 10 Jan 2022 03:25:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6pzq-0000J4-DM for bug-gnu-emacs@gnu.org; Mon, 10 Jan 2022 03:25:43 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:41001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6pzo-0003PH-Jb for bug-gnu-emacs@gnu.org; Mon, 10 Jan 2022 03:25:42 -0500 Received: (Authenticated sender: juri@linkov.net) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id EDC68E000E for ; Mon, 10 Jan 2022 08:25:34 +0000 (UTC) From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: Use overlays in hi-lock Organization: LINKOV.NET Date: Mon, 10 Jan 2022 10:17:15 +0200 Message-ID: <86zgo4ovmw.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=217.70.183.196; envelope-from=juri@linkov.net; helo=relay4-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, 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-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) --=-=-= Content-Type: text/plain When diff-refine overlays take precedence over hi-lock text properties, then hi-lock can't be used to review diffs. Hi-lock provides two modes: font-lock highlighting and highlighting with overlays. Using overlays solves the problem. But how to decide when overlays should be used? Detecting whether the buffer is read-only, so no more text is expected to be added to the buffer? Then add overlays instead of using font-lock? But this heuristics doesn't work in read-only *vc-change-log* buffers where expanding commits inserts new text that should be highlighted with font-lock. Thus the following patch adds a new variable hi-lock-use-overlays that can be used like: #+begin_src emacs-lisp (add-hook 'diff-mode-hook (lambda () (setq-local hi-lock-use-overlays t))) #+end_src --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=hi-lock-use-overlays.patch diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index fbd698e234..99e908ad07 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -738,6 +738,17 @@ hi-lock-read-face-name (add-to-list 'hi-lock-face-defaults face t)) (intern face))) +(defvar hi-lock-use-overlays nil + "Whether to always use overlays instead of font-lock rules. +When font-lock-mode is enabled and the buffer specifies font-lock rules, +highlighting is performed by adding new font-lock rules to the existing ones, +so when new matching strings are added, they are highlighted by font-lock. +Otherwise, overlays are used, but new highlighting overlays are not added +when new matching strings are inserted to the buffer. +However, sometimes overlays are still preferable even in buffers +where font-lock is enabled, because hi-lock overlays take precedence +over other overlays in the same buffer, such as diff-refine overlays, etc.") + (defun hi-lock-set-pattern (regexp face &optional subexp lighter case-fold spaces-regexp) "Highlight SUBEXP of REGEXP with face FACE. If omitted or nil, SUBEXP defaults to zero, i.e. the entire @@ -759,7 +770,8 @@ hi-lock-set-pattern (add-to-list 'hi-lock--unused-faces (face-name face)) (push pattern hi-lock-interactive-patterns) (push (cons (or lighter regexp) pattern) hi-lock-interactive-lighters) - (if (and font-lock-mode (font-lock-specified-p major-mode)) + (if (and font-lock-mode (font-lock-specified-p major-mode) + (not hi-lock-use-overlays)) (progn (font-lock-add-keywords nil (list pattern) t) (font-lock-flush)) @@ -781,6 +793,7 @@ hi-lock-set-pattern (match-end subexp)))) (overlay-put overlay 'hi-lock-overlay t) (overlay-put overlay 'hi-lock-overlay-regexp (or lighter regexp)) + (overlay-put overlay 'priority 1) (overlay-put overlay 'face face)) (goto-char (match-end 0))) (when no-matches --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 13 04:08:18 2022 Received: (at 53155) by debbugs.gnu.org; 13 Jan 2022 09:08:19 +0000 Received: from localhost ([127.0.0.1]:60164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7w5i-0000xl-O3 for submit@debbugs.gnu.org; Thu, 13 Jan 2022 04:08:18 -0500 Received: from quimby.gnus.org ([95.216.78.240]:52080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7w5h-0000xZ-RQ for 53155@debbugs.gnu.org; Thu, 13 Jan 2022 04:08:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Bg2ShR9F6wD5d8WlQquCuHYjpaLXImVNHp7nbQ1HaYM=; b=myo08oxTpyQRepOMhYVRVq4Jw6 m/SYDy2XXUNEnDxKgAN8mzv8r49xbqpkdf61AVvz+wv1K0rmx/0iIMb54+PZq/gW7Gx51tBg/GiHs Qz9PJvpH6+nWJdvtCVq95lyXsfofZgbdUI9pLJwXmhRgkzrsunXXRLvrVZANsx2ycn8g=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7w5Z-0000nC-Fm; Thu, 13 Jan 2022 10:08:12 +0100 From: Lars Ingebrigtsen To: Juri Linkov Subject: Re: bug#53155: Use overlays in hi-lock References: <86zgo4ovmw.fsf@mail.linkov.net> X-Now-Playing: Panoptique Electrical's _Decades (2001-2021)_: "Late Night Sea" Date: Thu, 13 Jan 2022 10:08:08 +0100 In-Reply-To: <86zgo4ovmw.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 10 Jan 2022 10:17:15 +0200") Message-ID: <875yqo6m13.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Juri Linkov writes: > But this heuristics doesn't work in read-only *vc-change-log* buffers > where expanding commits inserts new text that should be highlighted > with font-lock. > > Thus the following patch adds a new [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 53155 Cc: 53155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Juri Linkov writes: > But this heuristics doesn't work in read-only *vc-change-log* buffers > where expanding commits inserts new text that should be highlighted > with font-lock. > > Thus the following patch adds a new variable hi-lock-use-overlays > that can be used like: I guess that makes sense... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 24 14:18:10 2022 Received: (at 53155) by debbugs.gnu.org; 24 Jan 2022 19:18:10 +0000 Received: from localhost ([127.0.0.1]:45932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nC4qw-0003kf-27 for submit@debbugs.gnu.org; Mon, 24 Jan 2022 14:18:10 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:49859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nC4qu-0003kF-Rl; Mon, 24 Jan 2022 14:18:09 -0500 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 6D1C7E0005; Mon, 24 Jan 2022 19:17:59 +0000 (UTC) From: Juri Linkov To: Lars Ingebrigtsen Subject: Re: bug#53155: Use overlays in hi-lock Organization: LINKOV.NET References: <86zgo4ovmw.fsf@mail.linkov.net> <875yqo6m13.fsf@gnus.org> Date: Mon, 24 Jan 2022 21:17:31 +0200 In-Reply-To: <875yqo6m13.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 13 Jan 2022 10:08:08 +0100") Message-ID: <86mtjlx7sk.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 53155 Cc: 53155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) close 53155 29.0.50 stop >> But this heuristics doesn't work in read-only *vc-change-log* buffers >> where expanding commits inserts new text that should be highlighted >> with font-lock. >> >> Thus the following patch adds a new variable hi-lock-use-overlays >> that can be used like: > > I guess that makes sense... So now pushed to master and closed. I'm not sure if the new variable 'hi-lock-use-overlays' needs to be mentioned in NEWS. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 25 06:59:54 2022 Received: (at 53155) by debbugs.gnu.org; 25 Jan 2022 11:59:54 +0000 Received: from localhost ([127.0.0.1]:47154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCKUM-00062D-65 for submit@debbugs.gnu.org; Tue, 25 Jan 2022 06:59:54 -0500 Received: from quimby.gnus.org ([95.216.78.240]:34202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCKUK-000621-Vh for 53155@debbugs.gnu.org; Tue, 25 Jan 2022 06:59:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eZXBzxVTYsop/reWXwWk6bPJRMonDkEVSOaYpnMn8mI=; b=gbIWHCrdZWoLGlaXgCocHTntS7 NfCCo/0LmlMoYy4FHDDo955lns6ITYr0GFMQ1vWdixKYtGqkSNAp682e8RDHYPA9I8wd6e8EwKI7v ImXMdMHN2mR6lMKbvc7DytUFYZ8nlCKkFNfXuZjGpl+K6/MuUU3AxtEWbeLbz6P5pjxw=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCKUC-00037z-GS; Tue, 25 Jan 2022 12:59:47 +0100 From: Lars Ingebrigtsen To: Juri Linkov Subject: Re: bug#53155: Use overlays in hi-lock References: <86zgo4ovmw.fsf@mail.linkov.net> <875yqo6m13.fsf@gnus.org> <86mtjlx7sk.fsf@mail.linkov.net> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEViX1vk49D7+fQ4 ODqCgXurrp3///86tVd9AAAAAWJLR0QGYWa4fQAAAAd0SU1FB+YBGQsvCAwqPCQAAAGfSURBVDjL pdTNbsMgDABgV4F7jMoDYG33SHR3NsHdVPj9X2UmP2vapKehHqJ82CaOG4DTdQnwBuhfMExQeL22 e4hxMnICeh+gXk8iIOfiiI9QRKTieAYoOZ9E5CwtHYsXgCal8QEkQbK5yAkYLtmuyXZQk2U9lpxA YSnoD6e6ZGFTqiR9fjDlAV9JUhXhIT6BgRtni156j59TTZpcaw/Daw2NmAzIEvDUEjZWfIsLmH2v Jlv9GgDGwdY2MHHKKW7wiGh1iDEeoRJxh8rPYElXgwHWd/sH9w4UUAOX4aRdwLbGHbh5u8PgAtHn Ay59oy9e7j9+zUW7CvWDqmgRSq/g1fTS8R+4BT715yi4cQPTS3fAnw59GKcZvjs4qkGcAolfoc5n uoclISnzkiprwdB8WQDZ4scK38Fh4floqHNVNnABEWVJmEwG6/yjBtZlv0gDizzDcEPtT606O/q/ CR5MnSMG3eF6f4xUTerCCDhO63ME9DdVCqzMX+46R8RJJ7NFMDmn0vTFW49RPwBeM2iRprezKdJy wUDeEdCb9RZ+ARFAaMcbB71OAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIyLTAxLTI1VDExOjQ3OjA4 KzAwOjAwejh8lAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0wMS0yNVQxMTo0NzowOCswMDowMAtl xCgAAAAASUVORK5CYII= X-Now-Playing: David Bowie's _Brilliant Adventure (8): Toy_: "Toy (Your Turn To Drive)" Date: Tue, 25 Jan 2022 12:59:43 +0100 In-Reply-To: <86mtjlx7sk.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 24 Jan 2022 21:17:31 +0200") Message-ID: <87mtjkyqj4.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Juri Linkov writes: > So now pushed to master and closed. I'm not sure if the new > variable 'hi-lock-use-overlays' needs to be mentioned in NEWS. No, probably not. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 53155 Cc: 53155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Juri Linkov writes: > So now pushed to master and closed. I'm not sure if the new > variable 'hi-lock-use-overlays' needs to be mentioned in NEWS. No, probably not. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Sun Aug 17 22:13:18 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 22 Feb 2022 12:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator