Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

emacs - org-mode: creation time range from effort estimate

I would like to use org-mode not with a GTD-like system but rather as a planner/scheduler, scheduling/timestamping every captured task on capture or refile. In such a system, detailed planning of a day including specific frames of times according to the estimated duration a task will take to get done, might be advantageous.

Would it be possible to generate a time frame from an existing effort estimate property when a timestamp is created? This would mean that, when a) scheduling is called and b) I enter not only a date but also a time and c) an effort property exists, this time will automatically be turned into a time frame according to said property.

Some hints as to how this could be achieved would be more than enough, I just do not know enough elisp to get started.

Edit

after capturing the task in my refile.org would look like this:

* TODO Sample todo
 :PROPERTIES:
 :Effort:   1h
 :END:

now when refiling I look at it and decide that I will do it, say, on Friday at 10am:

* TODO Sample todo
  SCHEDULED: <2014-04-18 Fr 10:00>
  :PROPERTIES:
  :Effort:   1h
  :END:

the function that could be called now would automatically add a time range according to effort estimate:

* TODO Sample todo
 SCHEDULED: <2014-04-18 Fr 10:00-11:00>
 :PROPERTIES:
 :Effort:   1h
 :END:

Edit2

See lawlists accepted answer below for a robust solution

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To add a scheduled timestamp, use: M-x org-schedule

To add effort as a range to an existing timestamp, using the standard effort format (e.g., "0 0:10 0:30 1:00 2:00 3:00 4:00") [see http://orgmode.org/manual/Filtering_002flimiting-agenda-items.html ], the following function should do the job. NOTE org-mode version 7 uses all lowercase for the org-element-property property drawer, whereas org-mode version 8 uses all capitals -- e.g., (org-element-property :EFFORT (org-element-at-point))


org-schedule-effort was tested with org-mode version 8.2.5.c using the following example task -- not using h or m for effort. Emacs rounds 00 01 02 03 04 05 06 07 08 09 to 0 1 2 3 4 5 6 7 8 9 and timestamp format requires the former -- therefore, we need to concatenate a 0 to the beginning if less than 10.

* TODO Sample todo
  SCHEDULED: <2014-04-18 Fr 10:00>
  :PROPERTIES:
  :Effort:  1:15
  :END:

(defun org-schedule-effort ()
(interactive)
  (save-excursion
    (org-back-to-heading t)
    (let* (
        (element (org-element-at-point))
        (effort (org-element-property :EFFORT element))
        (scheduled (org-element-property :scheduled element))
        (ts-year-start (org-element-property :year-start scheduled))
        (ts-month-start (org-element-property :month-start scheduled))
        (ts-day-start (org-element-property :day-start scheduled))
        (ts-hour-start (org-element-property :hour-start scheduled))
        (ts-minute-start (org-element-property :minute-start scheduled)) )
      (org-schedule nil (concat
        (format "%s" ts-year-start)
        "-"
        (if (< ts-month-start 10)
          (concat "0" (format "%s" ts-month-start))
          (format "%s" ts-month-start))
        "-"
        (if (< ts-day-start 10)
          (concat "0" (format "%s" ts-day-start))
          (format "%s" ts-day-start))
        " "
        (if (< ts-hour-start 10)
          (concat "0" (format "%s" ts-hour-start))
          (format "%s" ts-hour-start))
        ":"
        (if (< ts-minute-start 10)
          (concat "0" (format "%s" ts-minute-start))
          (format "%s" ts-minute-start))
        "+"
        effort)) )))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...