Changeset main,6


Ignore:
Timestamp:
05/01/2020 01:31:51 PM (5 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
org-autofocus
revision id:
dsowen@fugue88.ws-20200501133151-v2pvtwbe4ylxv7i0
Message:

Hiding/dimming works as a minor mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/org-autofocus.el

    r5 r6  
    1818
    1919
     20(defvar org-af-marked 'org-af-marked)
     21(put 'org-af-marked 'org-af-marked t)
     22(put 'org-af-marked 'display "*")
     23
     24
     25(defvar org-af-hidden 'org-af-hidden)
     26(put 'org-af-hidden 'org-af-hidden t)
     27(put 'org-af-hidden 'invisible t)
     28
     29
     30(defvar org-af-dimmed 'org-af-dimmed)
     31(put 'org-af-dimmed 'org-af-dimmed t)
     32(put 'org-af-dimmed 'face 'org-agenda-dimmed-todo-face)
     33(put 'org-af-dimmed 'evaporate t)
     34
     35(defun org-af--dim (start end)
     36  (let ((o (make-overlay start end)))
     37    (overlay-put o 'category org-af-dimmed)))
     38
     39(defun org-af--undim (start end)
     40  (remove-overlays start end 'org-af-dimmed t))
     41
     42(defun org-af--dimmed-p (point)
     43  (get-char-property point 'org-af-dimmed))
     44
     45
    2046(defun org-af-mark ()
    2147  "Mark or unmark the current task."
    2248  (interactive)
    23   (save-excursion
    24     (let ((inhibit-read-only t)
    25           (props '(org-af-marked t display "*"))
    26           bol)
    27       (beginning-of-line)
    28       (setq bol (point))
    29       (funcall (if (get-text-property bol 'org-af-marked)
    30                    'remove-list-of-text-properties
    31                  'add-text-properties)
    32                bol (1+ bol) props))))
     49  (beginning-of-line)
     50  (when (get-text-property (point) 'org-af-hidden)
     51    (goto-char (next-single-property-change (point) 'org-af-hidden)))
     52
     53  (let ((inhibit-read-only t)
     54        (task-point (point))
     55        bol marked)
     56    (unless (org-af--dimmed-p task-point)
     57      (setq marked (not (get-text-property task-point 'org-af-marked)))
     58      (if marked
     59          (add-text-properties task-point (1+ task-point)
     60                               '(category org-af-marked))
     61        (remove-text-properties task-point (1+ task-point)
     62                                '(category org-af-marked)))
     63
     64      (save-excursion
     65        ;; Go to previous mark, if any
     66        (while (and (= (forward-line -1) 0)
     67                    (setq bol (line-beginning-position))
     68                    (get-text-property bol 'type)
     69                    (not (get-text-property bol 'org-af-marked))))
     70
     71        (when (get-text-property bol 'org-af-marked)
     72          (if marked
     73              (org-af--dim bol (line-end-position))
     74            (org-af--undim bol (line-end-position))))
     75
     76        (forward-line)
     77        (if marked
     78            (add-text-properties bol task-point '(category org-af-hidden))
     79          (remove-text-properties bol task-point '(category org-af-hidden)))))))
    3380
    3481
Note: See TracChangeset for help on using the changeset viewer.