emacs-wiki-discuss
[Top][All Lists]
Advanced

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

[emacs-wiki-discuss] Re: Planner-Newbie


From: Jody Klymak
Subject: [emacs-wiki-discuss] Re: Planner-Newbie
Date: Mon, 06 Dec 2004 15:03:43 -0800
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (darwin)


>
> * Hot projects
> - Ongoing: TeachPrep | DissSurvey
> - Next week: HolidayShopping

OK, how about the following, heavily stolen from planner-diary.  Note
that you cannot say "* Hot projects" in your "CurrentProjects" wiki
page because the code wants to insert something between "* Current
Projects" and the next section.  

Note I also insert it at the top.  If you want it somewhere else,
just change the planner-day-page-template.  

I haven't tested this very carefully.

Cheers,  Jody

;; Add a "working on" section...
(add-hook 'planner-goto-hook 'planner-insert-current-projects-maybe)

(defun planner-insert-current-projects-maybe (&optional force)
  "Maybe insert the projects for the day into the day plan file.
If the current day is in the past and FORCE is nil, don't do
anything.  If FORCE is non-nil, insert the section even if there"
  (interactive "P")
  (let ((date (planner-diary-get-name)))
    ;; check if we're in a day plan buffer
    (if (and (string-match planner-date-regexp date)
             (or force                    ; don't care about the date
                 (not (string< date (planner-today))))) ; not past
        ;; today, future, or force
        (planner-insert-current-projects force)
      ;; we are in the past -> do nothing, message when interactive
      (when (interactive-p)
        (message "No day plan buffer or date is in the past.  No diary entries 
inserted.")))))

(defconst planner-insert-current-projects-page "CurrentProjects");
(defconst planner-insert-current-projects-title "* Current Projects");


(defun planner-insert-current-projects (&optional force)
  "Insert the fancy diary for the day into the day plan file.
If FORCE is non-nil, insert a diary section even if there is no
`planner-diary-string' in the buffer."
  (interactive "P")
  ;; sanity check
  (save-excursion 
    (save-window-excursion
      (goto-char (point-min))
      (or (re-search-forward (concat "^" planner-insert-current-projects-title 
"$") (point-max) t)
          (insert planner-insert-current-projects-title "\n\n"))
      (let ((beg (point))
            (end (if (re-search-forward "^* " (point-max) t)
                     (progn (beginning-of-line)
                            (backward-char 1)
                            (point))
                   (point-max)))
            (buf (current-buffer)))
        (delete-region beg end)
        (planner-find-file planner-insert-current-projects-page)
        (set-buffer buf)
        (newline)
        (insert-buffer-substring planner-insert-current-projects-page)
        (newline)
        )))))


-- 
Jody Klymak      http://opg1.ucsd.edu/~jklymak/
mailto:address@hidden   





reply via email to

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