summary refs log tree commit diff stats
path: root/emacs/elisp
diff options
context:
space:
mode:
authorAlan Pearce2014-04-10 19:32:18 +0100
committerAlan Pearce2014-04-10 19:32:18 +0100
commit55b9f757183ff0e603482f7a085bab75a1a8643d (patch)
treef686eb717b55fedbb689647bc0479f45298fe2dd /emacs/elisp
parentf942db6269c28f7aab01fe7a50d15c0f9798747f (diff)
downloaddotfiles-55b9f757183ff0e603482f7a085bab75a1a8643d.tar.lz
dotfiles-55b9f757183ff0e603482f7a085bab75a1a8643d.tar.zst
dotfiles-55b9f757183ff0e603482f7a085bab75a1a8643d.zip
Emacs: add narrow-to-function-indirect function
Diffstat (limited to 'emacs/elisp')
-rw-r--r--emacs/elisp/ap-functions.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/emacs/elisp/ap-functions.el b/emacs/elisp/ap-functions.el
index 19f6332..37b8863 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)