summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.org3
-rw-r--r--doc/keythemes.org37
-rw-r--r--evil-org-test.el20
-rw-r--r--evil-org.el14
4 files changed, 55 insertions, 19 deletions
diff --git a/doc/changelog.org b/doc/changelog.org
index a169996..8ecaee4 100644
--- a/doc/changelog.org
+++ b/doc/changelog.org
@@ -1,3 +1,6 @@
+* Version 1.0
+ - Make =dw= realign tags. Make =dd= renumber lists.
+
* 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.
diff --git a/doc/keythemes.org b/doc/keythemes.org
index bad9eb5..a2d2ea3 100644
--- a/doc/keythemes.org
+++ b/doc/keythemes.org
@@ -11,24 +11,25 @@
** Basic
These keys are always enabled
- |-------+-------------------------------+-----------------------------------------|
- | key | function | explanation |
- |-------+-------------------------------+-----------------------------------------|
- | =TAB= | org-cycle | change folding level of current heading |
- | =0= | evil-org-beginning-of-line | like 0 but can be special* |
- | =$= | evil-org-end-of-line | like $ but can be special* |
- | =I= | evil-org-insert-line | like I but can be special* |
- | =A= | evil-org-append-line | like A but can be special* |
- | =o= | evil-org-open-below | like o but continue tables and items* |
- | =O= | evil-org-open-above | like O but continue tables and items* |
- | =x= | evil-org-delete-char | like x but keep tables and tags aligned |
- | =X= | evil-org-delete-previous-char | like X but keep tables and tags aligned |
- | =(= | org-forward-sentence | next cell in table |
- | =)= | org-backward-sentence | previous cell in table |
- | ={= | org-backward-paragraph | beginning of table |
- | =}= | org-forward-paragraph | end of table |
- |-------+-------------------------------+-----------------------------------------|
-
+ |-------+-------------------------------+--------------------------------------------|
+ | key | function | explanation |
+ |-------+-------------------------------+--------------------------------------------|
+ | =TAB= | org-cycle | change folding level of current heading |
+ | =0= | evil-org-beginning-of-line | like 0 but can be special* |
+ | =$= | evil-org-end-of-line | like $ but can be special* |
+ | =I= | evil-org-insert-line | like I but can be special* |
+ | =A= | evil-org-append-line | like A but can be special* |
+ | =o= | evil-org-open-below | like o but continue tables and items* |
+ | =O= | evil-org-open-above | like O but continue tables and items* |
+ | =d= | evil-org-delete | like d but keep tags aligned and fix lists |
+ | =x= | evil-org-delete-char | like x but keep tables and tags aligned |
+ | =X= | evil-org-delete-previous-char | like X but keep tables and tags aligned |
+ | =(= | org-forward-sentence | next cell in table |
+ | =)= | org-backward-sentence | previous cell in table |
+ | ={= | org-backward-paragraph | beginning of table |
+ | =}= | org-forward-paragraph | end of table |
+ |-------+-------------------------------+--------------------------------------------|
+
* Set =org-special-ctrl-a/e= to =t= to make =org-beginning-of-line= and =org-end-of-line= ignore leading stars or tags on headings. Repeat to toggle. By default it's set to ~nil~.
* =evil-org-insert-line= and =evil-org-append-line= also respect the setting of =org-special-ctrl-a/e=.
* The cases in which =o= and =O= should behave special can be controlled using =evil-org-special-o/O=. By default it's set to ~'(table-row item)~.
diff --git a/evil-org-test.el b/evil-org-test.el
index 2c5fd55..9c5c963 100644
--- a/evil-org-test.el
+++ b/evil-org-test.el
@@ -2,6 +2,7 @@
(require 'ert)
(defmacro evil-org-with (in &rest body)
+ ;; TODO use evil-test-buffer instead
`(with-temp-buffer
;; "hello"
(evil-mode)
@@ -102,5 +103,24 @@
#+END_SRC"
(call-interactively 'evil-org-open-below)))))
+(ert-deftest evil-org-test-delete-list-item ()
+ (should (equal "
+ 1. emacs
+| 2. evil_org"
+ (evil-org-with "
+ 4. emacs
+ 5. |evil
+ 6. evil_org"
+ (evil-org-delete (line-beginning-position)
+ (line-beginning-position 2)
+ 'line)))))
+
+(ert-deftest evil-org-test-delete-tags ()
+ (should (equal "* |heading with some text :testcase:"
+ (evil-org-with
+ "* |Funny heading with some text :testcase:"
+ (let ((w (evil-a-word)))
+ (evil-org-delete (first w) (second w)))))))
+
;; TODO test x and X
;; TODO test < and >
diff --git a/evil-org.el b/evil-org.el
index 5affd2d..7d35329 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.6
+;; Version: 1.0.0
;; Package-Requires: ((emacs "24.4") (evil "1.0") (org "8.0.0"))
;; Keywords: evil vim-emulation org-mode key-bindings presets
@@ -405,6 +405,17 @@ If ARG < 0, move column END to BEG"
(evil-yank beg end type register)
(org-delete-char count)))
+(evil-define-operator evil-org-delete (beg end type register yank-handler)
+ "Like evil-delete, but realigns tags and numbered lists."
+ (interactive "<R><x><y>")
+ (let ((renumber-lists-p (or (< beg (line-beginning-position))
+ (> end (line-end-position)))))
+ (evil-delete beg end type register yank-handler)
+ (cond ((and renumber-lists-p (org-at-item-p))
+ (org-list-repair))
+ ((org-at-heading-p)
+ (org-fix-tags-on-the-fly)))))
+
(defun evil-org-generic-open-links (beg end incog)
"Open org mode links in visual selection.
Argument BEG beginning of region.
@@ -588,6 +599,7 @@ Includes tables, list items and subtrees."
(kbd "A") 'evil-org-append-line
(kbd "o") 'evil-org-open-below
(kbd "O") 'evil-org-open-above
+ (kbd "d") 'evil-org-delete
(kbd "x") 'evil-org-delete-char
(kbd "X") 'evil-org-delete-backward-char
(kbd "<C-return>") (evil-org-define-eol-command