summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSomelauw <Somelauw>2017-10-15 17:16:14 +0200
committerSomelauw <Somelauw>2017-10-15 17:28:53 +0200
commit242e637255bbce1694f77f9c05989ff11c97097a (patch)
tree7f3bfd5f5246e9a66419402ffbcb8b3f242ac6d4
parent4e9943680c9dbedfff2f325d79b723f76d3da42f (diff)
Improve and simplify o/O functions.
-rw-r--r--doc/changelog.org3
-rw-r--r--evil-org.el40
2 files changed, 16 insertions, 27 deletions
diff --git a/doc/changelog.org b/doc/changelog.org
index 8ecaee4..0911c2b 100644
--- a/doc/changelog.org
+++ b/doc/changelog.org
@@ -1,6 +1,7 @@
* Version 1.0
- Make =dw= realign tags. Make =dd= renumber lists.
-
+ - Simplify implementation of `evil-org-open-above/below`.
+ - Only continue item lists on first line.
* 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/evil-org.el b/evil-org.el
index 7d35329..238d608 100644
--- a/evil-org.el
+++ b/evil-org.el
@@ -95,11 +95,6 @@ By default, o and O are bound to ‘evil-org-open-above’ and ‘evil-org-open-
:type 'boolean)
;; Constants
-(defconst evil-org-special-o/O-ignore
- (append '(latex-environment drawer property-drawer)
- (cl-remove-if-not (lambda (s) (string-suffix-p "block" (symbol-name s)))
- org-element-all-elements))
- "Org elements on which o/O should not special.")
;;; Variable declarations
(defvar browse-url-generic-program)
@@ -250,15 +245,13 @@ Argument COUNT number of lines to insert.
The behavior in items and tables can be controlled using ‘evil-org-special-o/O’.
Passing in any prefix argument, executes the command without special behavior."
(interactive "P")
- (end-of-visible-line)
- (let* ((special (and (null count) evil-org-special-o/O))
- (ignore (when (memq 'item special) evil-org-special-o/O-ignore))
- (elements (append special ignore))
- (e (org-element-lineage (org-element-at-point) elements t)))
- (cl-case (org-element-type e)
- ((table-row) (org-table-insert-row '(4)) (evil-insert nil))
- ((item) (org-insert-item (org-at-item-checkbox-p)) (evil-insert nil))
- (otherwise (evil-open-below count)))))
+ (end-of-visible-line) ; to make items be inserted at the end
+ (cond ((and (memq 'table-row evil-org-special-o/O) (org-at-table-p))
+ (org-table-insert-row '(4)))
+ ((and (memq 'item evil-org-special-o/O) (org-at-item-p)
+ (org-insert-item (org-at-item-checkbox-p))))
+ ((evil-open-below count)))
+ (evil-insert nil))
(defun evil-org-open-above (count)
"Clever insertion of org item.
@@ -266,18 +259,13 @@ Argument COUNT number of lines to insert.
The behavior in items and tables can be controlled using ‘evil-org-special-o/O’.
Passing in any prefix argument, executes the command without special behavior."
(interactive "P")
- (end-of-visible-line)
- (let* ((special (and (null count) evil-org-special-o/O))
- (ignore (when (memq 'item special) evil-org-special-o/O-ignore))
- (elements (append special ignore))
- (e (org-element-lineage (org-element-at-point) elements t)))
- (cl-case (org-element-type e)
- ((table-row) (org-table-insert-row) (evil-insert nil))
- ((item)
- (beginning-of-line)
- (org-insert-item (org-at-item-checkbox-p))
- (evil-insert nil))
- (otherwise (evil-open-above count)))))
+ (beginning-of-line) ; to make items be inserted at the beginning
+ (cond ((and (memq 'table-row evil-org-special-o/O) (org-at-table-p))
+ (org-table-insert-row))
+ ((and (memq 'item evil-org-special-o/O) (org-at-item-p)
+ (org-insert-item (org-at-item-checkbox-p))))
+ ((evil-open-above count)))
+ (evil-insert nil))
(defmacro evil-org-define-eol-command (cmd)
"Return a function that executes CMD at eol and then enters insert state.