Changeset main,19


Ignore:
Timestamp:
03/16/2021 02:08:00 PM (21 months ago)
Author:
David Owen <dsowen@…>
branch-nick:
main
revision id:
dsowen@fugue88.ws-20210316140800-2kpodckrt27wq77v
Message:

Added ORG-AF--END-OF-TASK, ORG-AF--NEXT-TASK, ORG-AF--FIRST-TASK, and ORG-AF--PREV-MARK; and fixed hiding before/between dotted tasks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/org-autofocus.el

    r18 r19  
    119119
    120120
     121(defun org-af--end-of-task (pos)
     122  "Return the position of the end of the task at POS (excluding end of line)."
     123  (next-single-property-change pos 'org-hd-marker))
     124
     125
     126(defun org-af--next-task (from-pos)
     127  "Return the position of the next visible task, from FROM-POS."
     128  (setf from-pos (next-single-property-change from-pos 'org-hd-marker))
     129  (while (eq (get-text-property from-pos 'org-todo-blocked) 'invisible)
     130    ;; The EOL doesn't have an ORG-HD-MARKER property, so search twice to skip
     131    ;; over it.
     132    (setf from-pos (next-single-property-change from-pos 'org-hd-marker)
     133          from-pos (next-single-property-change from-pos 'org-hd-marker)))
     134  from-pos)
     135
     136
     137(defun org-af--first-task ()
     138  "Return the position of the first visible task."
     139  (org-af--next-task 1))
     140
     141
     142(defun org-af--prev-mark (pos)
     143  "Return the position of the first mark previous to POS, or NIL if none are previous."
     144  (let* ((prev (previous-single-char-property-change pos 'org-af-marked)))
     145    (if (= prev 1)
     146        nil
     147      (1- prev))))
     148
     149
    121150(defun org-af-mark ()
    122151  "Mark or unmark the current task, dim the previous marked task if any, and hide any tasks between."
     
    126155  (let ((inhibit-read-only t)
    127156        (task-point (point))
    128         bol marked)
     157        marked)
    129158
    130159    (unless (org-af--dimmed-p task-point)
     
    135164
    136165      (save-excursion
    137         ;; Go to previous mark, if any, or first task otherwise.
    138         (while (and (= (forward-line -1) 0)
    139                     (get-text-property (point) 'type)
    140                     (setq bol (point))
    141                     (not (org-af--marked-p bol))))
    142         (goto-char bol)
    143 
    144         (when (org-af--marked-p bol)
     166        (let ((prev-marked (org-af--prev-mark task-point))
     167              hide-from)
     168
     169          (cond
     170           (prev-marked
     171            (let ((eot (org-af--end-of-task prev-marked)))
     172              (if marked
     173                  (org-af--dim prev-marked eot)
     174                (org-af--undim prev-marked eot))
     175              (setf hide-from (org-af--next-task eot))))
     176
     177           (t
     178            (setf hide-from (org-af--first-task))))
     179
    145180          (if marked
    146               (org-af--dim bol (line-end-position))
    147             (org-af--undim bol (line-end-position))))
    148 
    149         (forward-line)
    150         (setq bol (point))
    151         (if marked
    152             (add-text-properties bol task-point '(category org-af-hidden))
    153           (remove-text-properties bol task-point '(category org-af-hidden)))))))
     181              (add-text-properties hide-from task-point
     182                                   '(category org-af-hidden))
     183            (remove-text-properties hide-from task-point
     184                                    '(category org-af-hidden))))))))
    154185
    155186
Note: See TracChangeset for help on using the changeset viewer.