Index: main/org-autofocus.el
===================================================================
--- main/org-autofocus.el	(revision main,4)
+++ main/org-autofocus.el	(revision main,5)
@@ -18,73 +18,108 @@
 
 
-(defvar-local org-af--ewoc nil)
+(defun org-af-mark ()
+  "Mark or unmark the current task."
+  (interactive)
+  (save-excursion
+    (let ((inhibit-read-only t)
+          (props '(org-af-marked t display "*"))
+          bol)
+      (beginning-of-line)
+      (setq bol (point))
+      (funcall (if (get-text-property bol 'org-af-marked)
+                   'remove-list-of-text-properties
+                 'add-text-properties)
+               bol (1+ bol) props))))
 
 
-(defclass org-af--task ()
-  ((org :initarg :org)
-   (marked :initform nil)
-   (passed :initform nil)))
+(defvar org-autofocus-mode-map (make-sparse-keymap))
+(define-key org-autofocus-mode-map "." 'org-af-mark)
 
 
-(defun org-af--pp (obj)
-  "Print the task OBJ in the current buffer at point."
-  (with-slots (org marked passed) obj
-    (when (or marked (not passed))
-      (insert (if marked "*" " ")
-              " "
-              (if passed
-                  (propertize org 'face 'org-agenda-dimmed-todo-face)
-                org)
-              "\n"))))
+(define-minor-mode org-autofocus-mode nil nil " AF" org-autofocus-mode-map
+  nil)
 
 
-(define-derived-mode org-autofocus-mode special-mode "Org AF" nil
-  (let ((inhibit-read-only t)
-        (date (calendar-current-date))
-        tasks)
-    (setq buffer-undo-list t)
-
-    (dolist (f (org-agenda-files))
-      (catch 'nextfile
-	(org-check-agenda-file f)
-	(setq tasks (nconc (org-agenda-get-day-entries f date :todo) tasks))))
-
-    (setq org-af--ewoc (ewoc-create 'org-af--pp "header\n" "footer\n" t))
-    (dolist (task tasks)
-      (ewoc-enter-last org-af--ewoc (make-instance 'org-af--task :org task)))))
+;; (defvar-local org-af--ewoc nil)
 
 
-(defun org-af--mark ()
-  "Toggle whether the task at point is marked."
-  (interactive)
-  (let* ((node (ewoc-locate org-af--ewoc))
-         (obj (ewoc-data node))
-         changed)
-    (unless (slot-value obj 'passed)
-      (let ((marked (not (slot-value obj 'marked))))
-        (setf (slot-value obj 'marked) marked)
-        (push node changed)
-        (let ((node node))
-          (while (and (setf node (ewoc-prev org-af--ewoc node))
-                      (setf obj (ewoc-data node))
-                      (not (slot-value obj 'marked)))
-            (setf (slot-value obj 'passed) marked)
-            (push node changed))
-          (when node
-            (setf (slot-value obj 'passed) marked)
-            (push node changed))))
-      (apply 'ewoc-invalidate org-af--ewoc changed)
-      (ewoc-goto-node org-af--ewoc node))))
+;; (defclass org-af--task ()
+;;   ((org :initarg :org)
+;;    (marked :initform nil)
+;;    (passed :initform nil)))
 
 
-(define-key org-autofocus-mode-map "." 'org-af--mark)
+;; (defun org-af--pp (obj)
+;;   "Print the task OBJ in the current buffer at point."
+;;   (with-slots (org marked passed) obj
+;;     (when (or marked (not passed))
+;;       (insert (if marked "*" " ")
+;;               " "
+;;               (if passed
+;;                   (propertize org 'face 'org-agenda-dimmed-todo-face)
+;;                 org)
+;;               "\n"))))
 
 
-;;;###autoload
-(defun org-autofocus ()
-  "Show the AutoFocus buffer; create it if necessary."
-  (interactive)
-  (pop-to-buffer (get-buffer-create "*Org AutoFocus*"))
-  (org-autofocus-mode))
+;; (define-derived-mode org-autofocus-mode special-mode "Org AF" nil
+;;   (let ((inhibit-read-only t)
+;;         (date (calendar-current-date))
+;;         tasks)
+;;     (setq buffer-undo-list t)
+
+;;     (dolist (f (org-agenda-files))
+;;       (catch 'nextfile
+;; 	(org-check-agenda-file f)
+;; 	(setq tasks (nconc (org-agenda-get-day-entries f date :todo) tasks))))
+
+;;     (setq org-af--ewoc (ewoc-create 'org-af--pp "header\n" "footer\n" t))
+;;     (dolist (task tasks)
+;;       (ewoc-enter-last org-af--ewoc (make-instance 'org-af--task :org task)))))
+
+
+;; (defun org-af--mark ()
+;;   "Toggle whether the task at point is marked."
+;;   (interactive)
+;;   (let* ((node (ewoc-locate org-af--ewoc))
+;;          (obj (ewoc-data node))
+;;          changed)
+;;     (unless (slot-value obj 'passed)
+;;       (let ((marked (not (slot-value obj 'marked))))
+;;         (setf (slot-value obj 'marked) marked)
+;;         (push node changed)
+;;         (let ((node node))
+;;           (while (and (setf node (ewoc-prev org-af--ewoc node))
+;;                       (setf obj (ewoc-data node))
+;;                       (not (slot-value obj 'marked)))
+;;             (setf (slot-value obj 'passed) marked)
+;;             (push node changed))
+;;           (when node
+;;             (setf (slot-value obj 'passed) marked)
+;;             (push node changed))))
+;;       (apply 'ewoc-invalidate org-af--ewoc changed)
+;;       (ewoc-goto-node org-af--ewoc node))))
+
+
+;; (defun org-af--complete ()
+;;   "Complete the task at point, if it's marked and not passed over."
+;;   (interactive)
+;;   (let* ((node (ewoc-locate org-af--ewoc))
+;;          (obj (ewoc-data node)))
+;;     (unless (and nil (or (slot-value obj 'passed)
+;;                 (not (slot-value obj 'marked))))
+;;       (org-agenda-todo)
+;;       (org-autofocus-mode))))
+
+
+;; (define-key org-autofocus-mode-map "." 'org-af--mark)
+;; (define-key org-autofocus-mode-map "c" 'org-af--complete)
+
+
+;; ;;;###autoload
+;; (defun org-autofocus ()
+;;   "Show the AutoFocus buffer; create it if necessary."
+;;   (interactive)
+;;   (pop-to-buffer (get-buffer-create "*Org AutoFocus*"))
+;;   (org-autofocus-mode))
 
 
