[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Idea - adds new TODO item for specific time and task-group

From: Juraj Kubelka
Subject: [Orgmode] Idea - adds new TODO item for specific time and task-group
Date: Sun, 17 Jun 2007 19:56:42 +0200


I tried to implement function for adding a new todo item to an org-file.

Let's say there is a org-file:

* Project 1
** Small Tasks of project 1
*** a task no.1

If I am in agenda-view and press "I" key, it will insert new task after the "###-PROJECT1-###" string with deadline or schedule for given day:

* Project 1
** Small Tasks of project 1
*** TODO (cursor here)
    DEADLINE: ....
*** a task no.1

It is similar for "i" key (org-self-insert-command). So, after pressing of "I" key, it will ask for schedule or deadline and afterwards for task-group according to a configuration (see attachment).

Am not so familiar with org-mode, so this is just pilot version with lot of drawbacks. For example it will not insert new task, if file is in OVERVIEW presentation.

If some find it useful, I advice to add it to official package. But of course with better implementation. Can you have a look and explain me how to do it better?

Thank you in advance,

============ code ============
(require 'org)

(defcustom myorg-tasks
  '((?s "Project1" "###-PROJECT1-###" "~/Org/main.org.txt")
    (?h "Home" "###-HOME-###" "~/Org/main.org.txt"))
  "*Tasks list.

(key description search-string file-name)

(defun myorg-insert-task (search-string what time file)
  "Add new TODO item in orgmode file after search-string string.

what = SCHEDULED or DEADLINE (see org-add-planning-info).
  (let (point)
    (find-file-other-window (substitute-in-file-name file))
    (when (setq point (save-excursion
                        (goto-char (point-min))
                        (search-forward search-string nil t)))
      (goto-char point)
      (org-todo 'right)
      (org-add-planning-info what time 'closed))))

(defun myorg-agenda-insert-task ()
  "Make a task."
  (org-agenda-check-type t 'agenda 'timeline)
  (require 'diary-lib)
  (let* ((char (progn
                 (message "Choose [d]eadline [s]chedule")
         (type (cdr (assoc char
                           '((?d . deadline)
                             (?s . scheduled)))))
         (point (point))
         (calendar-date-display-form '(year "-" month "-" day))
    (unless type
      (error "No task type associated with <%c>" char))
    (unless (setq time (get-text-property point 'day))
      (error "Don't know which date to use for task entry"))

    (unless (setq task (myorg-ask-for-task-type))
      (error "No tasks selected."))
    (myorg-insert-task (caddr task) type
                       (org-read-date nil 'to-time
(calendar-gregorian-from- absolute (get-text-property point 'day))))
                       (cadddr task))))

(defun myorg-ask-for-task-type ()
  (unless myorg-tasks
    (error "No tasks defined.  See myorg-tasks custom variable."))
  (let* (tmp
         (tasks (dolist (task myorg-tasks tmp)
                  (setq tmp
                        (concat tmp
                                " "
                                (cadr task)
                                (char-to-string (car task))
         (char (progn
                 (message "Choose %s" tasks)
(selected (car (member* char myorg-tasks :key #'car :test #'eql))))

(org-defkey org-agenda-mode-map "I" 'myorg-agenda-insert-task)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]