aboutsummaryrefslogtreecommitdiff
path: root/evil-macros.el
diff options
context:
space:
mode:
authorFrank Fischer <frank-fischer@shadow-soft.de>2016-01-05 09:02:05 +0100
committerFrank Fischer <frank-fischer@shadow-soft.de>2016-01-05 09:02:05 +0100
commit9bb25789ece132c7b19f3669622197d81dad537a (patch)
treeab721f8fdab82f8a280d376b5260f6d6e2a39288 /evil-macros.el
parentf1ad2aef3ce54a9adb07df9145433098b3343fea (diff)
Add `evil-text-object-change-visual-type` customization option (fix #607)
Setting this variable to nil causes text-objects not to change the type of the current visual selection. If the resulting visual selection in linewise and the first selected character is a newline character, that character is excluded from the selected range (otherwise the linewise selection would include the corresponding line, which is usually not desired). This is similar to the common exclusive-linewise rule.
Diffstat (limited to 'evil-macros.el')
-rw-r--r--evil-macros.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/evil-macros.el b/evil-macros.el
index affd1f0..42958eb 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -375,7 +375,17 @@ if COUNT is positive, and to the left of it if negative.
;; unless the selection goes the other way
(setq mark (evil-range-beginning range)
point (evil-range-end range)
- type (evil-type range))
+ type (evil-type
+ (if evil-text-object-change-visual-type
+ range
+ (evil-visual-range))))
+ ;; if new type is linewise, do not include a newline
+ ;; as first character
+ (when (and (eq type 'line)
+ (save-excursion
+ (goto-char mark)
+ (and (not (bolp)) (eolp))))
+ (setq mark (1+ mark)))
(when (< dir 0)
(evil-swap mark point))
;; select the union