Skip to content

Instantly share code, notes, and snippets.

@legumbre
Created July 2, 2013 05:46
Show Gist options
  • Save legumbre/5907024 to your computer and use it in GitHub Desktop.
Save legumbre/5907024 to your computer and use it in GitHub Desktop.
;; advices
(defadvice narrow-to-region (around clone-when-narrowing-already-visible-buffer compile activate)
"Clone an indirect buffer when attempting to narrow the
contents of buffer visible in more than one window."
(save-excursion
(when (> (length (get-buffer-window-list (current-buffer) nil nil)) 1)
(let ((cloned-buffer (clone-indirect-buffer nil t) ))
(switch-to-buffer cloned-buffer t)))
ad-do-it))
(defadvice narrow-to-defun (around clone-when-narrowing-already-visible-buffer compile activate)
"Clone an indirect buffer when attempting to narrow the
contents of buffer visible in more than one window."
(save-excursion
(when (> (length (get-buffer-window-list (current-buffer) nil nil)) 1)
(let ((cloned-buffer (clone-indirect-buffer nil t) ))
(switch-to-buffer cloned-buffer t)))
ad-do-it))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment