summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2010-09-12 13:15:48 +0200
committerDavid Maus <dmaus@ictsoc.de>2010-09-12 18:53:18 +0200
commit60fcd2fa7ec4cf805f13f91f80ad6d73264009f8 (patch)
treed6c0e497fbbef0ab3a5e3d6d598d6f18271e7813
parent59fa0d12c8413cfb8fd00551bffe450df2319f5d (diff)
downloadorg-mode-60fcd2fa7ec4cf805f13f91f80ad6d73264009f8.tar.gz
Replace non-interactive use of `org-next-item' and `org-previous-item'.
* org.el (org-skip-over-state-notes): do not compute bottom point at each item. * org-mouse.el (org-mouse-for-each-item): use `org-apply-on-list' instead of moving to each item.
-rw-r--r--lisp/org-mouse.el14
-rw-r--r--lisp/org.el9
2 files changed, 11 insertions, 12 deletions
diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el
index c47d197..3a5a403 100644
--- a/lisp/org-mouse.el
+++ b/lisp/org-mouse.el
@@ -148,6 +148,7 @@
(declare-function org-agenda-change-all-lines "org-agenda"
(newhead hdmarker &optional fixface just-this))
(declare-function org-verify-change-for-undo "org-agenda" (l1 l2))
+(declare-function org-apply-on-list "org-list" (function init-value &rest args))
(defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
"Regular expression that matches a plain list.")
@@ -576,14 +577,11 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
(goto-char (second contextdata))
(re-search-forward ".*" (third contextdata))))))
-(defun org-mouse-for-each-item (function)
- (save-excursion
- (ignore-errors
- (while t (org-previous-item)))
- (ignore-errors
- (while t
- (funcall function)
- (org-next-item)))))
+(defun org-mouse-for-each-item (funct)
+ ;; Functions called by `org-apply-on-list' need an argument
+ (let ((wrap-fun (lambda (c) (funcall funct))))
+ (when (org-in-item-p)
+ (org-apply-on-list wrap-fun nil))))
(defun org-mouse-bolp ()
"Return true if there only spaces, tabs, and '*' before point.
diff --git a/lisp/org.el b/lisp/org.el
index 6d8dfdc..1c3b064 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11775,10 +11775,11 @@ EXTRA is additional text that will be inserted into the notes buffer."
(defun org-skip-over-state-notes ()
"Skip past the list of State notes in an entry."
(if (looking-at "\n[ \t]*- State") (forward-char 1))
- (while (looking-at "[ \t]*- State")
- (condition-case nil
- (org-next-item)
- (error (org-end-of-item)))))
+ (when (org-in-item-p)
+ (let ((limit (org-list-bottom-point)))
+ (while (looking-at "[ \t]*- State")
+ (goto-char (or (org-get-next-item (point) limit)
+ (org-get-end-of-item limit)))))))
(defun org-add-log-note (&optional purpose)
"Pop up a window for taking a note, and add this note later at point."