From 61327bf77770d815d71ba84a872a2da3d8fd4a53 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 Mar 2024 03:24:44 -0400 Subject: [PATCH] refactor(lib): use doom-region-{beginning,end} --- lisp/lib/ui.el | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lisp/lib/ui.el b/lisp/lib/ui.el index d2d01e5e3..f564248e4 100644 --- a/lisp/lib/ui.el +++ b/lisp/lib/ui.el @@ -198,12 +198,9 @@ narrowing doesn't affect other windows displaying the same buffer. Call `doom/widen-indirectly-narrowed-buffer' to undo it (incrementally). Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/" - (interactive - (list (or (bound-and-true-p evil-visual-beginning) (region-beginning)) - (or (bound-and-true-p evil-visual-end) (region-end)))) - (unless (region-active-p) - (setq beg (line-beginning-position) - end (line-end-position))) + (interactive (if (region-active-p) + (list (doom-region-beginning) (doom-region-end)) + (list (bol) (eol)))) (deactivate-mark) (let ((orig-buffer (current-buffer))) (with-current-buffer (switch-to-buffer (clone-indirect-buffer nil nil)) @@ -242,12 +239,9 @@ If the current buffer is not an indirect buffer, it is `widen'ed." ;;;###autoload (defun doom/toggle-narrow-buffer (beg end) "Narrow the buffer to BEG END. If narrowed, widen it." - (interactive - (list (or (bound-and-true-p evil-visual-beginning) (region-beginning)) - (or (bound-and-true-p evil-visual-end) (region-end)))) + (interactive (if (region-active-p) + (list (doom-region-beginning) (doom-region-end)) + (list (bol) (eol)))) (if (buffer-narrowed-p) (widen) - (unless (region-active-p) - (setq beg (line-beginning-position) - end (line-end-position))) (narrow-to-region beg end)))