emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Idea - adds new TODO item for specific time and task-group
@ 2007-06-17 17:56 Juraj Kubelka
  2007-07-02 10:54 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Juraj Kubelka @ 2007-06-17 17:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

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
###-PROJECT1-###
*** a task no.1
     DEADLINE:....
...
=====

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
###-PROJECT1-###
*** TODO (cursor here)
     DEADLINE: ....
*** a task no.1
     DEADLINE:....
...
=====

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,
Juraj

============ 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-insert-heading)
       (org-do-demote)
       (org-todo 'right)
       (org-add-planning-info what time 'closed))))


(defun myorg-agenda-insert-task ()
   "Make a task."
   (interactive)
   (org-agenda-check-type t 'agenda 'timeline)
   (require 'diary-lib)
   (let* ((char (progn
                  (message "Choose [d]eadline [s]chedule")
                  (read-char-exclusive)))
          (type (cdr (assoc char
                            '((?d . deadline)
                              (?s . scheduled)))))
          (point (point))
          (calendar-date-display-form '(year "-" month "-" day))
          task)
     (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-date-string
                                        (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)
                  (read-char-exclusive)))
          (selected (car (member* char myorg-tasks :key #'car :test  
#'eql))))
     selected))


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Idea - adds new TODO item for specific time and task-group
  2007-06-17 17:56 Idea - adds new TODO item for specific time and task-group Juraj Kubelka
@ 2007-07-02 10:54 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2007-07-02 10:54 UTC (permalink / raw)
  To: Juraj Kubelka; +Cc: emacs-orgmode

Hi Juraj,

this is useful functionality, but you can do the same already using
remember templates.  Just define templates that do not
contain a link to the current location, and specify
file in which, and headline under which the new item
should be filed.  For example:

(setq org-remember-templates
   '((?s "* TODO %?\n %i" "~/Org/main.org.txt" "Small Tasks of project 
1")
     (?h "* TODO %?\n %i" "~/Org/main.org.txt" "Small tasks at home")))

You can also insert deadline, scheduling etc in this way.  It would
not take the date from the agenda date, but for the rest it
supports everything you are suggesting.

- Carsten

On Jun 17, 2007, at 19:56, Juraj Kubelka wrote:

> Hi,
>
> 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
> ###-PROJECT1-###
> *** a task no.1
>     DEADLINE:....
> ...
> =====
>
> 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
> ###-PROJECT1-###
> *** TODO (cursor here)
>     DEADLINE: ....
> *** a task no.1
>     DEADLINE:....
> ...
> =====
>
> 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,
> Juraj
>
> ============ 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-insert-heading)
>       (org-do-demote)
>       (org-todo 'right)
>       (org-add-planning-info what time 'closed))))
>
>
> (defun myorg-agenda-insert-task ()
>   "Make a task."
>   (interactive)
>   (org-agenda-check-type t 'agenda 'timeline)
>   (require 'diary-lib)
>   (let* ((char (progn
>                  (message "Choose [d]eadline [s]chedule")
>                  (read-char-exclusive)))
>          (type (cdr (assoc char
>                            '((?d . deadline)
>                              (?s . scheduled)))))
>          (point (point))
>          (calendar-date-display-form '(year "-" month "-" day))
>          task)
>     (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-date-string
>                                        
> (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)
>                  (read-char-exclusive)))
>          (selected (car (member* char myorg-tasks :key #'car :test 
> #'eql))))
>     selected))
>
>
> (org-defkey org-agenda-mode-map "I" 'myorg-agenda-insert-task)
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-02 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-17 17:56 Idea - adds new TODO item for specific time and task-group Juraj Kubelka
2007-07-02 10:54 ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).