narrow-indirect.el. See Narrow Indirect for a description.
Indirect buffers let you have any number of different views of the same buffer/file. Each view is a different buffer, whose content is some region of the original buffer (possibly the whole buffer).
An indirect buffer always has the same text and text properties as its base buffer, but otherwise it is pretty independent.
In particular, you can kill an indirect buffer without affecting its base buffer. You will likely want to kill indirect narrowed buffers rather than widening them.
I use this key binding, to let
C-x 4 n n capture the region as an indirect buffer and visit that buffer in another window:
(define-key ctl-x-4-map "nn" 'ni-narrow-to-region-indirect-other-window)
The three commands defined in
narrow-indirect.el create and visit indirect buffers in another window. But if you want similar commands that do so in a separate frame, just bind
pop-up-frames to non-
nil in your own command. This definition uses the same arguments and
interactive spec as
ni-narrow-to-region-indirect-other-window and then just calls it with those arguments.
(defun my-narrow-to-region-indirect-other-frame (start end here
&optional full-name text msgp)
"`narrow-to-region' in a cloned indirect buffer in another frame.
(list (region-beginning) (region-end) (point)
(and current-prefix-arg (read-string "Buffer name: ")) nil 'MSGP))
(let ((pop-up-frames t))
(ni-narrow-to-region-indirect-other-window start end here full-name text msgp)))
This is what
C-h f ni-narrow-to-region-indirect-other-window tells you:
ni-narrow-to-region-indirect-other-window is an interactive Lisp
It is bound to
C-x 4 n n.
(ni-narrow-to-region-indirect-other-window START END HERE &optional
FULL-NAME TEXT MSGP)
narrow-to-region in a cloned indirect buffer in the other window.
The indirect buffer is named the same as the current buffer, except:
- It is prefixed by the value of option
- It is suffixed by
| TEXT, where
TEXT is the region text,
filtered by collapsing whitespace and (for Emacs 24.4+) removing
invisible text. (Actually, option
" | " is the default value of this option.)
However, the buffer name is in any case truncated at
END are the region beginning and end.
HERE is where to place the cursor, relative to
TEXT is prefixed by
ni-buf-name-separator and appended to the
original buffer name, which is appended to
name the new buffer.
FULL-NAME is a string then it is used as the complete indirect
buffer name. (
TEXT is then ignored.)