Changeset main,2 for main


Ignore:
Timestamp:
04/28/2020 01:37:19 PM (5 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
org-autofocus
revision id:
dsowen@fugue88.ws-20200428133719-pk0i1k9ri2dnyfzl
Message:

Allow tasks to be marked

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/org-autofocus.el

    r1 r2  
    1212
    1313(require 'calendar)
     14(require 'eieio)
     15(require 'ewoc)
    1416
    1517(require 'org-agenda)
     18
     19
     20(defvar-local org-af--ewoc nil)
     21
     22
     23(defclass org-af--task ()
     24  ((org :initarg :org)
     25   (marked :initform nil)))
     26
     27
     28(defun org-af--pp (obj)
     29  "Print the task OBJ in the current buffer at point."
     30  (with-slots (org marked) obj
     31    (insert (if marked "*" " ") " " org)))
     32
    1633
    1734(define-derived-mode org-autofocus-mode special-mode "Org AF" nil
     
    2037        tasks)
    2138    (setq buffer-undo-list t)
     39
    2240    (dolist (f (org-agenda-files))
    2341      (catch 'nextfile
    2442        (org-check-agenda-file f)
    2543        (setq tasks (nconc (org-agenda-get-day-entries f date :todo) tasks))))
     44
     45    (setq org-af--ewoc (ewoc-create 'org-af--pp "header" "footer"))
    2646    (dolist (task tasks)
    27       (insert task "\n"))))
     47      (ewoc-enter-last org-af--ewoc (make-instance 'org-af--task :org task)))))
     48
     49
     50(defun org-af--mark ()
     51  "Toggle whether the task at point is marked."
     52  (interactive)
     53  (let* ((node (ewoc-locate org-af--ewoc))
     54         (obj (ewoc-data node)))
     55    (with-slots (marked) obj
     56      (setf marked (not marked))
     57      (ewoc-invalidate org-af--ewoc node))))
     58
     59
     60(define-key org-autofocus-mode-map "." 'org-af--mark)
     61
    2862
    2963;;;###autoload
     
    3468  (org-autofocus-mode))
    3569
     70
    3671(provide 'org-autofocus)
    3772;;; org-autofocus.el ends here
Note: See TracChangeset for help on using the changeset viewer.