From 3676e9a68db43d789ae82fb18e67ece1578edad7 Mon Sep 17 00:00:00 2001 From: Somelauw Date: Sat, 2 Sep 2017 21:36:55 +0200 Subject: Add variable `evil-org-retain-visual-state-on-shift`. --- doc/changelog.org | 1 + doc/keythemes.org | 2 ++ evil-org.el | 46 +++++++++++++++++++++++++++------------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/doc/changelog.org b/doc/changelog.org index 7bab9ff..993cff8 100644 --- a/doc/changelog.org +++ b/doc/changelog.org @@ -1,6 +1,7 @@ * Version 0.9 - Make =I= / =A= ignore ellipses on heading. Also make them respect =org-special-ctrl-a/e=. - Make it possible for =<= and =>= (renamed to evil-org-) to move table columns. + - Introduce variable =evil-org-retain-visual-state-on-shift=. This variable mimics =dotspacemacs-retain-visual-state= in Spacemacs. * Version 0.8 - Make evil-org-a-greater-org-object (=ar=), evil-org-inner/a-subtree (=iR=, =aR=) text objects linewise. The other text objects remain characterwise. - Improvements to =o/O= diff --git a/doc/keythemes.org b/doc/keythemes.org index 29e1475..1b72b5d 100644 --- a/doc/keythemes.org +++ b/doc/keythemes.org @@ -45,6 +45,8 @@ | =<= | evil-org-< | Promote all headings in marked area | | =>= | evil-org-< | Demote all headings in marked area | |-----+------------+-------------------------------------| + + Variable =evil-org-retain-visual-state-on-shift= controls whether the selection should be restored after promoting / indenting, which is helpful if you want to promote / indent multiple times. By default this variable is set to =nil=. Examples: - =>>= to promote a heading diff --git a/evil-org.el b/evil-org.el index 76d944f..87a6f38 100644 --- a/evil-org.el +++ b/evil-org.el @@ -7,7 +7,7 @@ ;; Git-Repository: git://github.com/Somelauw/evil-org-mode.git ;; Created: 2012-06-14 ;; Forked-since: 2017-02-12 -;; Version: 0.9.4 +;; Version: 0.9.5 ;; Package-Requires: ((emacs "24.4") (evil "1.0") (org "8.0.0")) ;; Keywords: evil vim-emulation org-mode key-bindings presets @@ -49,6 +49,23 @@ :prefix "evil-org-") ;;; Customizations +(defcustom evil-org-key-theme + (if (bound-and-true-p evil-disable-insert-state-bindings) + '(navigation textobjects additional) + '(navigation insert textobjects additional)) + "Which key themes to enable. +If you use this variable, you should call `evil-org-set-key-theme' with zero +arguments." + :group 'evil-org + :type '(set (const navigation) + (const insert) + (const textobjects) + (const rsi) + (const additional) + (const shift) + (const todo) + (const heading))) + (defcustom evil-org-movement-bindings '((up . "k") (down . "j") @@ -65,23 +82,6 @@ This can be used by non-qwerty users who don't use hjkl." :group 'evil-org :type 'boolean) -(defcustom evil-org-key-theme - (if (bound-and-true-p evil-disable-insert-state-bindings) - '(textobjects navigation additional) - '(textobjects navigation insert additional)) - "Which key themes to enable. -If you use this variable, you should call `evil-org-set-key-theme' with zero -arguments." - :group 'evil-org - :type '(set (const navigation) - (const textobjects) - (const insert) - (const rsi) - (const additional) - (const shift) - (const todo) - (const heading))) - (defcustom evil-org-special-o/O '(table-row item) "When o and O should be special. This makes them continue item lists and table rows. @@ -89,6 +89,11 @@ By default, o and O are bound to ‘evil-org-open-above’ and ‘evil-org-open- :group 'evil-org :type '(set (const table-row) (const item))) +(defcustom evil-org-retain-visual-state-on-shift nil + "Whether < and > should retain selection when used in visual state." + :group 'evil-org + :type 'boolean) + ;; Constants (defconst evil-org-special-o/O-ignore (append '(latex-environment drawer property-drawer) @@ -332,7 +337,10 @@ In tables, move column to the right." (when (and (not (region-active-p)) (org-at-table-p)) (setq beg (min beg (org-table-begin))) (setq end (max end (org-table-end)))) - (evil-shift-right beg end count)))) + (evil-shift-right beg end count))) + (when (and evil-org-retain-visual-state-on-shift (evil-visual-state-p)) + (evil-normal-state) + (evil-visual-restore))) (evil-define-operator evil-org-< (beg end count) "Promote, dedent, move column left. -- cgit v1.0