From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#32365: Interactive Highlighting: prefix arg as subexp selector Date: Sun, 05 Aug 2018 23:07:46 -0400 Message-ID: <87sh3sxke5.fsf@gmail.com> References: <9fecb36d-cd58-0a70-ac84-ddaa8edb5030@imag.fr> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1533524775 14252 195.159.176.226 (6 Aug 2018 03:06:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Aug 2018 03:06:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 32365@debbugs.gnu.org To: =?UTF-8?Q?Gr=C3=A9gory_?= =?UTF-8?Q?Mouni=C3=A9?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 06 05:06:11 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmVqV-0003Zj-2S for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Aug 2018 05:06:11 +0200 Original-Received: from localhost ([::1]:60472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmVsZ-0008DE-Ke for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Aug 2018 23:08:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmVsN-0008CW-IA for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 23:08:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmVsI-00060i-I3 for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 23:08:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmVsI-00060d-Dd for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 23:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fmVsI-0001Kv-2C for bug-gnu-emacs@gnu.org; Sun, 05 Aug 2018 23:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Aug 2018 03:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32365 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32365-submit@debbugs.gnu.org id=B32365.15335248765127 (code B ref 32365); Mon, 06 Aug 2018 03:08:01 +0000 Original-Received: (at 32365) by debbugs.gnu.org; 6 Aug 2018 03:07:56 +0000 Original-Received: from localhost ([127.0.0.1]:42183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmVsC-0001KX-Bx for submit@debbugs.gnu.org; Sun, 05 Aug 2018 23:07:56 -0400 Original-Received: from mail-io0-f176.google.com ([209.85.223.176]:42119) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fmVs9-0001KE-Vi; Sun, 05 Aug 2018 23:07:54 -0400 Original-Received: by mail-io0-f176.google.com with SMTP id n18-v6so252538ioa.9; Sun, 05 Aug 2018 20:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=4VSxqEKRbmcOJcziOz+A2jrpFtkp/rnYUJ6kiND+PXs=; b=Fe5ynoD23CiLMOqRgEPUopchKl1R6rZgu/QKOgni2I2c6dSlHGCUyA416WbYEwC+Yx 29Zodt9qvyg1iKGNd4+PTrgvWQ1VgG0uCAiRlWxKBtQelyLdZa7xHSGIeBGoNE8Hko/6 l6cso3vrd0Fh14WoZxgNForaG7/dEXiV0xtGllwvHrN0TcjphlslUMKJRSREgu4iPEni MyzESP1Kn1+KpjA29HbFyAM4QoRdj643jCl7zMO0ixgJbWBJrAmiCQhF/I6AfJnHqdaS VwYq3sW/4wuBYTXO2Cnl5NW665QdCCXem7ZZSlwmAYnbuc2juOgZ4EmvHduOz9Hn+9WM rTuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=4VSxqEKRbmcOJcziOz+A2jrpFtkp/rnYUJ6kiND+PXs=; b=K4AxzL4+yt/+xtLbmKUuVwDI+JMaPrb/iA1moxeXx/2C6dXkkeEHBKTguHJ5f/Sfea 24qOZfNeOPqn/InlxaWGgSD9UZePMgz49cIKIJsQ6uJNNzaeZyDUcyagidFtunM4WILY kGxk5p7J2jIHd3u4RdG5N/uTjNX2TZFDtoLCgKsK/EsZZ5wneOwDwkr2reTsVZgy0g/4 DKmOCfEFfzQXaY7mR79Xe8yeb+gH4TAEtarSQ9NmTnNK+hZknZIQKemDu4ZCmBBKBmAA YDuJ/JMSBHPF4e1vnoAFS/DUhJ5RO2TuHvETFjOxU6mWf1wi39vHvn8tb14eu6qGkcpi 6QGw== X-Gm-Message-State: AOUpUlH9SchDWKQTlx1BEepJGtCJaD8fW346aGXg+LUYsAZjoDgdF9tk fbWlUeWkT52eRrWMUyyg0YF6CGGF X-Google-Smtp-Source: AAOMgpdAqVqivp3opz7aGjJf+dVAnwUiqurrAnPv5ozX88HlJzZGdIE9Iv1+WviIkUZ6DHqzPErKFA== X-Received: by 2002:a6b:6503:: with SMTP id z3-v6mr13622299iob.129.1533524868194; Sun, 05 Aug 2018 20:07:48 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id t20-v6sm3190745itb.31.2018.08.05.20.07.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Aug 2018 20:07:47 -0700 (PDT) In-Reply-To: <9fecb36d-cd58-0a70-ac84-ddaa8edb5030@imag.fr> ("=?UTF-8?Q?Gr=C3=A9gory_?= =?UTF-8?Q?Mouni=C3=A9?="'s message of "Fri, 3 Aug 2018 23:50:47 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149277 Archived-At: tags 32365 + patch forcemerge 32362 32365 quit Gr=C3=A9gory Mouni=C3=A9 writes: > PS: Sorry for generating noise with my previous patch (BUG: 32362) No problem, I'll just merge the bugs. Next time, you can respond to your own bug report by sending mail to xxxxx@debbugs.gnu.org, and the new patch would be added to the same thread. >>>From 6b6291ce1974a363080f535b40f06d5772ffa1be Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Gr=3DC3=3DA9gory=3D20Mouni=3DC3=3DA9?=3D > Date: Fri, 3 Aug 2018 23:08:10 +0200 > Subject: [PATCH] Interactive Highlighting: prefix argument to select sube= xp > > Use prefix-argument to highlight only the corresponding > subexpression of the regexp. > > * lisp/hi-lock.el (hi-lock-face-buffer, hi-lock-set-pattern) The message should go after the ChangeLog entry, as in * lisp/hi-lock.el (hi-lock-face-buffer, hi-lock-set-pattern): Use prefix-argument to highlight only the corresponding subexpression of the regexp. And I think we should have a NEWS entry mentioning the new feature too. > -(defun hi-lock-face-buffer (regexp &optional face) > +(defun hi-lock-face-buffer (regexp &optional face subexp) > "Set face of each match of REGEXP to FACE. > Interactively, prompt for REGEXP using `read-regexp', then FACE. > Use the global history list for FACE. > -(defun hi-lock-set-pattern (regexp face) > +(defun hi-lock-set-pattern (regexp face &optional arg) > "Highlight REGEXP with face FACE." You should mention the new arg in the docstrings. =20=20 > + (let* ((subexp (if (null arg) 0 arg)) This kind of thing is usually expressesd as (or arg 0). Though since `arg' is a bit vague, it might be clearer to rename arg as subexp, and then inside the function do (setq subexp (or subexp 0)) > + (let ((overlay (make-overlay (match-beginning subexp) > + (match-end subexp)))) > + (overlay-put overlay 'hi-lock-overlay t) > + (overlay-put overlay 'hi-lock-orverlay-regexp regexp) ^^^^^^^^ Looks like a typo.