diff options
| author | Stefan Monnier | 2005-09-19 17:41:22 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-09-19 17:41:22 +0000 |
| commit | f09cfd285f67f8518b5808b3da8614fdf063b037 (patch) | |
| tree | c95be9576f1dce0d83517b15aaa83e1c39359a24 | |
| parent | 12b8cf536a0507150a4824fe619631d60322cdce (diff) | |
| download | emacs-f09cfd285f67f8518b5808b3da8614fdf063b037.tar.gz emacs-f09cfd285f67f8518b5808b3da8614fdf063b037.zip | |
(mark-visible-calendar-date): Save excursion.
Re-indent within 80 columns. Use inhibit-read-only.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/calendar/calendar.el | 81 |
2 files changed, 49 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7e98ed9b2f7..66167330a07 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2005-09-19 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * calendar/calendar.el (mark-visible-calendar-date): Save excursion. | ||
| 4 | Re-indent within 80 columns. Use inhibit-read-only. | ||
| 5 | |||
| 1 | 2005-09-19 Romain Francoise <romain@orebokech.com> | 6 | 2005-09-19 Romain Francoise <romain@orebokech.com> |
| 2 | 7 | ||
| 3 | * calendar/diary-lib.el (mark-diary-entries): Revert last change. | 8 | * calendar/diary-lib.el (mark-diary-entries): Revert last change. |
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 2d2e5256977..ec70c8c6c35 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el | |||
| @@ -2900,43 +2900,50 @@ interpreted as BC; -1 being 1 BC, and so on." | |||
| 2900 | MARK is a single-character string, a list of face attributes/values, or a face. | 2900 | MARK is a single-character string, a list of face attributes/values, or a face. |
| 2901 | MARK defaults to `diary-entry-marker'." | 2901 | MARK defaults to `diary-entry-marker'." |
| 2902 | (if (calendar-date-is-legal-p date) | 2902 | (if (calendar-date-is-legal-p date) |
| 2903 | (save-excursion | 2903 | (with-current-buffer calendar-buffer |
| 2904 | (set-buffer calendar-buffer) | 2904 | (save-excursion |
| 2905 | (calendar-cursor-to-visible-date date) | 2905 | (calendar-cursor-to-visible-date date) |
| 2906 | (let ((mark (or (and (stringp mark) (= (length mark) 1) mark) ; single-char | 2906 | (setq mark |
| 2907 | (and (listp mark) (> (length mark) 0) mark) ; attr list | 2907 | (or (and (stringp mark) (= (length mark) 1) mark) ; single-char |
| 2908 | (and (facep mark) mark) ; face-name | 2908 | (and (listp mark) (> (length mark) 0) mark) ; attr list |
| 2909 | diary-entry-marker))) | 2909 | (and (facep mark) mark) ; face-name |
| 2910 | (if (facep mark) | 2910 | diary-entry-marker)) |
| 2911 | (progn ; face or an attr-list that contained a face | 2911 | (cond |
| 2912 | (overlay-put | 2912 | ;; face or an attr-list that contained a face |
| 2913 | (make-overlay (1- (point)) (1+ (point))) 'face mark)) | 2913 | ((facep mark) |
| 2914 | (if (and (stringp mark) | 2914 | (overlay-put |
| 2915 | (= (length mark) 1)) ; single-char | 2915 | (make-overlay (1- (point)) (1+ (point))) 'face mark)) |
| 2916 | (let ((buffer-read-only nil)) | 2916 | ;; single-char |
| 2917 | (forward-char 1) | 2917 | ((and (stringp mark) (= (length mark) 1)) |
| 2918 | (delete-char 1) | 2918 | (let ((inhibit-read-only t)) |
| 2919 | (insert mark) | 2919 | (forward-char 1) |
| 2920 | (forward-char -2)) | 2920 | ;; Insert before delete so as to better preserve markers. |
| 2921 | (let ; attr list | 2921 | (insert mark) |
| 2922 | ((temp-face | 2922 | (delete-char 1) |
| 2923 | (make-symbol (apply 'concat "temp-" | 2923 | (forward-char -2))) |
| 2924 | (mapcar '(lambda (sym) | 2924 | (t ;; attr list |
| 2925 | (cond ((symbolp sym) (symbol-name sym)) | 2925 | (let ((temp-face |
| 2926 | ((numberp sym) (int-to-string sym)) | 2926 | (make-symbol |
| 2927 | (t sym))) mark)))) | 2927 | (apply 'concat "temp-" |
| 2928 | (faceinfo mark)) | 2928 | (mapcar (lambda (sym) |
| 2929 | (make-face temp-face) | 2929 | (cond |
| 2930 | ;; Remove :face info from the mark, copy the face info into temp-face | 2930 | ((symbolp sym) (symbol-name sym)) |
| 2931 | (while (setq faceinfo (memq :face faceinfo)) | 2931 | ((numberp sym) (number-to-string sym)) |
| 2932 | (copy-face (read (nth 1 faceinfo)) temp-face) | 2932 | (t sym))) |
| 2933 | (setcar faceinfo nil) | 2933 | mark)))) |
| 2934 | (setcar (cdr faceinfo) nil)) | 2934 | (faceinfo mark)) |
| 2935 | (setq mark (delq nil mark)) | 2935 | (make-face temp-face) |
| 2936 | ;; Apply the font aspects | 2936 | ;; Remove :face info from the mark, copy the face info into |
| 2937 | (apply 'set-face-attribute temp-face nil mark) | 2937 | ;; temp-face |
| 2938 | (overlay-put | 2938 | (while (setq faceinfo (memq :face faceinfo)) |
| 2939 | (make-overlay (1- (point)) (1+ (point))) 'face temp-face)))))))) | 2939 | (copy-face (read (nth 1 faceinfo)) temp-face) |
| 2940 | (setcar faceinfo nil) | ||
| 2941 | (setcar (cdr faceinfo) nil)) | ||
| 2942 | (setq mark (delq nil mark)) | ||
| 2943 | ;; Apply the font aspects | ||
| 2944 | (apply 'set-face-attribute temp-face nil mark) | ||
| 2945 | (overlay-put | ||
| 2946 | (make-overlay (1- (point)) (1+ (point))) 'face temp-face)))))))) | ||
| 2940 | 2947 | ||
| 2941 | (defun calendar-star-date () | 2948 | (defun calendar-star-date () |
| 2942 | "Replace the date under the cursor in the calendar window with asterisks. | 2949 | "Replace the date under the cursor in the calendar window with asterisks. |