diff options
| author | Axel Forsman <axel@axelf.se> | 2024-04-24 21:45:21 +0200 |
|---|---|---|
| committer | Axel Forsman <axel@axelf.se> | 2024-04-30 19:30:57 +0200 |
| commit | 55f29f07e31c408931e3569066c2050c48dd882b (patch) | |
| tree | 704b65b84910eb274f1a47f1d6975cc4b04285f4 /evil-common.el | |
| parent | b6629aef2c196a6910b9fcdefad2c34b4cf4f0c1 (diff) | |
Small cleanups
Diffstat (limited to 'evil-common.el')
| -rw-r--r-- | evil-common.el | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/evil-common.el b/evil-common.el index 82eaddb..fd259d6 100644 --- a/evil-common.el +++ b/evil-common.el @@ -917,28 +917,26 @@ so it is more compatible with Evil's notion of EOL tracking." "Restrict the buffer to BEG and END. BEG or END may be nil, specifying a one-sided restriction including `point-min' or `point-max'. See also `evil-with-restriction.'" + (declare (obsolete nil "1.15.0")) (narrow-to-region (if beg (max beg (point-min)) (point-min)) (if end (min end (point-max)) (point-max)))) (defmacro evil-with-restriction (beg end &rest body) "Execute BODY with the buffer narrowed to BEG and END. -BEG or END may be nil as passed to `evil-narrow'; this creates -a one-sided restriction." - (declare (indent 2) - (debug t)) +BEG or END may be nil to specify a one-sided restriction." + (declare (indent 2) (debug t)) `(save-restriction (let ((evil-restriction-stack (cons (cons (point-min) (point-max)) evil-restriction-stack))) - (evil-narrow ,beg ,end) + (narrow-to-region (or ,beg (point-min)) (or ,end (point-max))) ,@body))) (defmacro evil-without-restriction (&rest body) "Execute BODY with the top-most narrowing removed. This works only if the previous narrowing has been generated by `evil-with-restriction'." - (declare (indent defun) - (debug t)) + (declare (indent defun) (debug t)) `(save-restriction (widen) (narrow-to-region (car (car evil-restriction-stack)) @@ -2932,8 +2930,8 @@ linewise, otherwise it is character wise." (objbnd (let ((wsend (evil-with-restriction ;; restrict to current line if we do non-line selection - (and (not line) (line-beginning-position)) - (and (not line) (line-end-position)) + (unless line (line-beginning-position)) + (unless line (line-end-position)) (evil-bounds-of-not-thing-at-point thing dir)))) (cond (wsend @@ -2947,11 +2945,11 @@ linewise, otherwise it is character wise." (setq wsend (evil-with-restriction ;; restrict to current line if we do non-line selection - (and (not line) - (if (member thing '(evil-word evil-WORD)) - (save-excursion (back-to-indentation) (point)) - (line-beginning-position))) - (and (not line) (line-end-position)) + (unless line + (if (member thing '(evil-word evil-WORD)) + (save-excursion (back-to-indentation) (point)) + (line-beginning-position))) + (unless line (line-end-position)) (evil-bounds-of-not-thing-at-point thing (- dir)))) (when wsend (setq other wsend addcurrent t))))))) ;; current match is whitespace, add thing @@ -3764,14 +3762,8 @@ should be left-aligned for left justification." (let ((fill-column position) adaptive-fill-mode fill-prefix) (evil-with-restriction - (save-excursion - (goto-char beg) - (line-beginning-position)) - (save-excursion - (goto-char end) - (if (bolp) - (line-end-position 0) - (line-end-position))) + (save-excursion (goto-char beg) (line-beginning-position)) + (save-excursion (goto-char end) (line-end-position (if (bolp) 0 1))) (goto-char (point-min)) (while (progn (if (eq justify 'left) |
