mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-29 14:33:34 -05:00
doom-narrow-buffer renamed to doom/narrow-buffer and moved
This commit is contained in:
@@ -218,8 +218,29 @@ consistent throughout a selected region, depending on `indent-tab-mode'."
|
||||
(tabify beg end)
|
||||
(untabify beg end)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/narrow-buffer (beg end &optional clone-p)
|
||||
"Restrict editing in this buffer to the current region, indirectly. With CLONE-P,
|
||||
clone the buffer and hard-narrow the selection. If mark isn't active, then widen
|
||||
the buffer (if narrowed).
|
||||
|
||||
Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
|
||||
(interactive "r")
|
||||
(cond ((region-active-p)
|
||||
(deactivate-mark)
|
||||
(when clone-p
|
||||
(let ((old-buf (current-buffer)))
|
||||
(switch-to-buffer (clone-indirect-buffer nil nil))
|
||||
(setq doom-buffer--narrowed-origin old-buf)))
|
||||
(narrow-to-region beg end))
|
||||
(doom-buffer--narrowed-origin
|
||||
(kill-this-buffer)
|
||||
(switch-to-buffer doom-buffer--narrowed-origin)
|
||||
(setq doom-buffer--narrowed-origin nil))
|
||||
(t
|
||||
(widen))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|enable-delete-trailing-whitespace ()
|
||||
"Attaches `delete-trailing-whitespace' to a buffer-local `before-save-hook'."
|
||||
(add-hook 'before-save-hook #'delete-trailing-whitespace nil t))
|
||||
|
||||
|
Reference in New Issue
Block a user