Compare commits

..

No commits in common. "1ea28a5823ffcbf10e986469e97264265e43e16f" and "21f5988d6a536fb8dfea8a96f8d0f7b12816f3ac" have entirely different histories.

2 changed files with 26 additions and 56 deletions

View File

@ -2691,7 +2691,7 @@ eventuelly be set to nil, however)."
(use-package lisp-mode
:mode (("\\.cl\\'" . lisp-mode)
("\\.lisp\\'" . lisp-mode))
:init (setq lisp-indent-function #'lisp-indent-function))
:init (setq lisp-indent-function #'common-lisp-indent-function))
(use-package lispy
:ensure t

View File

@ -1356,7 +1356,7 @@ inserting the checklist."
nil
'region))
(db/org-goto-first-open-checkbox-in-headline)))))
(db/org-goto-first-open-checkbox-in-subtree)))))
(define-obsolete-function-alias 'db/org-copy-template
'db/org-insert-checklist
@ -1429,75 +1429,45 @@ inserted template."
(looking-at (rx bol (* space) eol)))
(insert "\n"))))
(defun db/org-goto-first-open-checkbox-in-headline (&optional silent)
"Go to first open checkbox in the current subtree.
(defun db/org-goto-first-open-checkbox-in-subtree (&optional silent)
"Jump to first open checkbox in the current subtree.
First search for started checkboxes, i.e. [-], and if those are
not found, go to the first open checkbox, i.e. [ ]. If the item
thus found contains a sublist of checkbox items on it's own,
recursively repeat the search, until no more sublists exist that
contain open checkboxes.
not found, go to the first open checkbox, i.e. [ ].
If there's no such open checkbox, emit a message (unless SILENT
is non-nil) and stay put.
Do not search through branches, i.e., stop the search when the
first sub-headline is found."
Note: when lists are nested, those are not (yet) descended into
to find the logically first open checkbox. This should be fixed
somewhen, though."
(unless (derived-mode-p 'org-mode)
(user-error "Not in Org buffer, exiting"))
(save-restriction
(widen)
(org-back-to-heading 'invisible-ok)
(org-narrow-to-subtree)
;; XXX: this needs a description of how the below algorithm works
(let ((ast (org-element-parse-buffer))
checkbox-pos
checkbox-node
checkbox-pos-1)
(while ast
(when checkbox-pos
;; `checkbox-pos' might be nil when the found checkbox item is empty; in this case, `ast'
;; is not empty, and the following assignment will potentially delete the last known
;; position of a proper checkbox.
(setq checkbox-pos-1 checkbox-pos))
(setq checkbox-pos nil
checkbox-node nil)
(org-element-map ast '(item headline)
(lambda (node)
(unless (eq node ast)
(if (eq 'headline (org-element-type node))
nil ; Abort search to ignore headlines and everything that follows.
(when (and (null checkbox-pos)
(not (memq (org-element-property :checkbox node)
'(nil on))))
(setq checkbox-pos (org-element-contents-begin node)
checkbox-node node))
;; Having this `when' separately and at the end of this function results in
;; `org-element-map' terminating the search as soon as a “[-]” is found.
(when (eq 'trans (org-element-property :checkbox node))
(setq checkbox-pos (org-element-contents-begin node)
checkbox-node node)))))
nil t)
(setq ast checkbox-node))
(cond
(checkbox-pos (goto-char checkbox-pos))
(checkbox-pos-1 (goto-char checkbox-pos-1))
(t (unless silent
(message "No open checkbox in subtree")))))))
(let ((original-point (point)))
(widen)
(org-back-to-heading 'invisible-ok)
(org-narrow-to-subtree)
(unless
;; Yes, those `progn's are not strictly necessary, but it feels
;; cleaner this way.
(or (progn
(goto-char (point-min))
(re-search-forward " \\[-\\] " nil 'no-error))
(progn
(goto-char (point-min))
(re-search-forward " \\[ \\] " nil 'no-error)))
(unless silent
(message "No open checkbox in subtree"))
(goto-char original-point)))))
(defun db/org-clock-goto-first-open-checkbox (&optional select)
"Go to the currently clocked-in item or most recently clocked item.
Move point to first open checkbox there, if there's one. See
`db/org-goto-first-open-checkbox-in-headline' for details.
`db/org-goto-first-open-checkbox-in-subtree' for details.
If SELECT is non-nil, offer a choice of the most recently
clocked-in tasks to jump to."
@ -1524,7 +1494,7 @@ clocked-in tasks to jump to."
(goto-char m)
(org-fold-show-entry)
(org-fold-hide-drawer-all)
(db/org-goto-first-open-checkbox-in-headline :silent)
(db/org-goto-first-open-checkbox-in-subtree :silent)
(org-reveal)
(if recent
(message "No running clock, this is the most recently clocked task"))