|
@@ -40,6 +40,9 @@
|
|
|
(defvar org-M-RET-may-split-line)
|
|
(defvar org-M-RET-may-split-line)
|
|
|
(defvar org-complex-heading-regexp)
|
|
(defvar org-complex-heading-regexp)
|
|
|
(defvar org-odd-levels-only)
|
|
(defvar org-odd-levels-only)
|
|
|
|
|
+(defvar org-outline-regexp)
|
|
|
|
|
+(defvar org-ts-regexp)
|
|
|
|
|
+(defvar org-ts-regexp-both)
|
|
|
|
|
|
|
|
(declare-function org-invisible-p "org" ())
|
|
(declare-function org-invisible-p "org" ())
|
|
|
(declare-function org-on-heading-p "org" (&optional invisible-ok))
|
|
(declare-function org-on-heading-p "org" (&optional invisible-ok))
|
|
@@ -55,6 +58,13 @@
|
|
|
(pom property &optional inherit literal-nil))
|
|
(pom property &optional inherit literal-nil))
|
|
|
(declare-function org-narrow-to-subtree "org" ())
|
|
(declare-function org-narrow-to-subtree "org" ())
|
|
|
(declare-function org-show-subtree "org" ())
|
|
(declare-function org-show-subtree "org" ())
|
|
|
|
|
+(declare-function org-in-regexps-block-p "org"
|
|
|
|
|
+ (start-re end-re &optional bound))
|
|
|
|
|
+(declare-function org-level-increment "org" ())
|
|
|
|
|
+(declare-function org-at-heading-p "org" (&optional ignored))
|
|
|
|
|
+(declare-function outline-previous-heading "outline" ())
|
|
|
|
|
+(declare-function org-icompleting-read "org" (&rest args))
|
|
|
|
|
+(declare-function org-time-string-to-seconds "org" (s))
|
|
|
|
|
|
|
|
(defgroup org-plain-lists nil
|
|
(defgroup org-plain-lists nil
|
|
|
"Options concerning plain lists in Org-mode."
|
|
"Options concerning plain lists in Org-mode."
|
|
@@ -63,7 +73,6 @@
|
|
|
|
|
|
|
|
(defcustom org-cycle-include-plain-lists t
|
|
(defcustom org-cycle-include-plain-lists t
|
|
|
"When t, make TAB cycle visibility on plain list items.
|
|
"When t, make TAB cycle visibility on plain list items.
|
|
|
-
|
|
|
|
|
Cycling plain lists works only when the cursor is on a plain list
|
|
Cycling plain lists works only when the cursor is on a plain list
|
|
|
item. When the cursor is on an outline heading, plain lists are
|
|
item. When the cursor is on an outline heading, plain lists are
|
|
|
treated as text. This is the most stable way of handling this,
|
|
treated as text. This is the most stable way of handling this,
|
|
@@ -151,7 +160,6 @@ spaces instead of one after the bullet in each item of the list."
|
|
|
|
|
|
|
|
(defcustom org-list-ending-method 'both
|
|
(defcustom org-list-ending-method 'both
|
|
|
"Determine where plain lists should end.
|
|
"Determine where plain lists should end.
|
|
|
-
|
|
|
|
|
Valid values are: `regexp', `indent' or `both'.
|
|
Valid values are: `regexp', `indent' or `both'.
|
|
|
|
|
|
|
|
When set to `regexp', Org will look into two variables,
|
|
When set to `regexp', Org will look into two variables,
|
|
@@ -173,7 +181,6 @@ determine lists endings. This is the default method."
|
|
|
|
|
|
|
|
(defcustom org-empty-line-terminates-plain-lists nil
|
|
(defcustom org-empty-line-terminates-plain-lists nil
|
|
|
"Non-nil means an empty line ends all plain list levels.
|
|
"Non-nil means an empty line ends all plain list levels.
|
|
|
-
|
|
|
|
|
This variable only makes sense if `org-list-ending-method' is set
|
|
This variable only makes sense if `org-list-ending-method' is set
|
|
|
to `regexp' or `both'. This is then equivalent to set
|
|
to `regexp' or `both'. This is then equivalent to set
|
|
|
`org-list-end-regexp' to \"^[ \\t]*$\"."
|
|
`org-list-end-regexp' to \"^[ \\t]*$\"."
|
|
@@ -193,14 +200,12 @@ precedence over it."
|
|
|
(indent . t)
|
|
(indent . t)
|
|
|
(insert . t))
|
|
(insert . t))
|
|
|
"Non-nil means apply set of rules when acting on lists.
|
|
"Non-nil means apply set of rules when acting on lists.
|
|
|
-
|
|
|
|
|
By default, automatic actions are taken when using
|
|
By default, automatic actions are taken when using
|
|
|
-\\[org-shiftmetaup], \\[org-shiftmetadown], \\[org-meta-return],
|
|
|
|
|
-\\[org-metaright], \\[org-metaleft], \\[org-shiftmetaright],
|
|
|
|
|
-\\[org-shiftmetaleft], \\[org-ctrl-c-minus],
|
|
|
|
|
-\\[org-toggle-checkbox] or \\[org-insert-todo-heading]. You can
|
|
|
|
|
-disable individually these rules by setting them to nil. Valid
|
|
|
|
|
-rules are:
|
|
|
|
|
|
|
+ \\[org-meta-return], \\[org-metaright], \\[org-metaleft],
|
|
|
|
|
+ \\[org-shiftmetaright], \\[org-shiftmetaleft],
|
|
|
|
|
+ \\[org-ctrl-c-minus], \\[org-toggle-checkbox] or
|
|
|
|
|
+ \\[org-insert-todo-heading]. You can disable individually these
|
|
|
|
|
+ rules by setting them to nil. Valid rules are:
|
|
|
|
|
|
|
|
bullet when non-nil, cycling bullet do not allow lists at
|
|
bullet when non-nil, cycling bullet do not allow lists at
|
|
|
column 0 to have * as a bullet and descriptions lists
|
|
column 0 to have * as a bullet and descriptions lists
|
|
@@ -317,7 +322,6 @@ the end of the nearest terminator from MAX."
|
|
|
|
|
|
|
|
(defun org-list-maybe-skip-block (search limit)
|
|
(defun org-list-maybe-skip-block (search limit)
|
|
|
"Return non-nil value if point is in a block, skipping it on the way.
|
|
"Return non-nil value if point is in a block, skipping it on the way.
|
|
|
-
|
|
|
|
|
It looks for the boundary of the block in SEARCH direction,
|
|
It looks for the boundary of the block in SEARCH direction,
|
|
|
stopping at LIMIT."
|
|
stopping at LIMIT."
|
|
|
(save-match-data
|
|
(save-match-data
|
|
@@ -331,7 +335,6 @@ stopping at LIMIT."
|
|
|
|
|
|
|
|
(defun org-list-search-unenclosed-generic (search re bound noerr)
|
|
(defun org-list-search-unenclosed-generic (search re bound noerr)
|
|
|
"Search a string outside blocks and protected places.
|
|
"Search a string outside blocks and protected places.
|
|
|
-
|
|
|
|
|
Arguments SEARCH, RE, BOUND and NOERR are similar to those in
|
|
Arguments SEARCH, RE, BOUND and NOERR are similar to those in
|
|
|
`search-forward', `search-backward', `re-search-forward' and
|
|
`search-forward', `search-backward', `re-search-forward' and
|
|
|
`re-search-backward'."
|
|
`re-search-backward'."
|
|
@@ -350,7 +353,6 @@ Arguments SEARCH, RE, BOUND and NOERR are similar to those in
|
|
|
|
|
|
|
|
(defun org-search-backward-unenclosed (regexp &optional bound noerror)
|
|
(defun org-search-backward-unenclosed (regexp &optional bound noerror)
|
|
|
"Like `re-search-backward' but don't stop inside blocks or protected places.
|
|
"Like `re-search-backward' but don't stop inside blocks or protected places.
|
|
|
-
|
|
|
|
|
Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
|
`re-search-backward'."
|
|
`re-search-backward'."
|
|
|
(org-list-search-unenclosed-generic
|
|
(org-list-search-unenclosed-generic
|
|
@@ -358,7 +360,6 @@ Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
|
|
|
|
|
|
(defun org-search-forward-unenclosed (regexp &optional bound noerror)
|
|
(defun org-search-forward-unenclosed (regexp &optional bound noerror)
|
|
|
"Like `re-search-forward' but don't stop inside blocks or protected places.
|
|
"Like `re-search-forward' but don't stop inside blocks or protected places.
|
|
|
-
|
|
|
|
|
Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
|
`re-search-forward'."
|
|
`re-search-forward'."
|
|
|
(org-list-search-unenclosed-generic
|
|
(org-list-search-unenclosed-generic
|
|
@@ -366,7 +367,6 @@ Arguments REGEXP, BOUND and NOERROR are similar to those used in
|
|
|
|
|
|
|
|
(defun org-list-in-item-p-with-indent (limit)
|
|
(defun org-list-in-item-p-with-indent (limit)
|
|
|
"Is the cursor inside a plain list?
|
|
"Is the cursor inside a plain list?
|
|
|
-
|
|
|
|
|
Plain lists are considered ending when a non-blank line is less
|
|
Plain lists are considered ending when a non-blank line is less
|
|
|
indented than the previous item within LIMIT."
|
|
indented than the previous item within LIMIT."
|
|
|
(save-excursion
|
|
(save-excursion
|
|
@@ -403,7 +403,6 @@ indented than the previous item within LIMIT."
|
|
|
|
|
|
|
|
(defun org-list-in-item-p-with-regexp (limit)
|
|
(defun org-list-in-item-p-with-regexp (limit)
|
|
|
"Is the cursor inside a plain list?
|
|
"Is the cursor inside a plain list?
|
|
|
-
|
|
|
|
|
Plain lists end when `org-list-end-regexp' is matched, or at a
|
|
Plain lists end when `org-list-end-regexp' is matched, or at a
|
|
|
blank line if `org-empty-line-terminates-plain-lists' is true.
|
|
blank line if `org-empty-line-terminates-plain-lists' is true.
|
|
|
|
|
|
|
@@ -424,7 +423,6 @@ Argument LIMIT specifies the upper-bound of the search."
|
|
|
|
|
|
|
|
(defun org-list-top-point-with-regexp (limit)
|
|
(defun org-list-top-point-with-regexp (limit)
|
|
|
"Return point at the top level item in a list.
|
|
"Return point at the top level item in a list.
|
|
|
-
|
|
|
|
|
Argument LIMIT specifies the upper-bound of the search.
|
|
Argument LIMIT specifies the upper-bound of the search.
|
|
|
|
|
|
|
|
List ending is determined by regexp. See
|
|
List ending is determined by regexp. See
|
|
@@ -440,7 +438,6 @@ List ending is determined by regexp. See
|
|
|
|
|
|
|
|
(defun org-list-bottom-point-with-regexp (limit)
|
|
(defun org-list-bottom-point-with-regexp (limit)
|
|
|
"Return point just before list ending.
|
|
"Return point just before list ending.
|
|
|
-
|
|
|
|
|
Argument LIMIT specifies the lower-bound of the search.
|
|
Argument LIMIT specifies the lower-bound of the search.
|
|
|
|
|
|
|
|
List ending is determined by regexp. See
|
|
List ending is determined by regexp. See
|
|
@@ -454,7 +451,6 @@ List ending is determined by regexp. See
|
|
|
|
|
|
|
|
(defun org-list-top-point-with-indent (limit)
|
|
(defun org-list-top-point-with-indent (limit)
|
|
|
"Return point at the top level in a list.
|
|
"Return point at the top level in a list.
|
|
|
-
|
|
|
|
|
Argument LIMIT specifies the upper-bound of the search.
|
|
Argument LIMIT specifies the upper-bound of the search.
|
|
|
|
|
|
|
|
List ending is determined by indentation of text. See
|
|
List ending is determined by indentation of text. See
|
|
@@ -491,7 +487,6 @@ List ending is determined by indentation of text. See
|
|
|
|
|
|
|
|
(defun org-list-bottom-point-with-indent (limit)
|
|
(defun org-list-bottom-point-with-indent (limit)
|
|
|
"Return point just before list ending or nil if not in a list.
|
|
"Return point just before list ending or nil if not in a list.
|
|
|
-
|
|
|
|
|
Argument LIMIT specifies the lower-bound of the search.
|
|
Argument LIMIT specifies the lower-bound of the search.
|
|
|
|
|
|
|
|
List ending is determined by the indentation of text. See
|
|
List ending is determined by the indentation of text. See
|
|
@@ -520,7 +515,7 @@ List ending is determined by the indentation of text. See
|
|
|
(skip-chars-forward " \r\t\n")
|
|
(skip-chars-forward " \r\t\n")
|
|
|
(beginning-of-line))
|
|
(beginning-of-line))
|
|
|
((org-at-item-p)
|
|
((org-at-item-p)
|
|
|
- (setq ind-ref (min ind ind-ref))
|
|
|
|
|
|
|
+ (setq ind-ref ind)
|
|
|
(forward-line 1))
|
|
(forward-line 1))
|
|
|
((<= ind ind-ref)
|
|
((<= ind ind-ref)
|
|
|
(throw 'exit (point-at-bol)))
|
|
(throw 'exit (point-at-bol)))
|
|
@@ -558,7 +553,6 @@ uses PRE-MOVE before search. Return nil if no item was found."
|
|
|
|
|
|
|
|
(defun org-list-separating-blank-lines-number (pos top bottom)
|
|
(defun org-list-separating-blank-lines-number (pos top bottom)
|
|
|
"Return number of blank lines that should separate items in list.
|
|
"Return number of blank lines that should separate items in list.
|
|
|
-
|
|
|
|
|
POS is the position of point to be considered.
|
|
POS is the position of point to be considered.
|
|
|
|
|
|
|
|
TOP and BOTTOM are respectively position of list beginning and
|
|
TOP and BOTTOM are respectively position of list beginning and
|
|
@@ -603,7 +597,6 @@ some heuristics to guess the result."
|
|
|
|
|
|
|
|
(defun org-list-insert-item-generic (pos &optional checkbox after-bullet)
|
|
(defun org-list-insert-item-generic (pos &optional checkbox after-bullet)
|
|
|
"Insert a new list item at POS.
|
|
"Insert a new list item at POS.
|
|
|
-
|
|
|
|
|
If POS is before first character after bullet of the item, the
|
|
If POS is before first character after bullet of the item, the
|
|
|
new item will be created before the current one.
|
|
new item will be created before the current one.
|
|
|
|
|
|
|
@@ -659,6 +652,9 @@ function ends."
|
|
|
;; recompute next-item: last sexp modified list
|
|
;; recompute next-item: last sexp modified list
|
|
|
(goto-char (org-get-next-item (point) bottom))
|
|
(goto-char (org-get-next-item (point) bottom))
|
|
|
(org-move-to-column col)))
|
|
(org-move-to-column col)))
|
|
|
|
|
+ ;; checkbox update might modify bottom point, so use a
|
|
|
|
|
+ ;; marker here
|
|
|
|
|
+ (setq bottom (copy-marker bottom))
|
|
|
(when checkbox (org-update-checkbox-count-maybe))
|
|
(when checkbox (org-update-checkbox-count-maybe))
|
|
|
(org-list-repair nil top bottom))))
|
|
(org-list-repair nil top bottom))))
|
|
|
(goto-char true-pos)
|
|
(goto-char true-pos)
|
|
@@ -690,7 +686,6 @@ function ends."
|
|
|
|
|
|
|
|
(defun org-list-indent-item-generic (arg no-subtree top bottom)
|
|
(defun org-list-indent-item-generic (arg no-subtree top bottom)
|
|
|
"Indent a local list item including its children.
|
|
"Indent a local list item including its children.
|
|
|
-
|
|
|
|
|
When number ARG is a negative, item will be outdented, otherwise
|
|
When number ARG is a negative, item will be outdented, otherwise
|
|
|
it will be indented.
|
|
it will be indented.
|
|
|
|
|
|
|
@@ -863,8 +858,10 @@ A checkbox is blocked if all of the following conditions are fulfilled:
|
|
|
;; already in a list and doesn't compute list boundaries.
|
|
;; already in a list and doesn't compute list boundaries.
|
|
|
|
|
|
|
|
;; If you plan to use more than one org-list function is some code,
|
|
;; If you plan to use more than one org-list function is some code,
|
|
|
-;; you should therefore first compute list boundaries, and then make
|
|
|
|
|
-;; use of non-interactive forms.
|
|
|
|
|
|
|
+;; you should therefore first check if point is in a list with
|
|
|
|
|
+;; `org-in-item-p' or `org-at-item-p', then compute list boundaries
|
|
|
|
|
+;; with `org-list-top-point' and `org-list-bottom-point', and make use
|
|
|
|
|
+;; of non-interactive forms.
|
|
|
|
|
|
|
|
(defun org-list-top-point ()
|
|
(defun org-list-top-point ()
|
|
|
"Return point at the top level in a list.
|
|
"Return point at the top level in a list.
|
|
@@ -960,8 +957,8 @@ If the cursor in not in an item, throw an error."
|
|
|
(defun org-get-end-of-item (bottom)
|
|
(defun org-get-end-of-item (bottom)
|
|
|
"Return position at the end of the current item.
|
|
"Return position at the end of the current item.
|
|
|
BOTTOM is the position at list ending."
|
|
BOTTOM is the position at list ending."
|
|
|
- (let* ((next-p (org-get-next-item (point) bottom)))
|
|
|
|
|
- (or next-p (org-get-end-of-list bottom))))
|
|
|
|
|
|
|
+ (or (org-get-next-item (point) bottom)
|
|
|
|
|
+ (org-get-end-of-list bottom)))
|
|
|
|
|
|
|
|
(defun org-end-of-item ()
|
|
(defun org-end-of-item ()
|
|
|
"Go to the end of the current hand-formatted item.
|
|
"Go to the end of the current hand-formatted item.
|
|
@@ -998,7 +995,6 @@ Stop searching at LIMIT. Return nil if no item is found."
|
|
|
|
|
|
|
|
(defun org-previous-item ()
|
|
(defun org-previous-item ()
|
|
|
"Move to the beginning of the previous item.
|
|
"Move to the beginning of the previous item.
|
|
|
-
|
|
|
|
|
Item is at the same level in the current plain list. Error if not
|
|
Item is at the same level in the current plain list. Error if not
|
|
|
in a plain list, or if this is the first item in the list."
|
|
in a plain list, or if this is the first item in the list."
|
|
|
(interactive)
|
|
(interactive)
|
|
@@ -1015,7 +1011,6 @@ Stop searching at LIMIT. Return nil if no item is found."
|
|
|
|
|
|
|
|
(defun org-next-item ()
|
|
(defun org-next-item ()
|
|
|
"Move to the beginning of the next item.
|
|
"Move to the beginning of the next item.
|
|
|
-
|
|
|
|
|
Item is at the same level in the current plain list. Error if not
|
|
Item is at the same level in the current plain list. Error if not
|
|
|
in a plain list, or if this is the last item in the list."
|
|
in a plain list, or if this is the last item in the list."
|
|
|
(interactive)
|
|
(interactive)
|
|
@@ -1028,7 +1023,6 @@ in a plain list, or if this is the last item in the list."
|
|
|
|
|
|
|
|
(defun org-list-exchange-items (beg-A beg-B bottom)
|
|
(defun org-list-exchange-items (beg-A beg-B bottom)
|
|
|
"Swap item starting at BEG-A with item starting at BEG-B.
|
|
"Swap item starting at BEG-A with item starting at BEG-B.
|
|
|
-
|
|
|
|
|
Blank lines at the end of items are left in place. Assume BEG-A
|
|
Blank lines at the end of items are left in place. Assume BEG-A
|
|
|
is lesser than BEG-B.
|
|
is lesser than BEG-B.
|
|
|
|
|
|
|
@@ -1049,7 +1043,6 @@ BOTTOM is the position at list ending."
|
|
|
|
|
|
|
|
(defun org-move-item-down ()
|
|
(defun org-move-item-down ()
|
|
|
"Move the plain list item at point down, i.e. swap with following item.
|
|
"Move the plain list item at point down, i.e. swap with following item.
|
|
|
-
|
|
|
|
|
Subitems (items with larger indentation) are considered part of the item,
|
|
Subitems (items with larger indentation) are considered part of the item,
|
|
|
so this really moves item trees."
|
|
so this really moves item trees."
|
|
|
(interactive)
|
|
(interactive)
|
|
@@ -1071,7 +1064,6 @@ so this really moves item trees."
|
|
|
|
|
|
|
|
(defun org-move-item-up ()
|
|
(defun org-move-item-up ()
|
|
|
"Move the plain list item at point up, i.e. swap with previous item.
|
|
"Move the plain list item at point up, i.e. swap with previous item.
|
|
|
-
|
|
|
|
|
Subitems (items with larger indentation) are considered part of the item,
|
|
Subitems (items with larger indentation) are considered part of the item,
|
|
|
so this really moves item trees."
|
|
so this really moves item trees."
|
|
|
(interactive)
|
|
(interactive)
|
|
@@ -1093,7 +1085,6 @@ so this really moves item trees."
|
|
|
|
|
|
|
|
(defun org-insert-item (&optional checkbox)
|
|
(defun org-insert-item (&optional checkbox)
|
|
|
"Insert a new item at the current level.
|
|
"Insert a new item at the current level.
|
|
|
-
|
|
|
|
|
If cursor is before first character after bullet of the item, the
|
|
If cursor is before first character after bullet of the item, the
|
|
|
new item will be created before the current one.
|
|
new item will be created before the current one.
|
|
|
|
|
|
|
@@ -1102,7 +1093,9 @@ If CHECKBOX is non-nil, add a checkbox next to the bullet.
|
|
|
Return t when things worked, nil when we are not in an item, or
|
|
Return t when things worked, nil when we are not in an item, or
|
|
|
item is invisible."
|
|
item is invisible."
|
|
|
(unless (or (not (org-in-item-p))
|
|
(unless (or (not (org-in-item-p))
|
|
|
- (org-invisible-p))
|
|
|
|
|
|
|
+ (save-excursion
|
|
|
|
|
+ (goto-char (org-get-item-beginning))
|
|
|
|
|
+ (org-invisible-p)))
|
|
|
(if (save-excursion
|
|
(if (save-excursion
|
|
|
(goto-char (org-get-item-beginning))
|
|
(goto-char (org-get-item-beginning))
|
|
|
(org-at-item-timer-p))
|
|
(org-at-item-timer-p))
|
|
@@ -1151,7 +1144,6 @@ bullet string and bullet counter, if any."
|
|
|
|
|
|
|
|
(defun org-list-struct (begin end top bottom &optional outdent)
|
|
(defun org-list-struct (begin end top bottom &optional outdent)
|
|
|
"Return the structure containing the list between BEGIN and END.
|
|
"Return the structure containing the list between BEGIN and END.
|
|
|
-
|
|
|
|
|
A structure is an alist where key is point of item and values
|
|
A structure is an alist where key is point of item and values
|
|
|
are, in that order, indentation, bullet string and value of
|
|
are, in that order, indentation, bullet string and value of
|
|
|
counter, if any. A structure contains every list and sublist that
|
|
counter, if any. A structure contains every list and sublist that
|
|
@@ -1217,7 +1209,6 @@ change is an outdent."
|
|
|
|
|
|
|
|
(defun org-list-struct-origins (struct)
|
|
(defun org-list-struct-origins (struct)
|
|
|
"Return an alist where key is item's position and value parent's.
|
|
"Return an alist where key is item's position and value parent's.
|
|
|
-
|
|
|
|
|
STRUCT is the list's structure looked up."
|
|
STRUCT is the list's structure looked up."
|
|
|
(let* ((struct-rev (reverse struct))
|
|
(let* ((struct-rev (reverse struct))
|
|
|
(acc (list (cons (nth 1 (car struct)) 0)))
|
|
(acc (list (cons (nth 1 (car struct)) 0)))
|
|
@@ -1248,7 +1239,6 @@ STRUCT is the list's structure looked up."
|
|
|
|
|
|
|
|
(defun org-list-struct-get-parent (item struct origins)
|
|
(defun org-list-struct-get-parent (item struct origins)
|
|
|
"Return parent association of ITEM in STRUCT or nil.
|
|
"Return parent association of ITEM in STRUCT or nil.
|
|
|
-
|
|
|
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'."
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'."
|
|
|
(let* ((parent-pos (cdr (assq (car item) origins))))
|
|
(let* ((parent-pos (cdr (assq (car item) origins))))
|
|
|
(when (> parent-pos 0) (assq parent-pos struct))))
|
|
(when (> parent-pos 0) (assq parent-pos struct))))
|
|
@@ -1261,7 +1251,6 @@ ORIGINS is the alist of parents. See `org-list-struct-origins'."
|
|
|
|
|
|
|
|
(defun org-list-struct-fix-bul (struct origins)
|
|
(defun org-list-struct-fix-bul (struct origins)
|
|
|
"Verify and correct bullets for every association in STRUCT.
|
|
"Verify and correct bullets for every association in STRUCT.
|
|
|
-
|
|
|
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'.
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'.
|
|
|
|
|
|
|
|
This function modifies STRUCT."
|
|
This function modifies STRUCT."
|
|
@@ -1302,7 +1291,6 @@ This function modifies STRUCT."
|
|
|
|
|
|
|
|
(defun org-list-struct-fix-ind (struct origins)
|
|
(defun org-list-struct-fix-ind (struct origins)
|
|
|
"Verify and correct indentation for every association in STRUCT.
|
|
"Verify and correct indentation for every association in STRUCT.
|
|
|
-
|
|
|
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'.
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'.
|
|
|
|
|
|
|
|
This function modifies STRUCT."
|
|
This function modifies STRUCT."
|
|
@@ -1322,7 +1310,6 @@ This function modifies STRUCT."
|
|
|
|
|
|
|
|
(defun org-list-struct-fix-struct (struct origins)
|
|
(defun org-list-struct-fix-struct (struct origins)
|
|
|
"Return STRUCT with correct bullets and indentation.
|
|
"Return STRUCT with correct bullets and indentation.
|
|
|
-
|
|
|
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'.
|
|
ORIGINS is the alist of parents. See `org-list-struct-origins'.
|
|
|
|
|
|
|
|
Only elements of STRUCT that have changed are returned."
|
|
Only elements of STRUCT that have changed are returned."
|
|
@@ -1333,7 +1320,6 @@ Only elements of STRUCT that have changed are returned."
|
|
|
|
|
|
|
|
(defun org-list-struct-outdent (start end origins)
|
|
(defun org-list-struct-outdent (start end origins)
|
|
|
"Outdent items in a structure.
|
|
"Outdent items in a structure.
|
|
|
-
|
|
|
|
|
Items are indented when their key is between START, included, and
|
|
Items are indented when their key is between START, included, and
|
|
|
END, excluded.
|
|
END, excluded.
|
|
|
|
|
|
|
@@ -1366,7 +1352,6 @@ STRUCT is the concerned structure."
|
|
|
|
|
|
|
|
(defun org-list-struct-indent (start end origins struct)
|
|
(defun org-list-struct-indent (start end origins struct)
|
|
|
"Indent items in a structure.
|
|
"Indent items in a structure.
|
|
|
-
|
|
|
|
|
Items are indented when their key is between START, included, and
|
|
Items are indented when their key is between START, included, and
|
|
|
END, excluded.
|
|
END, excluded.
|
|
|
|
|
|
|
@@ -1429,7 +1414,6 @@ END."
|
|
|
|
|
|
|
|
(defun org-list-struct-apply-struct (struct bottom)
|
|
(defun org-list-struct-apply-struct (struct bottom)
|
|
|
"Apply modifications to list so it mirrors STRUCT.
|
|
"Apply modifications to list so it mirrors STRUCT.
|
|
|
-
|
|
|
|
|
BOTTOM is position at list ending.
|
|
BOTTOM is position at list ending.
|
|
|
|
|
|
|
|
Initial position is restored after the changes."
|
|
Initial position is restored after the changes."
|
|
@@ -1502,7 +1486,6 @@ BOTTOM is position at list ending."
|
|
|
|
|
|
|
|
(defun org-outdent-item ()
|
|
(defun org-outdent-item ()
|
|
|
"Outdent a local list item, but not its children.
|
|
"Outdent a local list item, but not its children.
|
|
|
-
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
If a region is active, all items inside will be moved."
|
|
|
(interactive)
|
|
(interactive)
|
|
|
(org-list-indent-item-generic
|
|
(org-list-indent-item-generic
|
|
@@ -1510,7 +1493,6 @@ If a region is active, all items inside will be moved."
|
|
|
|
|
|
|
|
(defun org-indent-item ()
|
|
(defun org-indent-item ()
|
|
|
"Indent a local list item, but not its children.
|
|
"Indent a local list item, but not its children.
|
|
|
-
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
If a region is active, all items inside will be moved."
|
|
|
(interactive)
|
|
(interactive)
|
|
|
(org-list-indent-item-generic
|
|
(org-list-indent-item-generic
|
|
@@ -1518,7 +1500,6 @@ If a region is active, all items inside will be moved."
|
|
|
|
|
|
|
|
(defun org-outdent-item-tree ()
|
|
(defun org-outdent-item-tree ()
|
|
|
"Outdent a local list item including its children.
|
|
"Outdent a local list item including its children.
|
|
|
-
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
If a region is active, all items inside will be moved."
|
|
|
(interactive)
|
|
(interactive)
|
|
|
(org-list-indent-item-generic
|
|
(org-list-indent-item-generic
|
|
@@ -1526,7 +1507,6 @@ If a region is active, all items inside will be moved."
|
|
|
|
|
|
|
|
(defun org-indent-item-tree ()
|
|
(defun org-indent-item-tree ()
|
|
|
"Indent a local list item including its children.
|
|
"Indent a local list item including its children.
|
|
|
-
|
|
|
|
|
If a region is active, all items inside will be moved."
|
|
If a region is active, all items inside will be moved."
|
|
|
(interactive)
|
|
(interactive)
|
|
|
(org-list-indent-item-generic
|
|
(org-list-indent-item-generic
|
|
@@ -1535,9 +1515,8 @@ If a region is active, all items inside will be moved."
|
|
|
(defvar org-tab-ind-state)
|
|
(defvar org-tab-ind-state)
|
|
|
(defun org-cycle-item-indentation ()
|
|
(defun org-cycle-item-indentation ()
|
|
|
"Cycle levels of indentation of an empty item.
|
|
"Cycle levels of indentation of an empty item.
|
|
|
-
|
|
|
|
|
-The first run indent the item, if applicable. Subsequents runs
|
|
|
|
|
-outdent it at meaningful levels in the list. When done, item is
|
|
|
|
|
|
|
+The first run indent the item, if applicable. Subsequents runs
|
|
|
|
|
+outdent it at meaningful levels in the list. When done, item is
|
|
|
put back at its original position with its original bullet.
|
|
put back at its original position with its original bullet.
|
|
|
|
|
|
|
|
Return t at each successful move."
|
|
Return t at each successful move."
|
|
@@ -1664,12 +1643,12 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
|
|
(unless (and bullet-rule-p
|
|
(unless (and bullet-rule-p
|
|
|
(looking-at "\\S-")) '("*"))
|
|
(looking-at "\\S-")) '("*"))
|
|
|
;; Description items cannot be numbered
|
|
;; Description items cannot be numbered
|
|
|
- (unless (and bullet-rule-p
|
|
|
|
|
- (or (eq org-plain-list-ordered-item-terminator ?.)
|
|
|
|
|
- (org-at-item-description-p))) '("1)"))
|
|
|
|
|
(unless (and bullet-rule-p
|
|
(unless (and bullet-rule-p
|
|
|
(or (eq org-plain-list-ordered-item-terminator ?\))
|
|
(or (eq org-plain-list-ordered-item-terminator ?\))
|
|
|
- (org-at-item-description-p))) '("1."))))
|
|
|
|
|
|
|
+ (org-at-item-description-p))) '("1."))
|
|
|
|
|
+ (unless (and bullet-rule-p
|
|
|
|
|
+ (or (eq org-plain-list-ordered-item-terminator ?.)
|
|
|
|
|
+ (org-at-item-description-p))) '("1)"))))
|
|
|
(len (length bullet-list))
|
|
(len (length bullet-list))
|
|
|
(item-index (- len (length (member current bullet-list))))
|
|
(item-index (- len (length (member current bullet-list))))
|
|
|
(get-value (lambda (index) (nth (mod index len) bullet-list)))
|
|
(get-value (lambda (index) (nth (mod index len) bullet-list)))
|
|
@@ -1684,17 +1663,16 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
|
|
|
|
|
|
|
(defun org-toggle-checkbox (&optional toggle-presence)
|
|
(defun org-toggle-checkbox (&optional toggle-presence)
|
|
|
"Toggle the checkbox in the current line.
|
|
"Toggle the checkbox in the current line.
|
|
|
-
|
|
|
|
|
With prefix arg TOGGLE-PRESENCE, add or remove checkboxes. With
|
|
With prefix arg TOGGLE-PRESENCE, add or remove checkboxes. With
|
|
|
double prefix, set checkbox to [-].
|
|
double prefix, set checkbox to [-].
|
|
|
|
|
|
|
|
When there is an active region, toggle status or presence of the
|
|
When there is an active region, toggle status or presence of the
|
|
|
-checkbox in the first line, and make every item in the region
|
|
|
|
|
-have the same status or presence, respectively.
|
|
|
|
|
|
|
+first checkbox there, and make every item inside have the
|
|
|
|
|
+same status or presence, respectively.
|
|
|
|
|
|
|
|
If the cursor is in a headline, apply this to all checkbox items
|
|
If the cursor is in a headline, apply this to all checkbox items
|
|
|
in the text below the heading, taking as reference the first item
|
|
in the text below the heading, taking as reference the first item
|
|
|
-in subtree."
|
|
|
|
|
|
|
+in subtree, ignoring drawers."
|
|
|
(interactive "P")
|
|
(interactive "P")
|
|
|
;; Bounds is a list of type (beg end single-p) where single-p is t
|
|
;; Bounds is a list of type (beg end single-p) where single-p is t
|
|
|
;; when `org-toggle-checkbox' is applied to a single item. Only
|
|
;; when `org-toggle-checkbox' is applied to a single item. Only
|
|
@@ -1702,22 +1680,34 @@ in subtree."
|
|
|
(let* ((bounds
|
|
(let* ((bounds
|
|
|
(cond
|
|
(cond
|
|
|
((org-region-active-p)
|
|
((org-region-active-p)
|
|
|
- (list (region-beginning) (region-end) nil))
|
|
|
|
|
|
|
+ (let ((rbeg (region-beginning))
|
|
|
|
|
+ (rend (region-end)))
|
|
|
|
|
+ (save-excursion
|
|
|
|
|
+ (goto-char rbeg)
|
|
|
|
|
+ (if (org-search-forward-unenclosed org-item-beginning-re rend 'move)
|
|
|
|
|
+ (list (point-at-bol) rend nil)
|
|
|
|
|
+ (error "No item in region")))))
|
|
|
((org-on-heading-p)
|
|
((org-on-heading-p)
|
|
|
- ;; In this case, reference line is the first item in subtree
|
|
|
|
|
- (let ((limit (save-excursion (outline-next-heading) (point))))
|
|
|
|
|
|
|
+ ;; In this case, reference line is the first item in
|
|
|
|
|
+ ;; subtree outside drawers
|
|
|
|
|
+ (let ((pos (point))
|
|
|
|
|
+ (limit (save-excursion (outline-next-heading) (point))))
|
|
|
(save-excursion
|
|
(save-excursion
|
|
|
|
|
+ (goto-char limit)
|
|
|
|
|
+ (org-search-backward-unenclosed ":END:" pos 'move)
|
|
|
(org-search-forward-unenclosed
|
|
(org-search-forward-unenclosed
|
|
|
org-item-beginning-re limit 'move)
|
|
org-item-beginning-re limit 'move)
|
|
|
(list (point) limit nil))))
|
|
(list (point) limit nil))))
|
|
|
((org-at-item-p)
|
|
((org-at-item-p)
|
|
|
(list (point-at-bol) (point-at-eol) t))
|
|
(list (point-at-bol) (point-at-eol) t))
|
|
|
(t (error "Not at an item or heading, and no active region"))))
|
|
(t (error "Not at an item or heading, and no active region"))))
|
|
|
- ;; marker is needed because deleting checkboxes will change END
|
|
|
|
|
|
|
+ (beg (car bounds))
|
|
|
|
|
+ ;; marker is needed because deleting or inserting checkboxes
|
|
|
|
|
+ ;; will change bottom point
|
|
|
(end (copy-marker (nth 1 bounds)))
|
|
(end (copy-marker (nth 1 bounds)))
|
|
|
(single-p (nth 2 bounds))
|
|
(single-p (nth 2 bounds))
|
|
|
(ref-presence (save-excursion
|
|
(ref-presence (save-excursion
|
|
|
- (goto-char (car bounds))
|
|
|
|
|
|
|
+ (goto-char beg)
|
|
|
(org-at-item-checkbox-p)))
|
|
(org-at-item-checkbox-p)))
|
|
|
(ref-status (equal (match-string 1) "[X]"))
|
|
(ref-status (equal (match-string 1) "[X]"))
|
|
|
(act-on-item
|
|
(act-on-item
|
|
@@ -1751,7 +1741,7 @@ in subtree."
|
|
|
(t "[X]"))
|
|
(t "[X]"))
|
|
|
t t nil 1))))))))
|
|
t t nil 1))))))))
|
|
|
(save-excursion
|
|
(save-excursion
|
|
|
- (beginning-of-line)
|
|
|
|
|
|
|
+ (goto-char beg)
|
|
|
(while (< (point) end)
|
|
(while (< (point) end)
|
|
|
(funcall act-on-item ref-presence ref-status)
|
|
(funcall act-on-item ref-presence ref-status)
|
|
|
(org-search-forward-unenclosed org-item-beginning-re end 'move)))
|
|
(org-search-forward-unenclosed org-item-beginning-re end 'move)))
|
|
@@ -1792,104 +1782,105 @@ with the current numbers. With optional prefix argument ALL, do this for
|
|
|
the whole buffer."
|
|
the whole buffer."
|
|
|
(interactive "P")
|
|
(interactive "P")
|
|
|
(save-excursion
|
|
(save-excursion
|
|
|
- (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
|
|
|
|
|
- (beg (condition-case nil
|
|
|
|
|
- (progn (org-back-to-heading) (point))
|
|
|
|
|
- (error (point-min))))
|
|
|
|
|
- (end (move-marker (make-marker)
|
|
|
|
|
- (progn (outline-next-heading) (point))))
|
|
|
|
|
- (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
|
|
|
|
|
- (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)")
|
|
|
|
|
- (re-find (concat re "\\|" re-box))
|
|
|
|
|
- beg-cookie end-cookie is-percent c-on c-off lim new
|
|
|
|
|
- eline curr-ind next-ind continue-from startsearch
|
|
|
|
|
- (recursive
|
|
|
|
|
- (or (not org-hierarchical-checkbox-statistics)
|
|
|
|
|
- (string-match "\\<recursive\\>"
|
|
|
|
|
- (or (ignore-errors
|
|
|
|
|
- (org-entry-get nil "COOKIE_DATA"))
|
|
|
|
|
- ""))))
|
|
|
|
|
- (cstat 0))
|
|
|
|
|
- (when all
|
|
|
|
|
- (goto-char (point-min))
|
|
|
|
|
- (outline-next-heading)
|
|
|
|
|
- (setq beg (point) end (point-max)))
|
|
|
|
|
- (goto-char end)
|
|
|
|
|
- ;; find each statistics cookie
|
|
|
|
|
- (while (and (org-search-backward-unenclosed re-find beg t)
|
|
|
|
|
- (not (save-match-data
|
|
|
|
|
- (and (org-on-heading-p)
|
|
|
|
|
- (string-match "\\<todo\\>"
|
|
|
|
|
- (downcase
|
|
|
|
|
- (or (org-entry-get
|
|
|
|
|
- nil "COOKIE_DATA")
|
|
|
|
|
- "")))))))
|
|
|
|
|
- (setq beg-cookie (match-beginning 1)
|
|
|
|
|
- end-cookie (match-end 1)
|
|
|
|
|
- cstat (+ cstat (if end-cookie 1 0))
|
|
|
|
|
- startsearch (point-at-eol)
|
|
|
|
|
- continue-from (match-beginning 0)
|
|
|
|
|
- is-percent (match-beginning 2)
|
|
|
|
|
- lim (cond
|
|
|
|
|
- ((org-on-heading-p) (outline-next-heading) (point))
|
|
|
|
|
- ((org-at-item-p) (org-end-of-item) (point))
|
|
|
|
|
- (t nil))
|
|
|
|
|
- c-on 0
|
|
|
|
|
- c-off 0)
|
|
|
|
|
- (when lim
|
|
|
|
|
- ;; find first checkbox for this cookie and gather
|
|
|
|
|
- ;; statistics from all that are at this indentation level
|
|
|
|
|
- (goto-char startsearch)
|
|
|
|
|
- (if (org-search-forward-unenclosed re-box lim t)
|
|
|
|
|
- (progn
|
|
|
|
|
- (goto-char (org-get-item-beginning))
|
|
|
|
|
- (setq curr-ind (org-get-indentation))
|
|
|
|
|
- (setq next-ind curr-ind)
|
|
|
|
|
- (while (and (bolp) (org-at-item-p)
|
|
|
|
|
- (if recursive
|
|
|
|
|
- (<= curr-ind next-ind)
|
|
|
|
|
- (= curr-ind next-ind)))
|
|
|
|
|
- (setq eline (point-at-eol))
|
|
|
|
|
- (if (org-search-forward-unenclosed re-box eline t)
|
|
|
|
|
- (if (member (match-string 2) '("[ ]" "[-]"))
|
|
|
|
|
- (setq c-off (1+ c-off))
|
|
|
|
|
- (setq c-on (1+ c-on))))
|
|
|
|
|
- (if (not recursive)
|
|
|
|
|
- ;; org-get-next-item goes through list-enders
|
|
|
|
|
- ;; with proper limit.
|
|
|
|
|
- (goto-char (or (org-get-next-item (point) lim) lim))
|
|
|
|
|
- (end-of-line)
|
|
|
|
|
- (when (org-search-forward-unenclosed
|
|
|
|
|
- org-item-beginning-re lim t)
|
|
|
|
|
- (beginning-of-line)))
|
|
|
|
|
- (setq next-ind (org-get-indentation)))))
|
|
|
|
|
- (goto-char continue-from)
|
|
|
|
|
- ;; update cookie
|
|
|
|
|
- (when end-cookie
|
|
|
|
|
- (setq new (if is-percent
|
|
|
|
|
- (format "[%d%%]" (/ (* 100 c-on)
|
|
|
|
|
- (max 1 (+ c-on c-off))))
|
|
|
|
|
- (format "[%d/%d]" c-on (+ c-on c-off))))
|
|
|
|
|
- (goto-char beg-cookie)
|
|
|
|
|
- (insert new)
|
|
|
|
|
- (delete-region (point) (+ (point) (- end-cookie beg-cookie))))
|
|
|
|
|
- ;; update items checkbox if it has one
|
|
|
|
|
- (when (org-at-item-p)
|
|
|
|
|
- (goto-char (org-get-item-beginning))
|
|
|
|
|
- (when (and (> (+ c-on c-off) 0)
|
|
|
|
|
- (org-search-forward-unenclosed re-box (point-at-eol) t))
|
|
|
|
|
- (setq beg-cookie (match-beginning 2)
|
|
|
|
|
- end-cookie (match-end 2))
|
|
|
|
|
- (delete-region beg-cookie end-cookie)
|
|
|
|
|
- (goto-char beg-cookie)
|
|
|
|
|
- (cond ((= c-off 0) (insert "[X]"))
|
|
|
|
|
- ((= c-on 0) (insert "[ ]"))
|
|
|
|
|
- (t (insert "[-]")))
|
|
|
|
|
- )))
|
|
|
|
|
- (goto-char continue-from))
|
|
|
|
|
|
|
+ (let ((cstat 0))
|
|
|
|
|
+ (catch 'exit
|
|
|
|
|
+ (while t
|
|
|
|
|
+ (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21
|
|
|
|
|
+ (beg (condition-case nil
|
|
|
|
|
+ (progn (org-back-to-heading) (point))
|
|
|
|
|
+ (error (point-min))))
|
|
|
|
|
+ (end (copy-marker (save-excursion
|
|
|
|
|
+ (outline-next-heading) (point))))
|
|
|
|
|
+ (re-cookie "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
|
|
|
|
|
+ (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)")
|
|
|
|
|
+ beg-cookie end-cookie is-percent c-on c-off lim new
|
|
|
|
|
+ curr-ind next-ind continue-from startsearch list-beg list-end
|
|
|
|
|
+ (recursive
|
|
|
|
|
+ (or (not org-hierarchical-checkbox-statistics)
|
|
|
|
|
+ (string-match "\\<recursive\\>"
|
|
|
|
|
+ (or (ignore-errors
|
|
|
|
|
+ (org-entry-get nil "COOKIE_DATA"))
|
|
|
|
|
+ "")))))
|
|
|
|
|
+ (goto-char end)
|
|
|
|
|
+ ;; find each statistics cookie
|
|
|
|
|
+ (while (and (org-search-backward-unenclosed re-cookie beg 'move)
|
|
|
|
|
+ (not (save-match-data
|
|
|
|
|
+ (and (org-on-heading-p)
|
|
|
|
|
+ (string-match "\\<todo\\>"
|
|
|
|
|
+ (downcase
|
|
|
|
|
+ (or (org-entry-get
|
|
|
|
|
+ nil "COOKIE_DATA")
|
|
|
|
|
+ "")))))))
|
|
|
|
|
+ (setq beg-cookie (match-beginning 1)
|
|
|
|
|
+ end-cookie (match-end 1)
|
|
|
|
|
+ cstat (+ cstat (if end-cookie 1 0))
|
|
|
|
|
+ startsearch (point-at-eol)
|
|
|
|
|
+ continue-from (match-beginning 0)
|
|
|
|
|
+ is-percent (match-beginning 2)
|
|
|
|
|
+ lim (cond
|
|
|
|
|
+ ((org-on-heading-p) (outline-next-heading) (point))
|
|
|
|
|
+ ;; Ensure many cookies in the same list won't imply
|
|
|
|
|
+ ;; computing list boundaries as many times.
|
|
|
|
|
+ ((org-at-item-p)
|
|
|
|
|
+ (unless (and list-beg (>= (point) list-beg))
|
|
|
|
|
+ (setq list-beg (org-list-top-point)
|
|
|
|
|
+ list-end (copy-marker
|
|
|
|
|
+ (org-list-bottom-point))))
|
|
|
|
|
+ (org-get-end-of-item list-end))
|
|
|
|
|
+ (t nil))
|
|
|
|
|
+ c-on 0
|
|
|
|
|
+ c-off 0)
|
|
|
|
|
+ (when lim
|
|
|
|
|
+ ;; find first checkbox for this cookie and gather
|
|
|
|
|
+ ;; statistics from all that are at this indentation level
|
|
|
|
|
+ (goto-char startsearch)
|
|
|
|
|
+ (if (org-search-forward-unenclosed re-box lim t)
|
|
|
|
|
+ (progn
|
|
|
|
|
+ (beginning-of-line)
|
|
|
|
|
+ (setq curr-ind (org-get-indentation))
|
|
|
|
|
+ (setq next-ind curr-ind)
|
|
|
|
|
+ (while (and (bolp) (org-at-item-p)
|
|
|
|
|
+ (if recursive
|
|
|
|
|
+ (<= curr-ind next-ind)
|
|
|
|
|
+ (= curr-ind next-ind)))
|
|
|
|
|
+ (when (org-at-item-checkbox-p)
|
|
|
|
|
+ (if (member (match-string 1) '("[ ]" "[-]"))
|
|
|
|
|
+ (setq c-off (1+ c-off))
|
|
|
|
|
+ (setq c-on (1+ c-on))))
|
|
|
|
|
+ (if (not recursive)
|
|
|
|
|
+ ;; org-get-next-item goes through list-enders
|
|
|
|
|
+ ;; with proper limit.
|
|
|
|
|
+ (goto-char (or (org-get-next-item (point) lim) lim))
|
|
|
|
|
+ (end-of-line)
|
|
|
|
|
+ (when (org-search-forward-unenclosed
|
|
|
|
|
+ org-item-beginning-re lim t)
|
|
|
|
|
+ (beginning-of-line)))
|
|
|
|
|
+ (setq next-ind (org-get-indentation)))))
|
|
|
|
|
+ (goto-char continue-from)
|
|
|
|
|
+ ;; update cookie
|
|
|
|
|
+ (when end-cookie
|
|
|
|
|
+ (setq new (if is-percent
|
|
|
|
|
+ (format "[%d%%]" (/ (* 100 c-on)
|
|
|
|
|
+ (max 1 (+ c-on c-off))))
|
|
|
|
|
+ (format "[%d/%d]" c-on (+ c-on c-off))))
|
|
|
|
|
+ (goto-char beg-cookie)
|
|
|
|
|
+ (insert new)
|
|
|
|
|
+ (delete-region (point) (+ (point) (- end-cookie beg-cookie))))
|
|
|
|
|
+ ;; update items checkbox if it has one
|
|
|
|
|
+ (when (and (org-at-item-checkbox-p)
|
|
|
|
|
+ (> (+ c-on c-off) 0))
|
|
|
|
|
+ (setq beg-cookie (match-beginning 1)
|
|
|
|
|
+ end-cookie (match-end 1))
|
|
|
|
|
+ (delete-region beg-cookie end-cookie)
|
|
|
|
|
+ (goto-char beg-cookie)
|
|
|
|
|
+ (cond ((= c-off 0) (insert "[X]"))
|
|
|
|
|
+ ((= c-on 0) (insert "[ ]"))
|
|
|
|
|
+ (t (insert "[-]")))))
|
|
|
|
|
+ (goto-char continue-from)))
|
|
|
|
|
+ (unless (and all (outline-next-heading)) (throw 'exit nil))))
|
|
|
(when (interactive-p)
|
|
(when (interactive-p)
|
|
|
- (message "Checkbox statistics updated %s (%d places)"
|
|
|
|
|
- (if all "in entire file" "in current outline entry") cstat)))))
|
|
|
|
|
|
|
+ (message "Checkbox statistics updated %s (%d places)"
|
|
|
|
|
+ (if all "in entire file" "in current outline entry") cstat)))))
|
|
|
|
|
|
|
|
(defun org-get-checkbox-statistics-face ()
|
|
(defun org-get-checkbox-statistics-face ()
|
|
|
"Select the face for checkbox statistics.
|
|
"Select the face for checkbox statistics.
|
|
@@ -1907,8 +1898,7 @@ Otherwise it will be `org-todo'."
|
|
|
;;; Misc Tools
|
|
;;; Misc Tools
|
|
|
|
|
|
|
|
(defun org-apply-on-list (function init-value &rest args)
|
|
(defun org-apply-on-list (function init-value &rest args)
|
|
|
- "Call FUNCTION for each item of a the list under point.
|
|
|
|
|
-
|
|
|
|
|
|
|
+ "Call FUNCTION on each item of the list at point.
|
|
|
FUNCTION must be called with at least one argument: INIT-VALUE,
|
|
FUNCTION must be called with at least one argument: INIT-VALUE,
|
|
|
that will contain the value returned by the function at the
|
|
that will contain the value returned by the function at the
|
|
|
previous item, plus ARGS extra arguments.
|
|
previous item, plus ARGS extra arguments.
|
|
@@ -1916,7 +1906,7 @@ previous item, plus ARGS extra arguments.
|
|
|
As an example, (org-apply-on-list (lambda (result) (1+ result)) 0)
|
|
As an example, (org-apply-on-list (lambda (result) (1+ result)) 0)
|
|
|
will return the number of items in the current list.
|
|
will return the number of items in the current list.
|
|
|
|
|
|
|
|
-Sublists of the list are skipped. Cursor is always at the
|
|
|
|
|
|
|
+Sublists of the list are skipped. Cursor is always at the
|
|
|
beginning of the item."
|
|
beginning of the item."
|
|
|
(let* ((pos (copy-marker (point)))
|
|
(let* ((pos (copy-marker (point)))
|
|
|
(end (copy-marker (org-list-bottom-point)))
|
|
(end (copy-marker (org-list-bottom-point)))
|
|
@@ -2161,7 +2151,6 @@ this list."
|
|
|
|
|
|
|
|
(defun org-list-to-generic (list params)
|
|
(defun org-list-to-generic (list params)
|
|
|
"Convert a LIST parsed through `org-list-parse-list' to other formats.
|
|
"Convert a LIST parsed through `org-list-parse-list' to other formats.
|
|
|
-
|
|
|
|
|
Valid parameters PARAMS are
|
|
Valid parameters PARAMS are
|
|
|
|
|
|
|
|
:ustart String to start an unordered list
|
|
:ustart String to start an unordered list
|
|
@@ -2217,7 +2206,7 @@ Valid parameters PARAMS are
|
|
|
(while (setq sublist (pop list))
|
|
(while (setq sublist (pop list))
|
|
|
(cond ((symbolp sublist) nil)
|
|
(cond ((symbolp sublist) nil)
|
|
|
((stringp sublist)
|
|
((stringp sublist)
|
|
|
- (when (string-match "^\\(\\S-+\\)[ \t]+::" sublist)
|
|
|
|
|
|
|
+ (when (string-match "^\\(.*\\)[ \t]+::" sublist)
|
|
|
(setq term (org-trim (format (concat dtstart "%s" dtend)
|
|
(setq term (org-trim (format (concat dtstart "%s" dtend)
|
|
|
(match-string 1 sublist))))
|
|
(match-string 1 sublist))))
|
|
|
(setq sublist (concat ddstart
|
|
(setq sublist (concat ddstart
|