Philipp Grau <[EMAIL PROTECTED]> writes:
> Hello,
>
> I would like to record the entry date of a task, perhaps in a seperate wiki
> page listing all entered tasks with date and time stamp.
>
> Has anyony some lisp code for me to achieve this? Any hints are
> welcome!
I have something along these lines called planner-timestamp.
It adds to the task description a string like '{{C:20060528}}' which
is then greyed out.
Put the code below into planner-timestam.el and put on your load
path. Then just (require 'planner-timestamp).
+ seth
;;; planner-timestamp.el --- planner.el extension for adding timestamps to tasks
;; Author: Seth Falcon <[EMAIL PROTECTED]>
;; URL: http://userprimary.net
(require 'planner)
(defgroup planner-timestamp nil
"Planner Timestamp options."
:prefix "planner-timestamp-"
:group 'planner)
(defcustom planner-timestamp-add-stamp-flag t
"If non-nil, add timestamps when creating new tasks."
:type 'boolean
:group 'planner-timestamp)
(defcustom planner-timestamp-key "C"
"String used on the left of the ':' in the timestamp"
:type 'file
:group 'planner-timestamp)
(defface planner-timestamp-face
'((((class color) (background light))
(:foreground "lightgray"))
(t (:foreground "darkgray")))
"Face for planner timestamp annotations."
:group 'planner-timestamp)
(defun planner-timestamp-remove-dots (string)
(while (string-match "\\." string)
(setq string (replace-match "" t t string)))
string)
(defun planner-timestamp-make-stamp ()
(let ((stamp (planner-timestamp-remove-dots (planner-today))))
(concat "{{" planner-timestamp-key ":" stamp "}}")))
(defun planner-timestamp-get-stamp-from-string (string)
"Return the timestamp in found in STRING"
(when (string-match
(concat "{{\\("
planner-timestamp-key
"\\):\\([0-9.]+\\)}}") string)
(cons (planner-match-string-no-properties 1 string)
(planner-match-string-no-properties 2 string))))
(defun planner-timestamp-get-current-stamp ()
"Return the planner timestamp on the current line."
(planner-timestamp-get-stamp-from-string
(buffer-substring (planner-line-beginning-position)
(planner-line-end-position))))
(defun planner-timestamp-add-stamp-maybe ()
"Add timestamp if `planner-timestamp-add-stamp-flag' is non-nil."
(when planner-timestamp-add-stamp-flag
(planner-timestamp-add-stamp)))
(defun planner-timestamp-add-stamp ()
"Add a timestamp to the current task if it does not have one yet.
Update the linked task page, if any."
(interactive)
(save-window-excursion
(save-excursion
(let* ((task-info (planner-current-task-info)))
(unless (or (not task-info) (planner-timestamp-get-current-stamp))
(planner-edit-task-description
(concat (planner-task-description task-info) " "
(planner-timestamp-make-stamp))))))))
(defun planner-timestamp-highlight (beg end &optional verbose)
"Highlight timestamps as unobtrusive, clickable text from BEG to END.
VERBOSE is ignored."
(goto-char beg)
(while (re-search-forward "{{[^}]+}}" end t)
(planner-highlight-region
(match-beginning 0)
(match-end 0)
'planner-timestamp 60
(list
'face 'planner-timestamp-face
'intangible nil
))))
(defun planner-timestamp-font-setup ()
(add-hook 'muse-colors-buffer-hook
'planner-timestamp-highlight t t))
(add-hook 'planner-mode-hook 'planner-timestamp-font-setup)
(add-hook 'planner-create-task-hook 'planner-timestamp-add-stamp-maybe)
(provide 'planner-timestamp)
_______________________________________________
Planner-el-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/planner-el-discuss