From 55b9f757183ff0e603482f7a085bab75a1a8643d Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 10 Apr 2014 19:32:18 +0100 Subject: Emacs: add narrow-to-function-indirect function --- emacs/elisp/ap-functions.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'emacs/elisp/ap-functions.el') diff --git a/emacs/elisp/ap-functions.el b/emacs/elisp/ap-functions.el index 19f63320..37b8863d 100644 --- a/emacs/elisp/ap-functions.el +++ b/emacs/elisp/ap-functions.el @@ -34,4 +34,14 @@ (command (read-shell-command "Shell command: " nil nil nil))) (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer))) +;;;###autoload +(defun narrow-to-region-indirect (start end) + "Restrict editing in this buffer to the current region, indirectly." + (interactive "r") + (deactivate-mark) + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-region start end)) + (switch-to-buffer buf))) + (provide 'ap-functions) -- cgit 1.4.1