diff options
| author | Justin Burkett <justin@burkett.cc> | 2019-08-08 21:50:50 -0400 |
|---|---|---|
| committer | Eivind Fonn <evfonn@gmail.com> | 2019-11-19 11:34:20 +0100 |
| commit | 5365e4d79f7f9c9e04d8d4f9b02b087791c18db2 (patch) | |
| tree | ea047fe8d9012bf3e60a00d431b9d9a1ee0bb6ae /evil-types.el | |
| parent | 92102f3b30d03d1d87b34ae2c01e4bc2013d5129 (diff) | |
Make more commands support visual-line-mode
when evil-respect-visual-line-mode is non-nil, including
evil-change-line, evil-delete-line, and evil-yank-line. Most of the work is done
through the motions evil-line-or-visual-line and
evil-end-of-line-or-visual-line. These motions use visual lines when
visual-line-mode and evil-respect-visual-line-mode are non-nil, and revert back
to standard lines otherwise.
Visual selection via visual lines in the sense of visual-line-mode is supported
by adding a new screen-line type (named to avoid confusion with visual state).
Diffstat (limited to 'evil-types.el')
| -rw-r--r-- | evil-types.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/evil-types.el b/evil-types.el index 2c6b4f2..1e257ef 100644 --- a/evil-types.el +++ b/evil-types.el @@ -141,6 +141,36 @@ line and `evil-want-visual-char-semi-exclusive', then: (format "%s line%s" height (if (= height 1) "" "s"))))) +(evil-define-type screen-line + "Include whole lines, being aware of `visual-line-mode' +when `evil-respect-visual-line-mode' is non-nil." + :one-to-one nil + :expand (lambda (beg end) + (if (or (not evil-respect-visual-line-mode) + (not visual-line-mode)) + (evil-line-expand beg end) + (evil-range + (progn + (goto-char beg) + (save-excursion + (beginning-of-visual-line))) + (progn + (goto-char end) + (save-excursion + ;; `beginning-of-visual-line' reverts to the beginning of the + ;; last visual line if the end of the last line is the end of + ;; the buffer. This would prevent selecting the last screen + ;; line. + (if (= (line-beginning-position 2) (point-max)) + (point-max) + (beginning-of-visual-line 2))))))) + :contract (lambda (beg end) + (evil-range beg (max beg (1- end)))) + :string (lambda (beg end) + (let ((height (count-screen-lines beg end))) + (format "%s screen line%s" height + (if (= height 1) "" "s"))))) + (evil-define-type block "Like `inclusive', but for rectangles: the last column is included." |
