karlheg(a)inetarena.com (Karl M. Hegbloom) writes:
The indirect buffers is really cool. I'm fixing up the
unfinishedness in the `searching.texi' where I editted it when we
added the regexp patches for `*?' and `\(?:'. To explain better,
I'm writing a short code example. It really neat to type the code
in one window narrowed and set to emacs-lisp mode, and have it
appear in the texi window too. :-) Way cool.
You may find this function useful for that purpose:
;; Yeah! We have indirect buffers!
(defun indirectize-buffer ()
(interactive)
(let* ((buf (make-indirect-buffer (current-buffer)
(generate-new-buffer-name "*indirect*")))
(extent (make-extent (point-min) (point-max) buf)))
(put extent 'end-closed t)
(set-extent-keymap extent (make-sparse-keymap))
(define-key (extent-keymap extent) "\C-c\C-c" 'kill-this-buffer)
(when (region-active-p)
(narrow-to-region (region-beginning) (region-end) buf))
(switch-to-buffer buf))
(emacs-lisp-mode)
(font-lock-mode 1))
(global-set-key "\C-ci" 'indirectize-buffer)
Mark the region and press `C-c i'.
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Those who like sausages, laws, and standards are well advised not to
learn how they are made.