Browse Source

Mouse: Create better TODO menu

The TODO keyword made with org-mouse.el now calls org-todo to change
the keyword, so that the logging and note-taking works properly.
Carsten Dominik 10 years ago
parent
commit
225e2111fe
2 changed files with 17 additions and 9 deletions
  1. 4 0
      lisp/ChangeLog
  2. 13 9
      lisp/org-mouse.el

+ 4 - 0
lisp/ChangeLog

@@ -1,5 +1,9 @@
 2009-03-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-mouse.el (org-mouse-todo-menu): New function.
+	(org-mouse-todo-keywords): Function removed.
+	(org-mouse-context-menu): Use `org-mouse-todo-menu'.
+
 	* org-table.el (org-table-beginning-of-field)
 	(org-table-end-of-field): New commands
 	(org-table-previous-field, org-table-beginning-of-field): Better

+ 13 - 9
lisp/org-mouse.el

@@ -422,7 +422,17 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
    (loop for priority from ?A to org-lowest-priority
 	 collect (char-to-string priority)))
 
+(defun org-mouse-todo-menu (state)
+  "Create the menu with TODO keywords."
+  (append
+   (let ((kwds org-todo-keywords-1))
+     (org-mouse-keyword-menu
+      kwds
+      `(lambda (kwd) (org-todo kwd))
+      (lambda (kwd) (equal state kwd))))))
+
 (defun org-mouse-tag-menu ()		;todo
+  "Create the tags menu"
   (append
    (let ((tags (org-get-tags)))
      (org-mouse-keyword-menu
@@ -441,7 +451,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
      ["Set Tags ..." (org-set-tags) t])))
 
 
-
 (defun org-mouse-set-tags (tags)
   (save-excursion
     ;; remove existing tags first
@@ -621,9 +630,6 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
 	(set-match-data ',match)
 	(apply ',function rest)))))
 
-(defun org-mouse-todo-keywords ()
-  (if (boundp 'org-todo-keywords-1) org-todo-keywords-1 org-todo-keywords))
-
 (defun org-mouse-match-todo-keyword ()
   (save-excursion
     (org-back-to-heading)
@@ -691,10 +697,10 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
 			 (org-mouse-remove-match-and-spaces))))]
        )))
    ((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_")
-	 (member (match-string 0) (org-mouse-todo-keywords)))
+	 (member (match-string 0) org-todo-keywords-1))
     (popup-menu
      `(nil
-       ,@(org-mouse-keyword-replace-menu (org-mouse-todo-keywords))
+       ,@(org-mouse-todo-menu (match-string 0))
        "--"
        ["Check TODOs" org-show-todo-tree t]
        ["List all TODO keywords" org-todo-list t]
@@ -832,9 +838,7 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
 	  "--"
 	  ,@(org-mouse-tag-menu))
 	 ("TODO Status"
-	  ,@(progn (org-mouse-match-todo-keyword)
-		   (org-mouse-keyword-replace-menu (org-mouse-todo-keywords)
-						   1)))
+	  ,@(org-mouse-todo-menu (org-get-todo-state)))
 	 ["Show Tags"
 	  (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags))
 	  :visible (not org-mouse-direct)]