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

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

Re: [emacs-wiki-discuss] Re: an odd proposal....


From: Alan Schussman
Subject: Re: [emacs-wiki-discuss] Re: an odd proposal....
Date: Wed, 22 Dec 2004 13:52:31 -0700
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Jody Klymak wrote:

Sacha Chua <address@hidden> writes:

You could probably go the way planner-diary and other
section-rewriting modules have gone. Check if the date is today, fetch
stuff (unless already fetched), and rewrite the section of your
choice. <laugh>


I'm pretty sure I posted a hack of planner-diary.el that includes the
contents of an arbitrary wiki page on each day page.  You could easily
use a cron to fill that page on a daily basis with whatever you want.

Let me know if you can't find it in the archives.

Cheers,  Jody

You sent me that code; it's below, and it works great. I have a CurrentEvents file that looks like this:

** Current: DissSurvey | PlanBetter | TeachPrep

and it gets inserted into each of my day pages right below the date (which I insert with (buffer-name); is there a better way to do this?). To move the position, I think you just change planner-insert-current-projects-title.

-Alan

;; Add a "working on" section...
;; from Jody Klymak
(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 "* <lisp>(buffer-name)</lisp>");

(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)
        ))))





reply via email to

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