comparison lisp/calendar/calendar.el @ 49736:dd8404d4fed8

(diary-face-attrs): New custom. (diary-file-name-prefix-function): New custom. (diary-glob-file-regexp-prefix): New custom. (diary-file-name-prefix): New custom. (generate-calendar-window): Check that font-lock-mode is bound before checking value. (mark-visible-calendar-date): Add the ability to pass face attribute/value pairs in the mark argument. Handle the mark.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 11 Feb 2003 23:23:10 +0000
parents c4611ea3a05d
children 88148dcfdd3a d7ddb3e565de
comparison
equal deleted inserted replaced
49735:5cfff357b829 49736:dd8404d4fed8
308 If t, show all the holidays that would appear in a complete Islamic 308 If t, show all the holidays that would appear in a complete Islamic
309 calendar." 309 calendar."
310 :type 'boolean 310 :type 'boolean
311 :group 'holidays) 311 :group 'holidays)
312 312
313 (defcustom diary-file-name-prefix-function (function (lambda (str) str))
314 "*The function that will take a diary file name and return the desired prefix."
315 :type 'string
316 :group 'diary)
317
313 ;;;###autoload 318 ;;;###autoload
314 (defcustom calendar-load-hook nil 319 (defcustom calendar-load-hook nil
315 "*List of functions to be called after the calendar is first loaded. 320 "*List of functions to be called after the calendar is first loaded.
316 This is the place to add key bindings to `calendar-mode-map'." 321 This is the place to add key bindings to `calendar-mode-map'."
317 :type 'hook 322 :type 'hook
493 ;;;###autoload 498 ;;;###autoload
494 (defcustom diary-include-string "#include" 499 (defcustom diary-include-string "#include"
495 "*The string indicating inclusion of another file of diary entries. 500 "*The string indicating inclusion of another file of diary entries.
496 See the documentation for the function `include-other-diary-files'." 501 See the documentation for the function `include-other-diary-files'."
497 :type 'string 502 :type 'string
503 :group 'diary)
504
505 (defcustom diary-glob-file-regexp-prefix "^\\#"
506 "*The regular expression that gets pre-pended to each of the attribute-regexp's for file-wide specifiers."
507 :type 'regexp
508 :group 'diary)
509
510 (defcustom diary-face-attrs '(
511 (" *\\[foreground:\\([-a-z]+\\)\\]$" 1 :foreground string)
512 (" *\\[background:\\([-a-z]+\\)\\]$" 1 :background string)
513 (" *\\[width:\\([-a-z]+\\)\\]$" 1 :width symbol)
514 (" *\\[height:\\([-0-9a-z]+\\)\\]$" 1 :height int)
515 (" *\\[weight:\\([-a-z]+\\)\\]$" 1 :weight symbol)
516 (" *\\[slant:\\([-a-z]+\\)\\]$" 1 :slant symbol)
517 (" *\\[underline:\\([-a-z]+\\)\\]$" 1 :underline stringtnil)
518 (" *\\[overline:\\([-a-z]+\\)\\]$" 1 :overline stringtnil)
519 (" *\\[strike-through:\\([-a-z]+\\)\\]$" 1 :strike-through stringtnil)
520 (" *\\[inverse-video:\\([-a-z]+\\)\\]$" 1 :inverse-video tnil)
521 (" *\\[face:\\([-0-9a-z]+\\)\\]$" 1 :face string)
522 (" *\\[font:\\([-a-z0-9]+\\)\\]$" 1 :font string)
523 ;Unsupported (" *\\[box:\\([-a-z]+\\)\\]$" 1 :box)
524 ;Unsupported (" *\\[stipple:\\([-a-z]+\\)\\]$" 1 :stipple)
525 )
526 "*A list of (regexp regnum attr attrtype) lists where the regexp says how to find the tag, the regnum says which parenthetical sub-regexp this regexp looks for, and the attr says which attribute of the face (or that this _is_ a face) is being modified."
527 :type 'sexp
528 :group 'diary)
529
530 (defcustom diary-file-name-prefix nil
531 "If non-nil then each entry in the diary list will be prefixed with the name of the file in which it was defined."
532 :type 'boolean
498 :group 'diary) 533 :group 'diary)
499 534
500 ;;;###autoload 535 ;;;###autoload
501 (defcustom sexp-diary-entry-symbol "%%" 536 (defcustom sexp-diary-entry-symbol "%%"
502 "*The string used to indicate a sexp diary entry in `diary-file'. 537 "*The string used to indicate a sexp diary entry in `diary-file'.
1814 ;; line is fully visible 1849 ;; line is fully visible
1815 (set-window-vscroll nil 0) 1850 (set-window-vscroll nil 0)
1816 ;; Adjust the window to exactly fit the displayed calendar 1851 ;; Adjust the window to exactly fit the displayed calendar
1817 (fit-window-to-buffer)) 1852 (fit-window-to-buffer))
1818 (sit-for 0) 1853 (sit-for 0)
1819 (if font-lock-mode 1854 (if (and (boundp 'font-lock-mode)
1855 font-lock-mode)
1820 (font-lock-fontify-buffer)) 1856 (font-lock-fontify-buffer))
1821 (and mark-holidays-in-calendar 1857 (and mark-holidays-in-calendar
1822 (mark-calendar-holidays) 1858 (mark-calendar-holidays)
1823 (sit-for 0)) 1859 (sit-for 0))
1824 (unwind-protect 1860 (unwind-protect
2554 (= (extract-calendar-day date1) (extract-calendar-day date2)) 2590 (= (extract-calendar-day date1) (extract-calendar-day date2))
2555 (= (extract-calendar-year date1) (extract-calendar-year date2)))) 2591 (= (extract-calendar-year date1) (extract-calendar-year date2))))
2556 2592
2557 (defun mark-visible-calendar-date (date &optional mark) 2593 (defun mark-visible-calendar-date (date &optional mark)
2558 "Mark DATE in the calendar window with MARK. 2594 "Mark DATE in the calendar window with MARK.
2559 MARK is either a single-character string or a face. 2595 MARK is a single-character string, a list of face attributes/values, or a face.
2560 MARK defaults to `diary-entry-marker'." 2596 MARK defaults to `diary-entry-marker'."
2561 (if (calendar-date-is-legal-p date) 2597 (if (calendar-date-is-legal-p date)
2562 (save-excursion 2598 (save-excursion
2563 (set-buffer calendar-buffer) 2599 (set-buffer calendar-buffer)
2564 (calendar-cursor-to-visible-date date) 2600 (calendar-cursor-to-visible-date date)
2565 (let ((mark (or mark diary-entry-marker))) 2601 (let ((mark (or (and (stringp mark) (= (length mark) 1) mark) ; single-char
2566 (if (stringp mark) 2602 (and (listp mark) (> (length mark) 0) mark) ; attr list
2567 (let ((buffer-read-only nil)) 2603 (and (facep mark) mark) ; face-name
2568 (forward-char 1) 2604 diary-entry-marker)))
2569 (delete-char 1) 2605 (if (facep mark)
2570 (insert mark) 2606 (progn ; face or an attr-list that contained a face
2571 (forward-char -2)) 2607 (overlay-put
2572 (overlay-put 2608 (make-overlay (1- (point)) (1+ (point))) 'face mark))
2573 (make-overlay (1- (point)) (1+ (point))) 'face mark)))))) 2609 (if (and (stringp mark)
2610 (= (length mark) 1)) ; single-char
2611 (let ((buffer-read-only nil))
2612 (forward-char 1)
2613 (delete-char 1)
2614 (insert mark)
2615 (forward-char -2))
2616 (progn ; attr list
2617 (setq temp-face
2618 (make-symbol (apply 'concat "temp-face-"
2619 (mapcar '(lambda (sym)
2620 (cond ((symbolp sym) (symbol-name sym))
2621 ((numberp sym) (int-to-string sym))
2622 (t sym))) mark))))
2623 (make-face temp-face)
2624 ;; Remove :face info from the mark, copy the face info into temp-face
2625 (setq faceinfo mark)
2626 (while (setq faceinfo (memq :face faceinfo))
2627 (copy-face (read (nth 1 faceinfo)) temp-face)
2628 (setcar faceinfo nil)
2629 (setcar (cdr faceinfo) nil))
2630 (setq mark (delq nil mark))
2631 ;; Apply the font aspects
2632 (apply 'set-face-attribute temp-face nil mark)
2633 (overlay-put
2634 (make-overlay (1- (point)) (1+ (point))) 'face temp-face))))))))
2574 2635
2575 (defun calendar-star-date () 2636 (defun calendar-star-date ()
2576 "Replace the date under the cursor in the calendar window with asterisks. 2637 "Replace the date under the cursor in the calendar window with asterisks.
2577 This function can be used with the `today-visible-calendar-hook' run after the 2638 This function can be used with the `today-visible-calendar-hook' run after the
2578 calendar window has been prepared." 2639 calendar window has been prepared."