diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-05-07 23:23:12 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-05-07 23:23:12 +0200 |
commit | 0c03971b09b1354367822b1117f8c73dbf13bc9d (patch) | |
tree | 16f18f9543de47441dd1cbe532fb62c5b82ea853 | |
parent | a8a8f70039954be3bffae13b059428ccef252966 (diff) | |
download | org-mode-0c03971b09b1354367822b1117f8c73dbf13bc9d.tar.gz |
org-list: Avoid unnecessary call to `org-in-item-p'
* lisp/org-list.el (org-list-insert-item): Compute item containing POS
based on the list structure instead of the buffer.
-rw-r--r-- | lisp/org-list.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lisp/org-list.el b/lisp/org-list.el index ba92217..37d245a 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -1258,10 +1258,18 @@ function ends. This function modifies STRUCT." (let ((case-fold-search t)) - ;; 1. Get information about list: position of point with regards - ;; to item start (BEFOREP), blank lines number separating items - ;; (BLANK-NB), if we're allowed to (SPLIT-LINE-P). - (let* ((item (progn (goto-char pos) (goto-char (org-list-get-item-begin)))) + ;; 1. Get information about list: ITEM containing POS, position of + ;; point with regards to item start (BEFOREP), blank lines + ;; number separating items (BLANK-NB), if we're allowed to + ;; (SPLIT-LINE-P). + (let* ((item (goto-char (catch :exit + (let ((inner-item 0)) + (pcase-dolist (`(,i . ,_) struct) + (cond + ((= i pos) (throw :exit i)) + ((< i pos) (setq inner-item i)) + (t (throw :exit inner-item)))) + inner-item)))) (item-end (org-list-get-item-end item struct)) (item-end-no-blank (org-list-get-item-end-before-blank item struct)) (beforep |