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

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

[emacs-wiki-discuss] Code to list recent entries


From: Sacha Chua
Subject: [emacs-wiki-discuss] Code to list recent entries
Date: Wed, 20 Apr 2005 18:38:08 +0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

The following code automatically keeps a list of the 15 most recent
entries in footer.inc.php, the PHP file I include on every page.
Wonder if anyone else will find it useful... =)

(defun sacha/planner-add-recent ()
  "Add the current note to the list of recent entries, trimmed at 10."
  (interactive)
  (let* ((info (planner-current-note-info))
         (url (concat 
               "http://sacha.free.net.ph/notebook/wiki/";
               (emacs-wiki-published-name (planner-note-page info))
               "#" (planner-note-anchor info))))
    (when info
      (with-current-buffer
          (find-file-noselect 
"/home/sacha/notebook/wiki/include/footer.inc.php")
        (goto-char (point-min))
        (when (re-search-forward "--recent--" nil t)
          (save-restriction
            (narrow-to-region (1+ (line-end-position))
                              (progn
                                (re-search-forward "--end of recent--" nil t)
                                (line-beginning-position)))
            (goto-char (point-min))
            (insert "<a href=\"" url "\">"
                    (planner-note-title info)
                    "</a><br/>\n")
            (forward-line 14)
            (delete-region (point) (point-max))
            (save-buffer)))))))
(add-hook 'remember-planner-append-hook 'sacha/planner-add-recent t)

-- 
Sacha Chua <address@hidden> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, CS ed
sachac on irc.freenode.net#emacs . YM: sachachua83




reply via email to

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