doom-narrow-buffer renamed to doom/narrow-buffer and moved
This commit is contained in:
parent
574a783f7f
commit
0c06514c6f
2 changed files with 27 additions and 23 deletions
|
@ -14,34 +14,17 @@
|
|||
"The name of the buffer to fall back to if no other buffers exist (will create
|
||||
it if it doesn't exist).")
|
||||
|
||||
|
||||
;;
|
||||
;; Functions
|
||||
;;
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-fallback-buffer ()
|
||||
"Returns the fallback buffer, creating it if necessary. By default this is the
|
||||
scratch buffer."
|
||||
(get-buffer-create doom-fallback-buffer))
|
||||
|
||||
;;;###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))))
|
||||
|
||||
|
||||
;; Buffer Life and Death ;;;;;;;;;;;;;;;
|
||||
;;;###autoload
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue