From f84115d7f274ce6832d196cdf550dde518e71632 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Wed, 26 Apr 2006 18:10:07 +0000 Subject: [PATCH] Merged from mwolson@gnu.org--2006 (patch 36-37) Patches applied: * mwolson@gnu.org--2006/planner--main--1.0--patch-36 Make publishing of calendars work better using a new method. * mwolson@gnu.org--2006/planner--main--1.0--patch-37 Minor docfix. git-archimport-id: mwolson@gnu.org--2006-planner-el/planner-el--devel--0--patch-32 --- planner-calendar.el | 63 +++++++++++++++-------------------------------------- planner-el.texi | 37 +++++++++++-------------------- planner-publish.el | 47 ++++++++++++++++++++++++++++++++++----- 3 files changed, 73 insertions(+), 74 deletions(-) diff --git a/planner-calendar.el b/planner-calendar.el index 77c8042..29d4bc2 100644 --- a/planner-calendar.el +++ b/planner-calendar.el @@ -34,11 +34,15 @@ ;; You will need to install Emacs Muse before this is of any use to ;; you. -;; Read the documentation for `planner-calendar-insert-calendar-maybe', -;; `planner-calendar-move-calendar-to-top-of-page-maybe' and -;; `planner-calendar-create-today-link' for how to use the functions -;; in this file from Muse hooks. +;; To publish calendars in your day pages, it is necessary to do two +;; steps. ;; +;; 1. Add (require 'planner-calendar) to your configuration. +;; +;; 2. Add a tag to either your header, footer, or +;; `planner-day-page-template', depending on where you want it to +;; appear. + ;; If you decide to create a today link for published planner pages, ;; add a hook function like this: ;; @@ -57,7 +61,9 @@ (require 'calendar) (require 'muse) (require 'planner) -(require 'planner-publish) + +(eval-when-compile + (require 'planner-publish)) (defgroup planner-calendar nil "Options controlling the behaviour of planner calendar publication." @@ -344,43 +350,6 @@ support POSIX \"ln\"." (date (planner-filename-to-calendar-date page))) (planner-calendar-next-month-href date name max-days))) -(defun planner-calendar-insert-calendar-maybe () - "Insert the calendar on day pages. -Add this to `muse-before-publish-hook'. This can't be done from -the page header, as header text is added after much of the page -buffer has been marked up." - (let ((page (planner-page-name))) - (when (and page (string-match planner-date-regexp page)) - (goto-char (point-min)) - (insert "\n")))) - -(defun planner-calendar-move-calendar-to-top-of-page-maybe () - "Move calendar to just after `planner-calendar-html-tag-marker'. -Add this to `muse-after-publish-hook'." - (when (string-match planner-date-regexp (or (planner-page-name) "")) - (goto-char (point-min)) - (let* ((inhibit-read-only t) - (body (and (search-forward planner-calendar-html-tag-marker - nil 'noerror) - (forward-line 1) - (point))) - (start (save-excursion - (and (search-forward "") - (point)))) - (calendar (and start end - (buffer-substring start end)))) - (when (and body calendar) - (delete-region start end) - (goto-char body) - (planner-insert-markup calendar (string-match planner-date-regexp - (planner-page-name))))))) - (defun planner-publish-calendar-tag (beg end attrs) (let ((arrows (cdr (assoc "arrows" attrs))) (wiki (cdr (assoc "wiki" attrs)))) @@ -388,9 +357,13 @@ Add this to `muse-after-publish-hook'." (planner-insert-markup (planner-calendar-from-wiki arrows wiki)) (muse-publish-mark-read-only beg (point)))) -(add-to-list 'planner-publish-markup-tags - '("calendar" nil t planner-publish-calendar-tag) - t) +(eval-after-load "planner-publish" + '(progn + (add-to-list 'planner-publish-markup-tags + '("calendar" nil t planner-publish-calendar-tag) + t) + (add-to-list 'planner-publish-finalize-regexps + '(200 "<\\(calendar\\)>" 0 muse-publish-markup-tag)))) (provide 'planner-calendar) diff --git a/planner-el.texi b/planner-el.texi index c15cedb..92ae860 100644 --- a/planner-el.texi +++ b/planner-el.texi @@ -3226,20 +3226,24 @@ Here are some more features related to publishing: @cindex calendar, publishing @cindex @file{planner-calendar.el}, using -Here is an example Emacs Lisp snippet that automatically publishes -calendars in your day pages. +To publish calendars in your day pages, it is necessary to do two steps. + +@itemize +@item Add (require 'planner-calendar) to your configuration. +@item Add a tag to either your header, footer, or +@var{planner-day-page-template}, depending on where you want it to +appear. +@end itemize + +It is also possible to create a symlink from the current day page to the +page name specified by @var{planner-calendar-today-page-name}. To +accomplish this, add the following to your configuration. @example -(require 'planner-calendar) (eval-after-load "muse-publish" '(progn - (add-hook 'muse-before-publish-hook - 'planner-calendar-insert-calendar-maybe nil t) - (add-hook 'muse-after-publish-hook - 'planner-calendar-create-today-link t t) (add-hook 'muse-after-publish-hook - 'planner-calendar-move-calendar-to-top-of-page-maybe - t t))) + 'planner-calendar-create-today-link t t))) @end example @defopt planner-calendar-prev-month-button @@ -3258,27 +3262,12 @@ Number of characters to use for day column header names. Default name for published today page link. @end defopt -@defun planner-calendar-insert-calendar-maybe -Add this function to @code{muse-before-publish-hook} in -@code{planner-mode} buffers in order to automatically add a day page -during the calendar. This cannot be done from the page header because -the inserted text still needs to be processed. -@end defun - @defun planner-calendar-create-today-link Add this function to @code{muse-after-publish-hook} to create a ``today'' soft-link to the newest published planner day page, on operating systems that support POSIX @command{ln}. @end defun -@defun planner-calendar-move-calendar-to-top-of-page-maybe -Add this function to @code{muse-after-publish-hook} if you want -the calendar inserted by @code{planner-calendar-insert-calendar-maybe} -to be moved to the beginning of the page. This work-around is -necessary because some functions used by @file{planner-calendar.el} -only work during markup. -@end defun - @node Authz Access Restriction, RSS Publication, Publishing Calendars, Publishing @comment node-name, next, previous, up @subsection Authz Access Restriction diff --git a/planner-publish.el b/planner-publish.el index 65c60e8..cbcd01f 100644 --- a/planner-publish.el +++ b/planner-publish.el @@ -382,11 +382,45 @@ This may be text or a filename." ;;;_ + Publishing hooks +(defcustom planner-publish-prepare-regexps + '((100 "^\\(\\*+\\)\\s-+" 0 planner-publish-section)) + "List of markup rules to apply before publishing a page with Planner. +See `muse-publish-markup-regexps' for details on the syntax used." + :type '(repeat (choice + (list :tag "Markup rule" + integer + (choice regexp symbol) + integer + (choice string function symbol)) + function)) + :group 'planner-publish) + +(defcustom planner-publish-finalize-regexps + '() + "List of markup rules to apply after publishing a page with Planner. +See `muse-publish-markup-regexps' for details on the syntax used." + :type '(repeat (choice + (list :tag "Markup rule" + integer + (choice regexp symbol) + integer + (choice string function symbol)) + function)) + :group 'planner-publish) + (defun planner-publish-prepare-buffer () (goto-char (point-min)) - (muse-publish-markup "sections" - '((100 "^\\(\\*+\\)\\s-+" 0 - planner-publish-section)))) + (muse-publish-markup "preparing Planner page" + planner-publish-prepare-regexps) + ;; indicate that we are to continue preparing the buffer + nil) + +(defun planner-publish-finalize-buffer () + (goto-char (point-min)) + (muse-publish-markup "finalizing Planner page" + planner-publish-finalize-regexps) + ;; indicate that we are to continue finalizing the buffer + nil) ;;;_ + Markup @@ -626,9 +660,9 @@ DIRECTORY and START." (insert "\n")))) (defvar planner-section-tagnames - "Alist of sections and their tag name." '(("Tasks" . "tasks-section") - ("Notes" . "notes-section"))) + ("Notes" . "notes-section")) + "Alist of sections and their tag name.") (defun planner-publish-section-tagname (text) "A routine that checks `planner-section-tagnames' for tagname." @@ -658,6 +692,7 @@ DIRECTORY and START." :tags 'planner-publish-markup-tags :strings 'planner-xml-markup-strings :before 'planner-publish-prepare-buffer + :after 'planner-publish-finalize-buffer :header 'planner-xml-header :footer 'planner-xml-footer) (muse-derive-style "planner-html" "html" @@ -666,6 +701,7 @@ DIRECTORY and START." :tags 'planner-publish-markup-tags :strings 'planner-html-markup-strings :before 'planner-publish-prepare-buffer + :after 'planner-publish-finalize-buffer :header 'planner-html-header :footer 'planner-html-footer) (muse-derive-style "planner-xhtml" "xhtml" @@ -674,6 +710,7 @@ DIRECTORY and START." :tags 'planner-publish-markup-tags :strings 'planner-html-markup-strings :before 'planner-publish-prepare-buffer + :after 'planner-publish-finalize-buffer :header 'planner-xhtml-header :footer 'planner-xhtml-footer)) -- 2.11.4.GIT