From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: [patch] Run occur command restricted to a region Date: Fri, 30 Dec 2016 01:31:04 +0200 Organization: LINKOV.NET Message-ID: <87shp6uwvj.fsf@mail.linkov.net> References: <87vau3jl6f.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1483054970 5914 195.159.176.226 (29 Dec 2016 23:42:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 29 Dec 2016 23:42:50 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (x86_64-pc-linux-gnu) Cc: Emacs developers To: Tino Calancha Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 30 00:42:46 2016 Return-path: Envelope-to: ged-emacs-devel@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 1cMkLJ-0000Tf-OS for ged-emacs-devel@m.gmane.org; Fri, 30 Dec 2016 00:42:41 +0100 Original-Received: from localhost ([::1]:37736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMkLO-0004rf-PV for ged-emacs-devel@m.gmane.org; Thu, 29 Dec 2016 18:42:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMkLH-0004rN-Qp for emacs-devel@gnu.org; Thu, 29 Dec 2016 18:42:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMkLC-00035F-Vn for emacs-devel@gnu.org; Thu, 29 Dec 2016 18:42:39 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:49666 helo=homiemail-a21.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cMkLC-00034E-Q4 for emacs-devel@gnu.org; Thu, 29 Dec 2016 18:42:34 -0500 Original-Received: from homiemail-a21.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a21.g.dreamhost.com (Postfix) with ESMTP id 2E5B8300074; Thu, 29 Dec 2016 15:42:32 -0800 (PST) Original-Received: from localhost.linkov.net (m83-180-117-39.cust.tele2.ee [83.180.117.39]) (Authenticated sender: jurta@jurta.org) by homiemail-a21.g.dreamhost.com (Postfix) with ESMTPA id 5891E300061; Thu, 29 Dec 2016 15:42:31 -0800 (PST) In-Reply-To: <87vau3jl6f.fsf@gmail.com> (Tino Calancha's message of "Thu, 29 Dec 2016 15:36:56 +0900") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 69.163.253.7 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210977 Archived-At: > is it worth to have versions of `occur' restricting the > search to lines before (after) the current line? > > Maybe there is already a way to do that, and i just ignore it. > I usually just i copy the region into a temporary buffer; then > i run `occur' there. (info "(emacs) Other Repeating Search") says what is the recommended way to do this is: `M-x occur' Prompt for a regexp, and display a list showing each line in the buffer that contains a match for it. The text that matched is highlighted using the `match' face. To limit the search to part of the buffer, narrow to that part (*note Narrowing::). > I just wrote a patch to show my point; it adds the following commands: > 1) occur-backward: for lines before the current one. The name occur-backward falsely implies it uses re-search-backward, and I'm unsure if we need it as a counter part of isearch-backward. > 2) occur-forward: for lines after the current one. > 3) occur-in-region: for lines within the active region. Maybe we should use the same logic of other related commands in replace.el how-many, keep-lines, flush-lines that limit the affected lines to the active region, or when the region is not active, take only lines after the current line. Then we don't need separate commands, and no keys for them.