all repos — nixfiles @ 55b9f757183ff0e603482f7a085bab75a1a8643d

System and user configuration, managed by nix and home-manager

Emacs: add narrow-to-function-indirect function

Alan Pearce
commit

55b9f757183ff0e603482f7a085bab75a1a8643d

parent

f942db6269c28f7aab01fe7a50d15c0f9798747f

1 file changed, 10 insertions(+), 0 deletions(-)

jump to
M emacs/elisp/ap-functions.elemacs/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)