aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-09-16 16:04:29 +0000
committerStefan Monnier2005-09-16 16:04:29 +0000
commitf52e8e862d4797e98812d35a9852764d7b97e1ca (patch)
tree3d2ba5981e5ad7a56ae7c8a87194e80e71d202b3
parent23006f3e262605aa5e72a7715c3f901c63d0d65d (diff)
downloademacs-f52e8e862d4797e98812d35a9852764d7b97e1ca.tar.gz
emacs-f52e8e862d4797e98812d35a9852764d7b97e1ca.zip
(mark-diary-entries): Don't move point. Use with-syntax-table and dolist.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/calendar/diary-lib.el192
2 files changed, 98 insertions, 99 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cef3f770ab4..b5093189d3e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12005-09-16 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * calendar/diary-lib.el (mark-diary-entries): Don't move point.
4 Use with-syntax-table and dolist.
5
12005-09-16 Carsten Dominik <dominik@science.uva.nl> 62005-09-16 Carsten Dominik <dominik@science.uva.nl>
2 7
3 * textmodes/reftex-auc.el: 8 * textmodes/reftex-auc.el:
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index 7b2f94ca4d1..3b634caaa9c 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -865,105 +865,99 @@ diary entries."
865 (let ((marking-diary-entries t) 865 (let ((marking-diary-entries t)
866 file-glob-attrs marks) 866 file-glob-attrs marks)
867 (with-current-buffer (find-file-noselect (diary-check-diary-file) t) 867 (with-current-buffer (find-file-noselect (diary-check-diary-file) t)
868 (setq mark-diary-entries-in-calendar t) 868 (save-excursion
869 (message "Marking diary entries...") 869 (setq mark-diary-entries-in-calendar t)
870 (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '()))) 870 (message "Marking diary entries...")
871 (let ((d diary-date-forms) 871 (setq file-glob-attrs (nth 1 (diary-pull-attrs nil '())))
872 (old-diary-syntax-table (syntax-table)) 872 (with-syntax-table diary-syntax-table
873 temp) 873 (dolist (date-form diary-date-forms)
874 (set-syntax-table diary-syntax-table) 874 (if (eq (car date-form) 'backup)
875 (while d 875 (setq date-form (cdr date-form))) ;; ignore 'backup directive
876 (let* ((date-form (if (equal (car (car d)) 'backup) 876 (let* ((dayname
877 (cdr (car d)) 877 (diary-name-pattern calendar-day-name-array
878 (car d)));; ignore 'backup directive 878 calendar-day-abbrev-array))
879 (dayname 879 (monthname
880 (diary-name-pattern calendar-day-name-array 880 (format "%s\\|\\*"
881 calendar-day-abbrev-array)) 881 (diary-name-pattern calendar-month-name-array
882 (monthname 882 calendar-month-abbrev-array)))
883 (format "%s\\|\\*" 883 (month "[0-9]+\\|\\*")
884 (diary-name-pattern calendar-month-name-array 884 (day "[0-9]+\\|\\*")
885 calendar-month-abbrev-array))) 885 (year "[0-9]+\\|\\*")
886 (month "[0-9]+\\|\\*") 886 (l (length date-form))
887 (day "[0-9]+\\|\\*") 887 (d-name-pos (- l (length (memq 'dayname date-form))))
888 (year "[0-9]+\\|\\*") 888 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
889 (l (length date-form)) 889 (m-name-pos (- l (length (memq 'monthname date-form))))
890 (d-name-pos (- l (length (memq 'dayname date-form)))) 890 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
891 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos))) 891 (d-pos (- l (length (memq 'day date-form))))
892 (m-name-pos (- l (length (memq 'monthname date-form)))) 892 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
893 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos))) 893 (m-pos (- l (length (memq 'month date-form))))
894 (d-pos (- l (length (memq 'day date-form)))) 894 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
895 (d-pos (if (/= l d-pos) (+ 2 d-pos))) 895 (y-pos (- l (length (memq 'year date-form))))
896 (m-pos (- l (length (memq 'month date-form)))) 896 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
897 (m-pos (if (/= l m-pos) (+ 2 m-pos))) 897 (regexp
898 (y-pos (- l (length (memq 'year date-form)))) 898 (concat
899 (y-pos (if (/= l y-pos) (+ 2 y-pos))) 899 "\\(\\`\\|\^M\\|\n\\)\\("
900 (regexp 900 (mapconcat 'eval date-form "\\)\\(")
901 (concat 901 "\\)"))
902 "\\(\\`\\|\^M\\|\n\\)\\(" 902 (case-fold-search t))
903 (mapconcat 'eval date-form "\\)\\(") 903 (goto-char (point-min))
904 "\\)")) 904 (while (re-search-forward regexp nil t)
905 (case-fold-search t)) 905 (let* ((dd-name
906 (goto-char (point-min)) 906 (if d-name-pos
907 (while (re-search-forward regexp nil t) 907 (match-string-no-properties d-name-pos)))
908 (let* ((dd-name 908 (mm-name
909 (if d-name-pos 909 (if m-name-pos
910 (match-string-no-properties d-name-pos))) 910 (match-string-no-properties m-name-pos)))
911 (mm-name 911 (mm (string-to-number
912 (if m-name-pos 912 (if m-pos
913 (match-string-no-properties m-name-pos))) 913 (match-string-no-properties m-pos)
914 (mm (string-to-number 914 "")))
915 (if m-pos 915 (dd (string-to-number
916 (match-string-no-properties m-pos) 916 (if d-pos
917 ""))) 917 (match-string-no-properties d-pos)
918 (dd (string-to-number 918 "")))
919 (if d-pos 919 (y-str (if y-pos
920 (match-string-no-properties d-pos) 920 (match-string-no-properties y-pos)))
921 ""))) 921 (yy (if (not y-str)
922 (y-str (if y-pos 922 0
923 (match-string-no-properties y-pos))) 923 (if (and (= (length y-str) 2)
924 (yy (if (not y-str) 924 abbreviated-calendar-year)
925 0 925 (let* ((current-y
926 (if (and (= (length y-str) 2) 926 (extract-calendar-year
927 abbreviated-calendar-year) 927 (calendar-current-date)))
928 (let* ((current-y 928 (y (+ (string-to-number y-str)
929 (extract-calendar-year 929 (* 100
930 (calendar-current-date))) 930 (/ current-y 100)))))
931 (y (+ (string-to-number y-str) 931 (if (> (- y current-y) 50)
932 (* 100 932 (- y 100)
933 (/ current-y 100))))) 933 (if (> (- current-y y) 50)
934 (if (> (- y current-y) 50) 934 (+ y 100)
935 (- y 100) 935 y)))
936 (if (> (- current-y y) 50) 936 (string-to-number y-str)))))
937 (+ y 100) 937 (let ((tmp (diary-pull-attrs (buffer-substring-no-properties
938 y))) 938 (point) (line-end-position))
939 (string-to-number y-str))))) 939 file-glob-attrs)))
940 (save-excursion 940 (setq entry (nth 0 tmp)
941 (setq entry (buffer-substring-no-properties 941 marks (nth 1 tmp)))
942 (point) (line-end-position)) 942 (if dd-name
943 temp (diary-pull-attrs entry file-glob-attrs) 943 (mark-calendar-days-named
944 entry (nth 0 temp) 944 (cdr (assoc-string
945 marks (nth 1 temp))) 945 dd-name
946 (if dd-name 946 (calendar-make-alist
947 (mark-calendar-days-named 947 calendar-day-name-array
948 (cdr (assoc-string 948 0 nil calendar-day-abbrev-array) t)) marks)
949 dd-name 949 (if mm-name
950 (calendar-make-alist 950 (setq mm
951 calendar-day-name-array 951 (if (string-equal mm-name "*") 0
952 0 nil calendar-day-abbrev-array) t)) marks) 952 (cdr (assoc-string
953 (if mm-name 953 mm-name
954 (setq mm 954 (calendar-make-alist
955 (if (string-equal mm-name "*") 0 955 calendar-month-name-array
956 (cdr (assoc-string 956 1 nil calendar-month-abbrev-array) t)))))
957 mm-name 957 (mark-calendar-date-pattern mm dd yy marks))))))
958 (calendar-make-alist 958 (mark-sexp-diary-entries)
959 calendar-month-name-array 959 (run-hooks 'nongregorian-diary-marking-hook
960 1 nil calendar-month-abbrev-array) t))))) 960 'mark-diary-entries-hook))
961 (mark-calendar-date-pattern mm dd yy marks))))
962 (setq d (cdr d))))
963 (mark-sexp-diary-entries)
964 (run-hooks 'nongregorian-diary-marking-hook
965 'mark-diary-entries-hook)
966 (set-syntax-table old-diary-syntax-table)
967 (message "Marking diary entries...done"))))) 961 (message "Marking diary entries...done")))))
968 962
969(defun mark-sexp-diary-entries () 963(defun mark-sexp-diary-entries ()