From: Lennart Borgman <lennart.borgman@gmail.com>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: 17401@debbugs.gnu.org, contact@zaneashby.co.nz
Subject: bug#17401: 24.4.50; Narrow to {region,page,defun} in an indirect clone buffer in the other window
Date: Thu, 8 May 2014 02:05:33 +0200 [thread overview]
Message-ID: <CANbX365u-6RuzYVUD1nQvEb2_vEaRgmm3C+JqJEJa6ktWBjLbw@mail.gmail.com> (raw)
In-Reply-To: <53661891.40206@orcon.net.nz>
[-- Attachment #1: Type: text/plain, Size: 4958 bytes --]
Here is my current version (which I think perhaps Phil can make something
better of):
(defun narrow-to-region-indirect (start end here name-suffix)
"Restrict editing in this buffer to the current region, indirectly."
(interactive (list (region-beginning) (region-end) (region-beginning) ""))
(deactivate-mark)
(let ((posdiff (- here start))
(name (buffer-name))
(line name-suffix))
(save-excursion
(goto-char start)
(while (and (not (eobp)) (string= line ""))
(setq line (buffer-substring-no-properties (point-at-bol)
(point-at-eol)))
(setq line (replace-regexp-in-string "^\s+\\|\s+$" "" line))
(forward-line)))
(let* ((bn (concat name " <" line ">"))
(buf (clone-indirect-buffer bn nil)))
(with-current-buffer buf
(narrow-to-region start end)
(goto-char start)
(forward-char posdiff))
(switch-to-buffer buf))))
(defun narrow-to-defun-indirect ()
"Restrict editing in this buffer to the current function, indirectly."
(interactive)
(require 'which-func)
(let ((here (point))
(suffix (which-function)))
(mark-defun)
(narrow-to-region-indirect (region-beginning) (region-end) here
suffix)))
On Sun, May 4, 2014 at 12:38 PM, Phil Sainty <psainty@orcon.net.nz> wrote:
> I encountered a blog post by Zane Ashby detailing this idea, and it
> was one of those "why did I never think of that?" moments, because
> I was doing this manually on a regular basis.
>
> http://demonastery.org/2013/04/emacs-narrow-to-region-indirect/
>
> 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
>
> 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.
>
>
> -Phil
>
>
>
>
>
> In GNU Emacs 24.4.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
> of 2014-05-03 on xerxes
> Windowing system distributor `The X.Org Foundation', version 11.0.11300000
> System Description: Ubuntu 12.04.4 LTS
>
> Configured using:
> `configure --prefix=/usr/local/src/emacs/usr/local --without-sound'
>
> Configured features:
> XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK DBUS GSETTINGS NOTIFY GNUTLS
> LIBXML2 FREETYPE XFT ZLIB
>
> Important settings:
> value of $LANG: en_NZ.UTF-8
> locale-coding-system: utf-8-unix
>
> Major mode: Lisp Interaction
>
> Minor modes in effect:
> tooltip-mode: t
> electric-indent-mode: t
> mouse-wheel-mode: t
> tool-bar-mode: t
> menu-bar-mode: t
> file-name-shadow-mode: t
> global-font-lock-mode: t
> font-lock-mode: t
> blink-cursor-mode: t
> auto-composition-mode: t
> auto-encryption-mode: t
> auto-compression-mode: t
> line-number-mode: t
> transient-mark-mode: t
>
> Recent input:
> <help-echo> M-x r e p o r t - e m <tab> <return>
>
> Recent messages:
> For information about GNU Emacs and the GNU system, type C-h C-a.
> user-error: End of history; no default available
>
> Load-path shadows:
> None found.
>
> Features:
> (shadow sort gnus-util mail-extr emacsbug message dired format-spec
> rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
> rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
> ietf-drums mm-util help-fns mail-prsvr mail-utils time-date tooltip
> electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
> tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
> lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
> scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
> georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
> korean japanese hebrew greek romanian slovak czech european ethiopic
> indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
> abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files
> text-properties overlay sha1 md5 base64 format env code-pages mule
> custom widget hashtable-print-readable backquote make-network-process
> dbusbind gfilenotify dynamic-setting system-font-setting
> font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)
>
> Memory information:
> ((conses 16 74917 6338)
> (symbols 48 17834 0)
> (miscs 40 35 138)
> (strings 32 10321 4869)
> (string-bytes 1 288458)
> (vectors 16 9191)
> (vector-slots 8 374331 12806)
> (floats 8 63 98)
> (intervals 56 170 0)
> (buffers 960 11)
> (heap 1024 19710 771))
>
>
>
[-- Attachment #2: Type: text/html, Size: 6287 bytes --]
next prev parent reply other threads:[~2014-05-08 0:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-04 10:38 bug#17401: 24.4.50; Narrow to {region,page,defun} in an indirect clone buffer in the other window Phil Sainty
2014-05-04 13:43 ` Drew Adams
2014-05-08 0:05 ` Lennart Borgman [this message]
2014-05-10 13:06 ` Phil Sainty
2014-05-10 20:57 ` Josh
2014-05-11 4:12 ` Drew Adams
2020-09-18 13:57 ` Lars Ingebrigtsen
2020-09-18 16:02 ` Drew Adams
2020-09-18 21:22 ` Zane Ashby
2020-09-19 14:14 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANbX365u-6RuzYVUD1nQvEb2_vEaRgmm3C+JqJEJa6ktWBjLbw@mail.gmail.com \
--to=lennart.borgman@gmail.com \
--cc=17401@debbugs.gnu.org \
--cc=contact@zaneashby.co.nz \
--cc=psainty@orcon.net.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.