GNU bug report logs - #79976
[PATCH] hi-lock: Use active region for default values in more places

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Rudolf Adamkovič <rudolf@HIDDEN>; Keywords: patch; Done: Eli Zaretskii <eliz@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 79976-done <at> debbugs.gnu.org:


Received: (at 79976-done) by debbugs.gnu.org; 20 Dec 2025 12:24:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 20 07:24:10 2025
Received: from localhost ([127.0.0.1]:48344 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vWw0I-0006vg-DZ
	for submit <at> debbugs.gnu.org; Sat, 20 Dec 2025 07:24:10 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:49526)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vWw0G-0006vK-I5
 for 79976-done <at> debbugs.gnu.org; Sat, 20 Dec 2025 07:24:09 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1vWw0A-0004GG-JG; Sat, 20 Dec 2025 07:24:02 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=cRNjU3ojOAr1uqrIezyf8YRngtSVCkmr9rexSaR739I=; b=Vg2qdYL6te2dybV1K7xh
 FtC+2zdp5XN+NgxXogWAOeCbQM6imZxMopQQ/DFRHVb3pguLNrdxH4Sj55oQHGL+yYwJKWvooozfF
 /um3IM8Uc5i9nn+FDxMfZwcwjTO1sYajfKuMXXxypiSI1dVm8WKoEmy4ibl/HTIcpsONEFM7sNDPV
 E2MzgJyy6FABtK1yHVeoVc6kZWmLHQ2ek2Xgl1c3RlUHEh+B0EI06YgHg3snwgDgljWLXslyIObKF
 7A/n34JHGRmFv/JxSGUD+lCeDc53X87eT/BKzMx4e3JU1/OG4DemqZfQftO8zL28XhwXQbpSvS+yH
 V89BOseFhYnXyA==;
Date: Sat, 20 Dec 2025 14:24:00 +0200
Message-Id: <86ms3dz6hr.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Rudolf =?utf-8?Q?Adamkovi=C4=8D?= <rudolf@HIDDEN>
In-Reply-To: <m2cy4noikb.fsf@HIDDEN> (message from Rudolf
 =?utf-8?Q?Adamkovi=C4=8D?= on Tue, 09 Dec 2025 15:07:00 +0100)
Subject: Re: bug#79976: [PATCH] hi-lock: Use active region for default values
 in more places
References: <m2cy4noikb.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79976-done
Cc: koppel@HIDDEN, 79976-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: David M. Koppelman <koppel@HIDDEN>
> From: Rudolf Adamkovič <rudolf@HIDDEN>
> Date: Tue, 09 Dec 2025 15:07:00 +0100
> 
> Today, I reviewed my notes on Hi Lock and figured I could contribute
> some improvements upstream.  Please, see the attached patch.

Thanks, now installed on the master branch, and closing the bug.




Notification sent to Rudolf Adamkovič <rudolf@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Eli Zaretskii <eliz@HIDDEN>:
You have taken responsibility. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Dec 2025 14:07:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 09 09:07:18 2025
Received: from localhost ([127.0.0.1]:53462 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vSyN3-0004nB-Q1
	for submit <at> debbugs.gnu.org; Tue, 09 Dec 2025 09:07:18 -0500
Received: from lists.gnu.org ([2001:470:142::17]:46238)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <rudolf@HIDDEN>)
 id 1vSyN0-0004mq-Rg
 for submit <at> debbugs.gnu.org; Tue, 09 Dec 2025 09:07:15 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rudolf@HIDDEN>)
 id 1vSyMu-0000dO-PL
 for bug-gnu-emacs@HIDDEN; Tue, 09 Dec 2025 09:07:09 -0500
Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rudolf@HIDDEN>)
 id 1vSyMs-0005N1-GY
 for bug-gnu-emacs@HIDDEN; Tue, 09 Dec 2025 09:07:08 -0500
Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42])
 by mailfhigh.phl.internal (Postfix) with ESMTP id 34B7E140016A
 for <bug-gnu-emacs@HIDDEN>; Tue,  9 Dec 2025 09:07:04 -0500 (EST)
Received: from phl-mailfrontend-01 ([10.202.2.162])
 by phl-compute-02.internal (MEProxy); Tue, 09 Dec 2025 09:07:04 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamkovic.org;
 h=cc:content-type:content-type:date:date:from:from:in-reply-to
 :message-id:mime-version:reply-to:subject:subject:to:to; s=fm2;
 t=1765289224; x=1765375624; bh=sgVkE04N3yQA51/ygueIb+9/UkHUkEzL
 E4cyJXCC6U0=; b=ScxVJiFAIfgRd3B6skjvJa1AuRg9ZcRsxVnSLb5enrMtkYt3
 HvfV3nP3HpWVlixXp572ZryWKdo3FsvNqwuGzyErdgDoNUeiY3P6UGMzMzUfMlml
 AI0wRdmOl5QZhzAK4DgsFz4kUNToHXddPA/oUoG418pqsHzjKbJwR9coQVFqLrKs
 6l5WcnYd7V/W7nFbjWaxMCRcunDzJea+vSBV5vjTd1o82r26/t7l2Wgx6s88d8il
 bqoNrCk5PyGFug0aPZpKKEPsT1C7lLuRU2WIt6N9hlUAZwNG8rL9L8tIDebERY4I
 SCQmHTuqlSuvIWW+mT30qyVIZ1yz1HQQvK04TQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-type:content-type:date:date
 :feedback-id:feedback-id:from:from:in-reply-to:message-id
 :mime-version:reply-to:subject:subject:to:to:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1765289224; x=
 1765375624; bh=sgVkE04N3yQA51/ygueIb+9/UkHUkEzLE4cyJXCC6U0=; b=F
 IQTyn7yvyX5Kpiq3pz+ZtaX5VNEsHpc3dG2/YRRFCpI9ol6WPEk6emcAE9d1wqn9
 j8lJfjj619o07X6iHTpemhN1Tm4nMrCKlyGuD4y9xp4dRXbtyBX1jH4oOyPAN1jo
 WSkOPZzzOe+ZY/RiB3sHQeZGCVvLJ0PqCy3FKdhqT2ByXgDulBcBrCoHxkH34dGM
 opsErjyegXm2NDLVTQ3zbsZ3IuodcZqsXYiRTmacGQfvzuJeNQBndm5tA86xjxms
 YhwbIa2jGvozUttqO5OVPNovvBKeNxRah5Y3XLV86zAoD9r7WKT4epDrYWTaXsTo
 6vklPxSJ7Q9iHBLsNFZIA==
X-ME-Sender: <xms:CC04aXzvTk4uchE3Qaul6YtJxiPgUr8M_KT0N9nS4z1WpK6KocHAzg>
 <xme:CC04aVLxsgNtNtS2HjXCKuBZHVTe8OyFhCfbca5-5YtSPkORcnwHRy-Kd890fCeF2
 -OmC1PsLr0ccbl5zfevdhjlEM1EkdYy4csKaatMWLr0JUPBkGRdTQ>
X-ME-Received: <xmr:CC04acY4SfSt-RltU9P1aHKhzI3OQebhEoe_OzLiqXBHj32hxyq2HjaYY7yCh9VNDaaaQk_B5qIshwGVHSaxxUolLWGqkNQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduleejiecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr
 ihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgesmhdtreertddtjeenuc
 fhrhhomheptfhuugholhhfucetuggrmhhkohhvihgtuceorhhuugholhhfsegruggrmhhk
 ohhvihgtrdhorhhgqeenucggtffrrghtthgvrhhnpeffkeefuedufedtkeevjeejveetff
 duteejteegtdffudeuvdejkedvjeeuieevffenucevlhhushhtvghrufhiiigvpedtnecu
 rfgrrhgrmhepmhgrihhlfhhrohhmpehruhguohhlfhesrggurghmkhhovhhitgdrohhrgh
 dpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghu
 ghdqghhnuhdqvghmrggtshesghhnuhdrohhrgh
X-ME-Proxy: <xmx:CC04aeUkV32Vs5tXYPKdWM_FpyUtiUjuGKRwrrVql31cUdVnjaJ25A>
 <xmx:CC04acnefr7rXWqlNL0VIP7ta7Ygvch8o1qGbOBa7Cd2BGWZt-Kneg>
 <xmx:CC04abzy7i_9WM5QC8dTnTjJsfrlYa3pwRp_7f-lmze0ygLbt3wT3A>
 <xmx:CC04aXg3R4XlMyu2ca99BDl5AjaX9ESOe0xNJfo4VjDwP5njQ9YH-g>
 <xmx:CC04aTDqJRb0-Ofso38Qglv27PF9p6voSX88CyWxL3PPWfe3UL8vZZCc>
Feedback-ID: i88214938:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
 <bug-gnu-emacs@HIDDEN>; Tue, 9 Dec 2025 09:07:03 -0500 (EST)
From: =?utf-8?Q?Rudolf_Adamkovi=C4=8D?= <rudolf@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] hi-lock: Use active region for default values in more places
X-Debbugs-Cc: David M. Koppelman <koppel@HIDDEN>
Date: Tue, 09 Dec 2025 15:07:00 +0100
Message-ID: <m2cy4noikb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=103.168.172.152;
 envelope-from=rudolf@HIDDEN; helo=fhigh-a1-smtp.messagingengine.com
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_VALIDITY_RPBL_BLOCKED=0.001,
 RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

--=-=-=
Content-Type: text/plain

Tags: patch

Hi there!

Today, I reviewed my notes on Hi Lock and figured I could contribute
some improvements upstream.  Please, see the attached patch.

Rudy

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.5.0, NS
 appkit-2575.60 Version 15.5 (Build 24F74)) of 2025-12-03 built on
 skynet.local
Repository revision: 669f0f4ff1970cb685ba0a3121110047cf9e44a3
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.5

Configured using:
 'configure --with-json --with-tree-sitter --with-sqlite3
 --with-native-compilation=aot'


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-hi-lock-Use-active-region-for-default-values-in-more.patch

From 6b685e6e78795a0769a4049b141ade8bcfdede45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <rudolf@HIDDEN>
Date: Tue, 9 Dec 2025 13:35:42 +0100
Subject: [PATCH] hi-lock: Use active region for default values in more places

* lisp/hi-lock.el (hi-lock-line-face-buffer, hi-lock-face-buffer)
(hi-lock-face-phrase-buffer): Use the new function `hi-lock-read-regexp'
to read font-lock patterns, mirroring `hi-lock-read-face-name' used to
read face names.  For end users, all three functions now get the default
value from the active region, rather than just `hi-lock-face-buffer'.
(hi-lock-read-regexp): Extract font-lock pattern reading functionality
from `hi-lock-face-buffer' into this function, to mirror how faces are
read with `hi-lock-read-face-name' and to promote reuse.
---
 etc/NEWS        |  9 +++++++++
 lisp/hi-lock.el | 36 +++++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 15 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 45c1d2865f1..2304c5a9b9b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3163,6 +3163,15 @@ it will begrudgingly use the scratch buffer.
 Customize the variable 'abbrev-mode' to non-nil to enable Abbrev mode by
 default in all buffers.
 
+** Hi Lock
+
+---
+*** Use active region for default values in more functions.
+
+If an active region exists, the commands `hi-lock-line-face-buffer' and
+`hi-lock-face-phrase-buffer' now use its contents as their default
+value.  Previously, only `hi-lock-face-buffer' supported this.
+
 
 * New Modes and Packages in Emacs 31.1
 
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index 35ee01c2f3b..71f302f3ebc 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -393,7 +393,7 @@ hi-lock-line-face-buffer
 the attributes of FACE with any other face attributes
 of text in those lines.
 
-Interactively, prompt for REGEXP using `read-regexp', then FACE.
+Interactively, prompt for REGEXP using `hi-lock-read-regexp', then FACE.
 Use the global history list for FACE.
 
 If REGEXP contains upper case characters (excluding those preceded by `\\')
@@ -404,8 +404,7 @@ hi-lock-line-face-buffer
 highlighting will not update as you type."
   (interactive
    (list
-    (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight line" 'regexp-history-last))
+    (hi-lock-read-regexp "Regexp to highlight line")
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -423,7 +422,7 @@ 'highlight-regexp
 ;;;###autoload
 (defun hi-lock-face-buffer (regexp &optional face subexp lighter)
   "Set face of each match of REGEXP to FACE.
-Interactively, prompt for REGEXP using `read-regexp', then FACE.
+Interactively, prompt for REGEXP using `hi-lock-read-regexp', then FACE.
 Use the global history list for FACE.  Limit face setting to the
 corresponding SUBEXP (interactively, the prefix argument) of REGEXP.
 If SUBEXP is omitted or nil, the entire REGEXP is highlighted.
@@ -443,14 +442,7 @@ hi-lock-face-buffer
 the major mode specifies support for Font Lock."
   (interactive
    (list
-    (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight"
-                  (if (use-region-p)
-                      (prog1
-                          (buffer-substring (region-beginning)
-                                            (region-end))
-                        (deactivate-mark))
-                    'regexp-history-last)))
+    (hi-lock-read-regexp "Regexp to highlight")
     (hi-lock-read-face-name)
     current-prefix-arg))
   (when (stringp face)
@@ -469,7 +461,7 @@ 'highlight-phrase
 ;;;###autoload
 (defun hi-lock-face-phrase-buffer (regexp &optional face)
   "Set face of each match of phrase REGEXP to FACE.
-Interactively, prompt for REGEXP using `read-regexp', then FACE.
+Interactively, prompt for REGEXP using `hi-lock-read-regexp', then FACE.
 Use the global history list for FACE.
 
 If REGEXP contains upper case characters (excluding those preceded by `\\')
@@ -484,8 +476,7 @@ hi-lock-face-phrase-buffer
 the major mode specifies support for Font Lock."
   (interactive
    (list
-    (hi-lock-regexp-okay
-     (read-regexp "Phrase to highlight" 'regexp-history-last))
+    (hi-lock-read-regexp "Phrase to highlight")
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -726,6 +717,21 @@ hi-lock-read-face-name
       (add-to-list 'hi-lock-face-defaults face t))
     (intern face)))
 
+(defun hi-lock-read-regexp (prompt)
+  "Read font-lock pattern from the minibuffer and return it.
+
+The pattern is read using `read-regexp' with PROMPT and validated using
+`hi-lock-regexp-okay'.  If the region is active, use its content as the
+default value."
+  (hi-lock-regexp-okay
+   (read-regexp prompt
+                (if (use-region-p)
+                    (prog1
+                        (buffer-substring (region-beginning)
+                                          (region-end))
+                      (deactivate-mark))
+                  'regexp-history-last))))
+
 (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,
-- 
2.39.5 (Apple Git-154)


--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


--=20
"It is better to have 100 functions operate on one data structure than
10 functions on 10 data structures."

--- Alan Perlis

Rudolf Adamkovi=C4=8D <rudolf@HIDDEN> [he/him]
http://adamkovic.org

--=-=-=--




Acknowledgement sent to Rudolf Adamkovič <rudolf@HIDDEN>:
New bug report received and forwarded. Copy sent to koppel@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to koppel@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#79976; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Dec 2025 12:30:01 UTC

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