Mercurial > emacs
comparison lisp/calendar/calendar.el @ 93504:9105df157c3a
(calendar-make-temp-face): New function.
(mark-visible-calendar-date): Use it.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 01 Apr 2008 04:09:41 +0000 |
parents | 258266315e25 |
children | 343109876a78 |
comparison
equal
deleted
inserted
replaced
93503:a56e8caca83b | 93504:9105df157c3a |
---|---|
2385 (and | 2385 (and |
2386 (= (extract-calendar-month date1) (extract-calendar-month date2)) | 2386 (= (extract-calendar-month date1) (extract-calendar-month date2)) |
2387 (= (extract-calendar-day date1) (extract-calendar-day date2)) | 2387 (= (extract-calendar-day date1) (extract-calendar-day date2)) |
2388 (= (extract-calendar-year date1) (extract-calendar-year date2)))) | 2388 (= (extract-calendar-year date1) (extract-calendar-year date2)))) |
2389 | 2389 |
2390 (defun calendar-make-temp-face (attrlist) | |
2391 "Return a temporary face based on the attributes in ATTRLIST. | |
2392 ATTRLIST is a list with elements of the form :face face :foreground color." | |
2393 (let ((temp-face (make-symbol | |
2394 (mapconcat (lambda (sym) | |
2395 (cond | |
2396 ((symbolp sym) (symbol-name sym)) | |
2397 ((numberp sym) (number-to-string sym)) | |
2398 (t sym))) | |
2399 attrlist ""))) | |
2400 (faceinfo attrlist)) | |
2401 (make-face temp-face) | |
2402 ;; Remove :face info, copy into temp-face. | |
2403 (while (setq faceinfo (memq :face faceinfo)) | |
2404 ;; FIXME is there any point doing this multiple times, or could we | |
2405 ;; just take the last? | |
2406 (condition-case nil | |
2407 (copy-face (intern-soft (cadr faceinfo)) temp-face) | |
2408 (error nil)) | |
2409 (setq faceinfo (cddr faceinfo))) | |
2410 (setq attrlist (delq nil attrlist)) | |
2411 ;; Apply the font aspects. | |
2412 (apply 'set-face-attribute temp-face nil attrlist) | |
2413 temp-face)) | |
2414 | |
2390 (defun mark-visible-calendar-date (date &optional mark) | 2415 (defun mark-visible-calendar-date (date &optional mark) |
2391 "Mark DATE in the calendar window with MARK. | 2416 "Mark DATE in the calendar window with MARK. |
2392 MARK is a single-character string, a list of face attributes/values, or a face. | 2417 MARK is a single-character string, a list of face attributes/values, or a face. |
2393 MARK defaults to `diary-entry-marker'." | 2418 MARK defaults to `diary-entry-marker'." |
2394 (if (calendar-date-is-valid-p date) | 2419 (if (calendar-date-is-valid-p date) |
2408 ;; Single-character mark, goes after the date. | 2433 ;; Single-character mark, goes after the date. |
2409 ((and (stringp mark) (= (length mark) 1)) | 2434 ((and (stringp mark) (= (length mark) 1)) |
2410 (overlay-put | 2435 (overlay-put |
2411 (make-overlay (1+ (point)) (+ 2 (point))) 'display mark)) | 2436 (make-overlay (1+ (point)) (+ 2 (point))) 'display mark)) |
2412 (t ; attr list | 2437 (t ; attr list |
2413 (let ((temp-face | 2438 (overlay-put |
2414 (make-symbol | 2439 (make-overlay (1- (point)) (1+ (point))) 'face |
2415 (apply 'concat "temp-" | 2440 (calendar-make-temp-face mark)))))))) |
2416 (mapcar (lambda (sym) | |
2417 (cond | |
2418 ((symbolp sym) (symbol-name sym)) | |
2419 ((numberp sym) (number-to-string sym)) | |
2420 (t sym))) | |
2421 mark)))) | |
2422 (faceinfo mark)) | |
2423 (make-face temp-face) | |
2424 ;; Remove :face info from mark, copy the face info into temp-face. | |
2425 (while (setq faceinfo (memq :face faceinfo)) | |
2426 ;; FIXME not read. | |
2427 (copy-face (read (nth 1 faceinfo)) temp-face) | |
2428 (setcar faceinfo nil) | |
2429 (setcar (cdr faceinfo) nil)) | |
2430 (setq mark (delq nil mark)) | |
2431 ;; Apply the font aspects. | |
2432 (apply 'set-face-attribute temp-face nil mark) | |
2433 (overlay-put | |
2434 (make-overlay (1- (point)) (1+ (point))) 'face temp-face)))))))) | |
2435 | 2441 |
2436 (defun calendar-star-date () | 2442 (defun calendar-star-date () |
2437 "Replace the date under the cursor in the calendar window with asterisks. | 2443 "Replace the date under the cursor in the calendar window with asterisks. |
2438 You might want to add this function to `today-visible-calendar-hook'." | 2444 You might want to add this function to `today-visible-calendar-hook'." |
2439 (unless (catch 'found | 2445 (unless (catch 'found |