This is something I wrote some time ago to list holidays in the Diary
section of day pages. I don't particularly like the code, but I haven't
made an effort to rewrite it. Perhaps somebody will find it useful.


;;; planner-holidays.el --- Diary holidays for Planner

;; Copyright (C) 2006 Daniel Jensen

;; Author: Daniel Jensen <[EMAIL PROTECTED]>
;; Keywords: planner diary holidays

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

;;; Code:

(require 'holidays)
(require 'planner-diary)

(defcustom planner-diary-insert-holidays t
  "Non-nil means insert diary holidays in day plan pages.
Set to `before' or `after' to place holidays before or after
diary entries, respectively."
  :type '(choice
          (const :tag "Don't insert holidays" nil)
          (const :tag "Holidays before diary entries" before)
          (const :tag "Holidays after diary entries" after))
  :group 'planner-diary)

(defun planner-diary-get-holidays (date)
  "Return a holiday string for the given DATE."
  (let ((holiday-list (check-calendar-holidays date)))
    (format "%s%s"
            (if holiday-list "" "No holidays")
            (mapconcat 'identity holiday-list "; "))))

(defadvice planner-diary-get-diary-entries (after planner-diary-and-holidays
                                                  activate)
  "Insert holidays before or after diary entries."
  (when planner-diary-insert-holidays
    (let ((holiday-string (planner-diary-get-holidays (ad-get-arg 0))))
      (setq ad-return-value
            (if (eq planner-diary-insert-holidays 'after)
                (format "%s\n%s" ad-return-value holiday-string)
                (format "%s\n%s" holiday-string ad-return-value))))))

(provide 'planner-holidays)

;;; planner-holidays.el ends here


_______________________________________________
Planner-el-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/planner-el-discuss

Reply via email to