From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#17401: 24.4.50; Narrow to {region,page,defun} in an indirect clone buffer in the other window Date: Fri, 18 Sep 2020 15:57:33 +0200 Message-ID: <87ft7fgpbm.fsf@gnus.org> References: <53661891.40206@orcon.net.nz> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4899"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 17401@debbugs.gnu.org, contact@zaneashby.co.nz To: Phil Sainty Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 18 15:58:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJGtv-00019Q-Cu for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Sep 2020 15:58:11 +0200 Original-Received: from localhost ([::1]:44954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJGtu-0003QZ-6v for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Sep 2020 09:58:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJGtm-0003PJ-NO for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 09:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60540) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJGtm-0006HB-Cx for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 09:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kJGtm-0006XC-Bf for bug-gnu-emacs@gnu.org; Fri, 18 Sep 2020 09:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Sep 2020 13:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17401 X-GNU-PR-Package: emacs Original-Received: via spool by 17401-submit@debbugs.gnu.org id=B17401.160043747025055 (code B ref 17401); Fri, 18 Sep 2020 13:58:02 +0000 Original-Received: (at 17401) by debbugs.gnu.org; 18 Sep 2020 13:57:50 +0000 Original-Received: from localhost ([127.0.0.1]:43850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJGtZ-0006W3-Mw for submit@debbugs.gnu.org; Fri, 18 Sep 2020 09:57:50 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:54706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJGtX-0006Vp-9b for 17401@debbugs.gnu.org; Fri, 18 Sep 2020 09:57:48 -0400 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=sa1XRt6o3BZrPzme7Wdw4QTWjfa+kndhQk9w91prGOA=; b=uatAh3e9RAkmmRM53ZzeytJM0+ tHf6Is0N36Az+VsceDKicBJWc0m5391U2CQSMEASpAh55nggbOK9kgLL52dx2LN3U51ht0hs58WZm wQHcykVvOaem6q63OZzP2vGxbRx97LLlw3MXg3eZQqfl+PhUz4YxF2MgU03jkkDI5Kb8=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJGtK-0006Xu-Fn; Fri, 18 Sep 2020 15:57:40 +0200 X-Now-Playing: Stina Nordenstam's _The World Is Saved_: "Butterfly" In-Reply-To: <53661891.40206@orcon.net.nz> (Phil Sainty's message of "Sun, 04 May 2014 22:38:09 +1200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188312 Archived-At: Phil Sainty writes: > That post provides a function which creates a indirect clone of > the current buffer, and narrows to the marked region in that, so > that you have both the original un-narrowed buffer and the narrowed > indirect clone available simultaneously. > > This is incredibly useful, and it seems like an obvious contender > for standard functionality in Emacs. > > I'm attaching a patch which uses that approach to implement the > following functions and bindings: > > C-x 4 n n: narrow-to-region-indirect-other-window > C-x 4 n p: narrow-to-page-indirect-other-window > C-x 4 n d: narrow-to-defun-indirect-other-window Sounds like a good idea to me, and seems to be a logical extension. Anybody got an opinion? However: > It's still essentially Zane's code, so I've confirmed that he's > happy for me to send this, and am CCing this to him. We'd need copyright assignment papers for something like this. Zane, would you be willing to assign copyright for this code to the FSF? diff --git a/lisp/bindings.el b/lisp/bindings.el index a1751a253c..e2b4ceb08e 100644 --- a/lisp/bindings.el +++ b/lisp/bindings.el @@ -1418,6 +1418,9 @@ esc-map (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) (define-key ctl-x-4-map "c" 'clone-indirect-buffer-other-window) +(define-key ctl-x-4-map "nn" 'narrow-to-region-indirect-other-window) +(define-key ctl-x-4-map "np" 'narrow-to-page-indirect-other-window) +(define-key ctl-x-4-map "nd" 'narrow-to-defun-indirect-other-window) ;; Signal handlers (define-key special-event-map [sigusr1] 'ignore) diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 8c18557c79..94edd8fdd6 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -647,6 +647,16 @@ narrow-to-defun (re-search-backward "^\n" (- (point) 1) t) (narrow-to-region beg end)))) +(defun narrow-to-defun-indirect-other-window (&optional arg) + "`narrow-to-defun' in a cloned indirect buffer in the other window. + +See `clone-indirect-buffer'." + (interactive) + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-defun arg)) + (pop-to-buffer buf))) + (defcustom insert-pair-alist '((?\( ?\)) (?\[ ?\]) (?\{ ?\}) (?\< ?\>) (?\" ?\") (?\' ?\') (?\` ?\')) "Alist of paired characters inserted by `insert-pair'. diff --git a/lisp/simple.el b/lisp/simple.el index 7dc695848b..8e360a0076 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -8947,6 +8947,16 @@ clone-indirect-buffer-other-window (let ((pop-up-windows t)) (clone-indirect-buffer newname display-flag norecord))) +(defun narrow-to-region-indirect-other-window (start end) + "`narrow-to-region' in a cloned indirect buffer in the other window. + +See `clone-indirect-buffer'." + (interactive "r") + (deactivate-mark) + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-region start end)) + (pop-to-buffer buf))) ;;; Handling of Backspace and Delete keys. diff --git a/lisp/textmodes/page.el b/lisp/textmodes/page.el index 029ba96691..e729c020a7 100644 --- a/lisp/textmodes/page.el +++ b/lisp/textmodes/page.el @@ -143,6 +143,16 @@ page--count-lines-page (count-lines (point) opoint) (count-lines opoint end)))))) +(defun narrow-to-page-indirect-other-window (&optional arg) + "`narrow-to-page' in a cloned indirect buffer in the other window. + +See `clone-indirect-buffer'." + (interactive "P") + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-page arg)) + (pop-to-buffer buf))) + (defun count-lines-page () "Report number of lines on current page, and how many are before or after point." (interactive) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no