diff --git a/core/autoload/buffers.el b/core/autoload/buffers.el index 80e268417..b79509120 100644 --- a/core/autoload/buffers.el +++ b/core/autoload/buffers.el @@ -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 diff --git a/core/autoload/editor.el b/core/autoload/editor.el index 3188c27c9..d2fc05c13 100644 --- a/core/autoload/editor.el +++ b/core/autoload/editor.el @@ -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)) -