From unknown Fri Jun 20 07:23:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#39122 <39122@debbugs.gnu.org> To: bug#39122 <39122@debbugs.gnu.org> Subject: Status: 27.0.60; occur: Add bindings for next-error-no-select Reply-To: bug#39122 <39122@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:23:14 +0000 retitle 39122 27.0.60; occur: Add bindings for next-error-no-select reassign 39122 emacs submitter 39122 Tino Calancha severity 39122 wishlist thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 13 15:51:22 2020 Received: (at submit) by debbugs.gnu.org; 13 Jan 2020 20:51:23 +0000 Received: from localhost ([127.0.0.1]:60183 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ir6gE-0001EJ-MF for submit@debbugs.gnu.org; Mon, 13 Jan 2020 15:51:22 -0500 Received: from lists.gnu.org ([209.51.188.17]:36138) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ir6gD-0001EC-SH for submit@debbugs.gnu.org; Mon, 13 Jan 2020 15:51:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53694) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ir6gC-0005L1-BP for bug-gnu-emacs@gnu.org; Mon, 13 Jan 2020 15:51:21 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ir6gB-0004Y6-8R for bug-gnu-emacs@gnu.org; Mon, 13 Jan 2020 15:51:20 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:36369) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ir6gB-0004XG-2u for bug-gnu-emacs@gnu.org; Mon, 13 Jan 2020 15:51:19 -0500 Received: by mail-wr1-x42b.google.com with SMTP id z3so10078788wru.3 for ; Mon, 13 Jan 2020 12:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=AsY+KLl4u7j+3eamPVAx6Tpfig1M0ByEr0vlSuFfzWA=; b=gGebMUUEh9Plzjh2N0lVp7g44FvmVw3oIU++i5OQpZII4Yr/uTxuSlwWhPp7OKz5Bt fvZEygIdvOTTM3F5+AKfV+OXJI+TXjXFS5uKMjMRSkugTUHgRQN/wi4evDHgITIPp6qi SEKAlPjkTwmZA8qAzHq0vyqKkJUWHzVwqED3QndLIgeeMS3/8TRaKS7Z29LDqay+umS1 m84Hxpu1O6txB9/Uct7774sxCTDufpnK4b6KjXQyO1YIxflXlC9OIjbxd6DcBDu9lwrK 7i1J9kC3+IsEzbJAu7/jF1u6oOBzXrpIdKznSLVoOFansjXSpQJwcsmzAqmjm6jScYUR 6R5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=AsY+KLl4u7j+3eamPVAx6Tpfig1M0ByEr0vlSuFfzWA=; b=mUswRcfWS9ejraFZ00qAzaQME9uA0TLK7IrxuPtMRJJaIf1Xnalxn5Bg2Np4wUvUiW a4/XoDPiU1pBuO4O8pHZQ4cASGBtgNoMyCabNdZkC00gDHDPGc+FGTozgtb0GfcxlJS7 ai3v1MBDUiDk60TIEHVDoBYTVSAWN9QrBRFDCR7ixd5PFCv7TnPRNuvQL7NyYRV6zmS9 XshB2Z541STT14WagQzG9sT9wR0Vr4Rfb1bz+vJ3H5PVl/u9FhiO9Q7zE668n0K1VOpB S7G0uuWHyYa1rpy5VqBWy+Se/LVPr8sNtiojTS4CPr+BH8hg6IeKWCxLlUnNMFveS03f xFlw== X-Gm-Message-State: APjAAAV0wU20y5NAzBbxD3FwknzHi64tUiSMiJBad396D5z13kjzt0c2 Hw78y0A3do3idEW8ff43lNmrkXh5 X-Google-Smtp-Source: APXvYqwlzDmZfx7wwk9U1KFDN/DBdkCBfGHMWkdizINMm52T3AeCW6jmLNvbfhzDDoZJMRG7tViCuA== X-Received: by 2002:adf:ef0b:: with SMTP id e11mr20618251wro.128.1578948677812; Mon, 13 Jan 2020 12:51:17 -0800 (PST) Received: from calancha-pc.dy.bbexcite.jp ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id u1sm15869514wmc.5.2020.01.13.12.51.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 12:51:17 -0800 (PST) From: Tino Calancha To: bug-gnu-emacs@gnu.org Subject: 27.0.60; occur: Add bindings for next-error-no-select Date: Mon, 13 Jan 2020 21:51:16 +0100 Message-ID: <87a76rt70b.fsf@calancha-pc.dy.bbexcite.jp> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b X-Spam-Score: 0.7 (/) 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.3 (--) Severity: wishlist X-Debbugs-Cc: Juri Linkov I wish having `next-error-no-select', `previous-error-no-select' bound to `n' and `p' in the occur mode, as we have in *grep* buffer. AFAICS, we have all the infrastructure and it's just a matter of define the bindings at `occur-mode-map'. --8<-----------------------------cut here---------------start------------->8--- commit 72617bd49b151772d3c709bfa489d0a8f14bf408 Author: Tino Calancha Date: Mon Jan 13 21:37:39 2020 +0100 occur: Add bindings for next-error-no-select Add bindings to navigate the matches without select their buffers. * lisp/replace.el (occur-mode-map): Bind n to next-error-no-select and p to previous-error-no-select. * etc/NEWS (Changes in Specialized Modes and Packages in Emacs 27.1): Annonce this change. diff --git a/etc/NEWS b/etc/NEWS index 031ddf5800..572dfbbcf0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -688,6 +688,8 @@ same as the 'C-x C-+' and 'C-x C--' commands. * Changes in Specialized Modes and Packages in Emacs 27.1 +** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and +'previous-error-no-select' bound to 'p'. --- ** New HTML mode skeleton 'html-id-anchor'. This new command (which inserts an _ skeleton) is diff --git a/lisp/replace.el b/lisp/replace.el index a0b050637e..3c1918a257 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -1106,6 +1106,8 @@ occur-mode-map (define-key map "\C-m" 'occur-mode-goto-occurrence) (define-key map "o" 'occur-mode-goto-occurrence-other-window) (define-key map "\C-o" 'occur-mode-display-occurrence) + (define-key map "n" 'next-error-no-select) + (define-key map "p" 'previous-error-no-select) (define-key map "\M-n" 'occur-next) (define-key map "\M-p" 'occur-prev) (define-key map "r" 'occur-rename-buffer) --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 27.0.60 (build 48, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2020-01-13 built on calancha-pc.dy.bbexcite.jp Repository revision: d645628e3cf6ebe5eaea3b40100bd77b9c823f8b Repository branch: emacs-27 Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 13 18:48:12 2020 Received: (at 39122) by debbugs.gnu.org; 13 Jan 2020 23:48:12 +0000 Received: from localhost ([127.0.0.1]:60396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ir9RM-000696-GS for submit@debbugs.gnu.org; Mon, 13 Jan 2020 18:48:12 -0500 Received: from dog.birch.relay.mailchannels.net ([23.83.209.48]:56798) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ir9RK-00068r-6t; Mon, 13 Jan 2020 18:48:11 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3756BE08DF; Mon, 13 Jan 2020 23:48:08 +0000 (UTC) Received: from pdx1-sub0-mail-a36.g.dreamhost.com (100-96-87-46.trex.outbound.svc.cluster.local [100.96.87.46]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 88698E0AF6; Mon, 13 Jan 2020 23:48:07 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Received: from pdx1-sub0-mail-a36.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Mon, 13 Jan 2020 23:48:08 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Macabre-Language: 2e0d93c500dd25f5_1578959287786_1068062446 X-MC-Loop-Signature: 1578959287786:1315386257 X-MC-Ingress-Time: 1578959287786 Received: from pdx1-sub0-mail-a36.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a36.g.dreamhost.com (Postfix) with ESMTP id 1EAA2950C7; Mon, 13 Jan 2020 15:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=linkov.net; bh=mKKjHUiesGMf2Vdd0uxYfIz4ZpU=; b=mNhSovsSkjZxJp EpvJYSlO0E3Hp4+bV//WQ0cAZa6PSmViRnXakytgBxVIYGwX9IvNLYNa2ZidCPGm Lv2n8d3auK7jdOUJ0EjnVYt0BqZzHCkqIkjTjCRPLFYu+qf1aXPuLn6+3Us728oA EvkZtyBZZfsDNq130hV2CcqYNZp5A= Received: from mail.jurta.org (m91-129-103-172.cust.tele2.ee [91.129.103.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a36.g.dreamhost.com (Postfix) with ESMTPSA id 3BA28952DE; Mon, 13 Jan 2020 15:47:59 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a36 From: Juri Linkov To: Tino Calancha Subject: Re: bug#39122: 27.0.60; occur: Add bindings for next-error-no-select Organization: LINKOV.NET References: <87a76rt70b.fsf@calancha-pc.dy.bbexcite.jp> Date: Tue, 14 Jan 2020 01:14:08 +0200 Message-ID: <87d0bndk5b.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.60 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39122 Cc: 39122@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.0 (-) merge 39121 39122 thanks > I wish having `next-error-no-select', `previous-error-no-select' bound to `n' > and `p' in the occur mode, as we have in *grep* buffer. > > AFAICS, we have all the infrastructure and it's just a matter of define > the bindings at `occur-mode-map'. It's a good idea to make occur more consistent with grep/compile, thanks. From debbugs-submit-bounces@debbugs.gnu.org Thu May 21 17:05:41 2020 Received: (at 39122) by debbugs.gnu.org; 21 May 2020 21:05:41 +0000 Received: from localhost ([127.0.0.1]:57414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbsNi-0007Cv-Ks for submit@debbugs.gnu.org; Thu, 21 May 2020 17:05:41 -0400 Received: from mail-ed1-f49.google.com ([209.85.208.49]:43446) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbsNg-0007Cc-0F; Thu, 21 May 2020 17:05:32 -0400 Received: by mail-ed1-f49.google.com with SMTP id g9so7699653edw.10; Thu, 21 May 2020 14:05:31 -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; bh=Gh0In0Sw3/DFIHanx9EMO6T9hwLiLi7ZJlvMMAjaJOc=; b=HLoUNiQOfu1RD+ExrtKotUna+sEQAc9qYgGGHrIbZyR6+iyfhxu1eIQbbU5/Bmfotk KE2S+AiUZpCmgBlo3mIJ1hEz1Hf2jdeIsIrBHYf/UIXMajwqmo0MYOsbte/8dbOEkXxj jX88MWeXxOmaIPPBfjuN5gd+AVVxAg5xjqrkYStIqjRISw9J0ZRGi/WY1HpIOoavse1Q i8yW4LU8ptvyxl5JUmhemxouplqC9rG+6Kf/qaVOwlr0UKAA7fsMdpmJPmCnmagO7k0h B37NwPAqT4BjvuFH6vUErUTy6jxZo8sr9zdqcG5pekSH9qYQcz6CMGEXVUWbKkZO9jKJ 7YyA== 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; bh=Gh0In0Sw3/DFIHanx9EMO6T9hwLiLi7ZJlvMMAjaJOc=; b=JF1xodbsdwswN3gR/F2RG0bLWdszvF6QY32mjmeBCrVS92S+rfgUbRMdKfqlu7KHVg 5pyv5dfBoJV7trIS0hzKcA3UJIX2jZ4Cacj2SY1ax8mmoOgskDwUsOJPkMaksAPWzM5C hQB8DpEths/EbS5pqY8Jxkj6Q7e0A+Jd1OPEPZ+OQwRvYZd11CM32CqXlj6jxNIhJYW7 tW+KF3mpESA+6YNoTQbHdkUVoITptd4tJEhZ1cRqisWFF4irJ4jwfU8I8mECsjQkEU66 4ZDkD/dpHG5LQpMElUOq5BWHcL+4uSw962LeulCerB6DhWnnavljquXI2Fw6IRJYSwXz nN4w== X-Gm-Message-State: AOAM532bpVBPZXhl5FRV3SpNIRjKr/2CNdrIA65F3LmucmuxY6QCYtCq DvqMjozCYusJ3eG1YLWdB58VpjOHkYA= X-Google-Smtp-Source: ABdhPJz56WPlM1t7Es9igJb0B4wt+Ogi24vacV75ZqwSBTxoUDSPPQeW0gGWkLGJYQf1GQjDH6obSA== X-Received: by 2002:aa7:d2d0:: with SMTP id k16mr548244edr.272.1590095125314; Thu, 21 May 2020 14:05:25 -0700 (PDT) Received: from calancha-pc.dy.bbexcite.jp ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id z23sm5837573ejx.72.2020.05.21.14.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 14:05:24 -0700 (PDT) From: Tino Calancha To: Juri Linkov Subject: Re: bug#39122: 27.0.60; occur: Add bindings for next-error-no-select References: <87a76rt70b.fsf@calancha-pc.dy.bbexcite.jp> <87d0bndk5b.fsf@mail.linkov.net> Date: Thu, 21 May 2020 23:05:15 +0200 In-Reply-To: <87d0bndk5b.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 14 Jan 2020 01:14:08 +0200") Message-ID: <878shlov78.fsf@calancha-pc.dy.bbexcite.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 39122 Cc: 39121@debbugs.gnu.org, 39122@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.0 (-) Juri Linkov writes: > merge 39121 39122 > thanks > >> I wish having `next-error-no-select', `previous-error-no-select' bound to `n' >> and `p' in the occur mode, as we have in *grep* buffer. > It's a good idea to make occur more consistent with grep/compile, thanks. Hi Juri, I have refined the patch so that we have visual feedback during the navigation (i.e. highligh) as `grep' does. --8<-----------------------------cut here---------------start------------->8--- commit 7d5917d0a2eda1782b9461951e40bfb837bc75ab Author: Tino Calancha Date: Thu May 21 22:36:00 2020 +0200 occur: Add bindings for next-error-no-select Make the navigation in the occur buffer closer to the navigation in the compilation buffer. Add bindings to navigate the occur matches (Bug#39121). Honor `next-error-highlight' and `next-error-highlight-no-select' when navigating the occurrences. * lisp/replace.el (occur-highlight-regexp, occur-highlight-overlay): New variables. (occur-1): Set `occur-highlight-regexp' to the searched regexp. (occur-goto-locus-delete-o, occur--highlight-occurrence): New defuns. (occur-mode-display-occurrence, occur-mode-goto-occurrence): Use `occur--highlight-occurrence'. (occur-mode-map): Bind n to `next-error-no-select' and p to `previous-error-no-select' * etc/NEWS (Changes in Sppecialized Modes and Packages in Emacs 28.1): Announce this change. * test/lisp/replace-tests.el (replace-tests-with-highlighted-occurrence): Add helper macro. (occur-highlight-occurrence): Add test. diff --git a/etc/NEWS b/etc/NEWS index 1bf1403cab..a273a06ef7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -101,6 +101,9 @@ horizontal movements now stop at the edge of the board. * Changes in Specialized Modes and Packages in Emacs 28.1 +** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and +'previous-error-no-select' bound to 'p'. + ** EIEIO: 'oset' and 'oset-default' are declared obsolete. ** New minor mode 'cl-font-lock-built-in-mode' for `lisp-mode'. diff --git a/lisp/replace.el b/lisp/replace.el index f3a71f87fe..69092c16f9 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -757,6 +757,13 @@ regexp-history Maximum length of the history list is determined by the value of `history-length', which see.") +(defvar occur-highlight-regexp t + "Regexp matching part of visited source lines to highlight temporarily. +Highlight entire line if t; don't highlight source lines if nil.") + +(defvar occur-highlight-overlay nil + "Overlay used to temporarily highlight occur matches.") + (defvar occur-collect-regexp-history '("\\1") "History of regexp for occur's collect operation") @@ -1113,6 +1120,8 @@ occur-mode-map (define-key map "\C-m" 'occur-mode-goto-occurrence) (define-key map "o" 'occur-mode-goto-occurrence-other-window) (define-key map "\C-o" 'occur-mode-display-occurrence) + (define-key map "n" 'next-error-no-select) + (define-key map "p" 'previous-error-no-select) (define-key map "\M-n" 'occur-next) (define-key map "\M-p" 'occur-prev) (define-key map "r" 'occur-rename-buffer) @@ -1261,9 +1270,12 @@ occur-mode-goto-occurrence (with-current-buffer (window-buffer (posn-window (event-end event))) (save-excursion (goto-char (posn-point (event-end event))) - (occur-mode-find-occurrence)))))) + (occur-mode-find-occurrence))))) + (regexp occur-highlight-regexp)) (pop-to-buffer (marker-buffer pos)) (goto-char pos) + (let ((end-mk (save-excursion (re-search-forward regexp nil t)))) + (occur--highlight-occurrence pos end-mk)) (when buffer (next-error-found buffer (current-buffer))) (run-hooks 'occur-mode-find-occurrence-hook))) @@ -1277,17 +1289,74 @@ occur-mode-goto-occurrence-other-window (next-error-found buffer (current-buffer)) (run-hooks 'occur-mode-find-occurrence-hook))) +;; Stolen from compile.el +(defun occur-goto-locus-delete-o () + (delete-overlay occur-highlight-overlay) + ;; Get rid of timer and hook that would try to do this again. + (if (timerp next-error-highlight-timer) + (cancel-timer next-error-highlight-timer)) + (remove-hook 'pre-command-hook + #'occur-goto-locus-delete-o)) + +;; Highlight the current visited occurrence. +;; Adapted from `compilation-goto-locus'. +(defun occur--highlight-occurrence (mk end-mk) + (let ((highlight-regexp occur-highlight-regexp)) + (if (timerp next-error-highlight-timer) + (cancel-timer next-error-highlight-timer)) + (unless occur-highlight-overlay + (setq occur-highlight-overlay + (make-overlay (point-min) (point-min))) + (overlay-put occur-highlight-overlay 'face 'next-error)) + (with-current-buffer (marker-buffer mk) + (save-excursion + (if end-mk (goto-char end-mk) (end-of-line)) + (let ((end (point))) + (if mk (goto-char mk) (beginning-of-line)) + (if (and (stringp highlight-regexp) + (re-search-forward highlight-regexp end t)) + (progn + (goto-char (match-beginning 0)) + (move-overlay occur-highlight-overlay + (match-beginning 0) (match-end 0) + (current-buffer))) + (move-overlay occur-highlight-overlay + (point) end (current-buffer))) + (if (or (eq next-error-highlight t) + (numberp next-error-highlight)) + ;; We want highlighting: delete overlay on next input. + (add-hook 'pre-command-hook + #'occur-goto-locus-delete-o) + ;; We don't want highlighting: delete overlay now. + (delete-overlay occur-highlight-overlay)) + ;; We want highlighting for a limited time: + ;; set up a timer to delete it. + (when (numberp next-error-highlight) + (setq next-error-highlight-timer + (run-at-time next-error-highlight nil + 'occur-goto-locus-delete-o)))))) + (when (eq next-error-highlight 'fringe-arrow) + ;; We want a fringe arrow (instead of highlighting). + (setq next-error-overlay-arrow-position + (copy-marker (line-beginning-position)))))) + (defun occur-mode-display-occurrence () "Display in another window the occurrence the current line describes." (interactive) (let ((buffer (current-buffer)) (pos (occur-mode-find-occurrence)) + (regexp occur-highlight-regexp) + (next-error-highlight next-error-highlight-no-select) + (display-buffer-overriding-action + '(nil (inhibit-same-window . t))) window) (setq window (display-buffer (marker-buffer pos) t)) ;; This is the way to set point in the proper window. (save-selected-window (select-window window) (goto-char pos) + (let ((end-mk (save-excursion (re-search-forward regexp nil t)))) + (occur--highlight-occurrence pos end-mk)) (next-error-found buffer (current-buffer)) (run-hooks 'occur-mode-find-occurrence-hook)))) @@ -1612,6 +1681,7 @@ occur-1 (buffer-undo-list t) (occur--final-pos nil)) (erase-buffer) + (set (make-local-variable 'occur-highlight-regexp) regexp) (let ((count (if (stringp nlines) ;; Treat nlines as a regexp to collect. diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index f5cff92d54..aed14c3357 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el @@ -546,4 +546,46 @@ replace-tests--query-replace-undo ?q (string= expected (buffer-string)))))) +(defmacro replace-tests-with-highlighted-occurrence (highlight-locus &rest body) + "Helper macro to test the highlight of matches when navigating occur buffer. + +Eval BODY with `next-error-highlight' and `next-error-highlight-no-select' +bound to HIGHLIGHT-LOCUS." + (declare (indent 1) (debug (form body))) + `(let ((regexp "foo") + (next-error-highlight ,highlight-locus) + (next-error-highlight-no-select ,highlight-locus) + (buffer (generate-new-buffer "test")) + (inhibit-message t)) + (unwind-protect + ;; Local bind to disable the deletion of `occur-highlight-overlay' + (cl-letf (((symbol-function 'occur-goto-locus-delete-o) (lambda ()))) + (with-current-buffer buffer (dotimes (_ 3) (insert regexp ?\n))) + (pop-to-buffer buffer) + (occur regexp) + (pop-to-buffer "*Occur*") + (occur-next) + ,@body) + (kill-buffer buffer) + (kill-buffer "*Occur*")))) + +(ert-deftest occur-highlight-occurrence () + "Test for https://debbugs.gnu.org/39121 ." + (let ((alist '((nil . nil) (0.5 . t) (t . t) (fringe-arrow . nil))) + (check-overlays + (lambda (has-ov) + (eq has-ov (not (null (overlays-in (point-min) (point-max)))))))) + (pcase-dolist (`(,highlight-locus . ,has-overlay) alist) + ;; Visiting occurrences + (replace-tests-with-highlighted-occurrence highlight-locus + (occur-mode-goto-occurrence) + (should (funcall check-overlays has-overlay))) + ;; Displaying occurrences + (replace-tests-with-highlighted-occurrence highlight-locus + (occur-mode-display-occurrence) + (with-current-buffer (marker-buffer + (get-text-property (point) 'occur-target)) + (should (funcall check-overlays has-overlay))))))) + + ;;; replace-tests.el ends here --8<-----------------------------cut here---------------end--------------->8--- In GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version 3.24.5, cairo version 1.16.0) of 2020-05-21 built on calancha-pc.dy.bbexcite.jp Repository revision: d714aa753b744c903d149a1f6c69262d958c313e Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) From debbugs-submit-bounces@debbugs.gnu.org Thu May 21 19:01:28 2020 Received: (at 39122) by debbugs.gnu.org; 21 May 2020 23:01:28 +0000 Received: from localhost ([127.0.0.1]:57550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbuBr-0001Wj-Se for submit@debbugs.gnu.org; Thu, 21 May 2020 19:01:28 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:41267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jbuBp-0001WN-EM; Thu, 21 May 2020 19:01:26 -0400 X-Originating-IP: 91.129.97.200 Received: from mail.gandi.net (m91-129-97-200.cust.tele2.ee [91.129.97.200]) (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id E098D40004; Thu, 21 May 2020 23:01:17 +0000 (UTC) From: Juri Linkov To: Tino Calancha Subject: Re: bug#39122: 27.0.60; occur: Add bindings for next-error-no-select Organization: LINKOV.NET References: <87a76rt70b.fsf@calancha-pc.dy.bbexcite.jp> <87d0bndk5b.fsf@mail.linkov.net> <878shlov78.fsf@calancha-pc.dy.bbexcite.jp> Date: Fri, 22 May 2020 01:33:53 +0300 In-Reply-To: <878shlov78.fsf@calancha-pc.dy.bbexcite.jp> (Tino Calancha's message of "Thu, 21 May 2020 23:05:15 +0200") Message-ID: <87k114aohq.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 39122 Cc: 39121@debbugs.gnu.org, 39122@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 (-) > I have refined the patch so that we have visual feedback during the > navigation (i.e. highligh) as `grep' does. Using highlighting like in grep is a nice addition that makes occur consistent with grep, thanks for this long-awaited feature. From unknown Fri Jun 20 07:23:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 28 Jun 2020 11:24:05 +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 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 15 05:14:03 2021 Received: (at control) by debbugs.gnu.org; 15 Jul 2021 09:14:03 +0000 Received: from localhost ([127.0.0.1]:46808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3xRT-0005R2-H5 for submit@debbugs.gnu.org; Thu, 15 Jul 2021 05:14:03 -0400 Received: from mail1463c50.megamailservers.eu ([91.136.14.63]:42632 helo=mail268c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3xRQ-0005QN-7w for control@debbugs.gnu.org; Thu, 15 Jul 2021 05:14:01 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1626340433; bh=gxI0fH3DpVlrVI/yyqd5k7zR/andIDQmJFBI8C/fViM=; h=From:Subject:Date:To:From; b=qS/FpPnKqd/piyirhOHKIKjcOzK7NHy1zl/+jZ0kkhq/khx8ALDhQ1vq6qO0ZYLMa IbSm56/KKTlBPvT22/9Vcr8qoJ/KUn0of9eNLnR+94+4I0VlkpO0E2iP6/ZAKUCTH3 Nt2P7oKaiq00OA/ho/fawdJeJ0iacMdlfvTy8teE= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail268c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 16F9DoCX019712 for ; Thu, 15 Jul 2021 09:13:52 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Message-Id: Date: Thu, 15 Jul 2021 11:13:49 +0200 To: control@debbugs.gnu.org X-Mailer: Apple Mail (2.3445.104.21) X-CTCH-RefID: str=0001.0A742F23.60EFFC50.003C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=OogxNB3t c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=5j5StdYQXcmdOctsKcAA:9 a=CjuIK1q_8ugA:10 a=xo5jKAKm-U-Zyk2_beg_:22 X-Origin-Country: SE X-Spam-Score: 3.4 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.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 the administrator of that system for details. Content preview: unarchive 39121 Content analysis details: (3.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 2.0 BLANK_SUBJECT Subject is present but empty 0.0 TVD_SPACE_RATIO No description available. 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: control 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.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.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 the administrator of that system for details. Content preview: unarchive 39121 Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 2.0 BLANK_SUBJECT Subject is present but empty 0.0 TVD_SPACE_RATIO No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager unarchive 39121 From unknown Fri Jun 20 07:23:14 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, 24 Aug 2021 11:24:04 +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