Commit f0a51f2a authored by Stefan Monnier's avatar Stefan Monnier

(diary-list-entries, include-other-diary-files, mark-diary-entries)

(mark-sexp-diary-entries, mark-included-diary-files)
(diary-entry-time, list-sexp-diary-entries): Remove the special
handling of ^M that dates back to the use of selective-display.
(simple-diary-display): Obey setting of pop-up-frames.
(body, entry): Remove unnecessary declarations.
parent 7027c07b
2008-03-08 Stefan Monnier <monnier@iro.umontreal.ca> 2008-03-08 Stefan Monnier <monnier@iro.umontreal.ca>
* calendar/diary-lib.el (diary-list-entries)
(include-other-diary-files, mark-diary-entries)
(mark-sexp-diary-entries, mark-included-diary-files)
(diary-entry-time, list-sexp-diary-entries): Remove the special
handling of ^M that dates back to the use of selective-display.
(simple-diary-display): Obey setting of pop-up-frames.
(body, entry): Remove unnecessary declarations.
* bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs. * bookmark.el (bookmark-prop-get, bookmark-prop-set): New funs.
(bookmark-get-annotation, bookmark-set-annotation) (bookmark-get-annotation, bookmark-set-annotation)
(bookmark-get-filename, bookmark-set-filename, bookmark-get-position) (bookmark-get-filename, bookmark-set-filename, bookmark-get-position)
......
...@@ -118,9 +118,9 @@ function `mark-included-diary-files' as part of `mark-diary-entries-hook'. ...@@ -118,9 +118,9 @@ function `mark-included-diary-files' as part of `mark-diary-entries-hook'.
For example, you could use For example, you could use
(setq list-diary-entries-hook (add-hook 'list-diary-entries-hook 'include-other-diary-files)
'(include-other-diary-files sort-diary-entries)) (add-hook 'list-diary-entries-hook 'sort-diary-entries)
(setq diary-display-hook 'fancy-diary-display) (add-hook 'diary-display-hook 'fancy-diary-display)
in your `.emacs' file to cause the fancy diary buffer to be displayed with in your `.emacs' file to cause the fancy diary buffer to be displayed with
diary entries from various included files, each day's entries sorted into diary entries from various included files, each day's entries sorted into
...@@ -413,7 +413,6 @@ syntax of `*' and `:' changed to be word constituents.") ...@@ -413,7 +413,6 @@ syntax of `*' and `:' changed to be word constituents.")
(defvar diary-entries-list) (defvar diary-entries-list)
(defvar displayed-year) (defvar displayed-year)
(defvar displayed-month) (defvar displayed-month)
(defvar entry)
(defvar date) (defvar date)
(defvar number) (defvar number)
(defvar date-string) (defvar date-string)
...@@ -722,38 +721,28 @@ If LIST-ONLY is non-nil don't modify or display the buffer, only return a list." ...@@ -722,38 +721,28 @@ If LIST-ONLY is non-nil don't modify or display the buffer, only return a list."
""))) "")))
(regexp (regexp
(concat (concat
"\\(\\`\\|\^M\\|\n\\)" mark "?\\(" "^" mark "?\\("
(mapconcat 'eval date-form "\\)\\(?:") (mapconcat 'eval date-form "\\)\\(?:")
"\\)")) "\\)"))
(case-fold-search t)) (case-fold-search t))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward regexp nil t) (while (re-search-forward regexp nil t)
(if backup (re-search-backward "\\<" nil t)) (if backup (re-search-backward "\\<" nil t))
(if (and (or (char-equal (preceding-char) ?\^M) (if (and (bolp) (not (looking-at "[ \t]")))
(char-equal (preceding-char) ?\n))
(not (looking-at " \\|\^I")))
;; Diary entry that consists only of date. ;; Diary entry that consists only of date.
(backward-char 1) (backward-char 1)
;; Found a nonempty diary entry--make it ;; Found a nonempty diary entry--make it
;; visible and add it to the list. ;; visible and add it to the list.
(setq entry-found t) (setq entry-found t)
(if (looking-at "[ \t]*\n[ \t]") (forward-line 1))
(let ((entry-start (point)) (let ((entry-start (point))
date-start temp) date-start temp)
(re-search-backward "\^M\\|\n\\|\\`") (setq date-start
(setq date-start (point)) (line-end-position
;; When selective display (rather than (if (and (bolp) (> number 1)) -1 0)))
;; overlays) was used, diary file used to (forward-line 1)
;; start in a blank line and end in a (while (looking-at "[ \t]")
;; newline. Now that neither of these (forward-line 1))
;; need be true, 'move handles the latter
;; and 1/2 kludge the former.
(re-search-forward
"\^M\\|\n" nil 'move
(if (and (bobp) (not (looking-at "\^M\\|\n")))
1
2))
(while (looking-at " \\|\^I")
(re-search-forward "\^M\\|\n" nil 'move))
(unless (and (eobp) (not (bolp))) (unless (and (eobp) (not (bolp)))
(backward-char 1)) (backward-char 1))
(unless list-only (unless list-only
...@@ -802,7 +791,7 @@ changing the variable `diary-include-string'." ...@@ -802,7 +791,7 @@ changing the variable `diary-include-string'."
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (while (re-search-forward
(concat (concat
"\\(?:\\`\\|\^M\\|\n\\)" "^"
(regexp-quote diary-include-string) (regexp-quote diary-include-string)
" \"\\([^\"]*\\)\"") " \"\\([^\"]*\\)\"")
nil t) nil t)
...@@ -839,7 +828,8 @@ changing the variable `diary-include-string'." ...@@ -839,7 +828,8 @@ changing the variable `diary-include-string'."
(msg (format "No diary entries for %s" hol-string)) (msg (format "No diary entries for %s" hol-string))
;; If selected window is dedicated (to the calendar), ;; If selected window is dedicated (to the calendar),
;; need a new one to display the diary. ;; need a new one to display the diary.
(pop-up-frames (window-dedicated-p (selected-window)))) (pop-up-frames (or pop-up-frames
(window-dedicated-p (selected-window)))))
(calendar-set-mode-line (format "Diary for %s" hol-string)) (calendar-set-mode-line (format "Diary for %s" hol-string))
(if (or (not diary-entries-list) (if (or (not diary-entries-list)
(and (not (cdr diary-entries-list)) (and (not (cdr diary-entries-list))
...@@ -1209,18 +1199,18 @@ diary entries." ...@@ -1209,18 +1199,18 @@ diary entries."
(year "[0-9]+\\|\\*") (year "[0-9]+\\|\\*")
(l (length date-form)) (l (length date-form))
(d-name-pos (- l (length (memq 'dayname date-form)))) (d-name-pos (- l (length (memq 'dayname date-form))))
(d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos))) (d-name-pos (if (/= l d-name-pos) (+ 1 d-name-pos)))
(m-name-pos (- l (length (memq 'monthname date-form)))) (m-name-pos (- l (length (memq 'monthname date-form))))
(m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos))) (m-name-pos (if (/= l m-name-pos) (+ 1 m-name-pos)))
(d-pos (- l (length (memq 'day date-form)))) (d-pos (- l (length (memq 'day date-form))))
(d-pos (if (/= l d-pos) (+ 2 d-pos))) (d-pos (if (/= l d-pos) (+ 1 d-pos)))
(m-pos (- l (length (memq 'month date-form)))) (m-pos (- l (length (memq 'month date-form))))
(m-pos (if (/= l m-pos) (+ 2 m-pos))) (m-pos (if (/= l m-pos) (+ 1 m-pos)))
(y-pos (- l (length (memq 'year date-form)))) (y-pos (- l (length (memq 'year date-form))))
(y-pos (if (/= l y-pos) (+ 2 y-pos))) (y-pos (if (/= l y-pos) (+ 1 y-pos)))
(regexp (regexp
(concat (concat
"\\(\\`\\|\^M\\|\n\\)\\(" "^\\("
(mapconcat 'eval date-form "\\)\\(") (mapconcat 'eval date-form "\\)\\(")
"\\)")) "\\)"))
(case-fold-search t)) (case-fold-search t))
...@@ -1289,7 +1279,7 @@ diary entries." ...@@ -1289,7 +1279,7 @@ diary entries."
Each entry in the diary file (or included files) visible in the calendar window Each entry in the diary file (or included files) visible in the calendar window
is marked. See the documentation for the function `list-sexp-diary-entries'." is marked. See the documentation for the function `list-sexp-diary-entries'."
(let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol)) (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol))
(s-entry (concat "\\(\\`\\|\^M\\|\n\\)\\(" (s-entry (concat "^\\("
sexp-mark "(\\)\\|\\(" sexp-mark "(\\)\\|\\("
(regexp-quote diary-nonmarking-symbol) (regexp-quote diary-nonmarking-symbol)
sexp-mark "(diary-remind\\)")) sexp-mark "(diary-remind\\)"))
...@@ -1310,31 +1300,21 @@ is marked. See the documentation for the function `list-sexp-diary-entries'." ...@@ -1310,31 +1300,21 @@ is marked. See the documentation for the function `list-sexp-diary-entries'."
(setq marking-diary-entry (char-equal (preceding-char) ?\()) (setq marking-diary-entry (char-equal (preceding-char) ?\())
(re-search-backward "(") (re-search-backward "(")
(let ((sexp-start (point)) (let ((sexp-start (point))
sexp entry entry-start line-start marks) sexp entry entry-start marks)
(forward-sexp) (forward-sexp)
(setq sexp (buffer-substring-no-properties sexp-start (point))) (setq sexp (buffer-substring-no-properties sexp-start (point)))
(save-excursion
(re-search-backward "\^M\\|\n\\|\\`")
(setq line-start (point)))
(forward-char 1) (forward-char 1)
(if (and (or (char-equal (preceding-char) ?\^M) (if (and (bolp) (not (looking-at "[ \t]")))
(char-equal (preceding-char) ?\n))
(not (looking-at " \\|\^I")))
(progn;; Diary entry consists only of the sexp (progn;; Diary entry consists only of the sexp
(backward-char 1) (backward-char 1)
(setq entry "")) (setq entry ""))
(setq entry-start (point)) (setq entry-start (point))
;; Find end of entry ;; Find end of entry
(re-search-forward "\^M\\|\n" nil t) (forward-line 1)
(while (looking-at " \\|\^I") (while (looking-at "[ \t]")
(or (re-search-forward "\^M\\|\n" nil t) (forward-line 1))
(re-search-forward "$" nil t))) (if (bolp) (backward-char 1))
(if (or (char-equal (preceding-char) ?\^M) (setq entry (buffer-substring-no-properties entry-start (point))))
(char-equal (preceding-char) ?\n))
(backward-char 1))
(setq entry (buffer-substring-no-properties entry-start (point)))
(while (string-match "[\^M]" entry)
(aset entry (match-beginning 0) ?\n )))
(calendar-for-loop date from first-date to last-date do (calendar-for-loop date from first-date to last-date do
(if (setq mark (diary-sexp-entry sexp entry (if (setq mark (diary-sexp-entry sexp entry
(calendar-gregorian-from-absolute date))) (calendar-gregorian-from-absolute date)))
...@@ -1360,7 +1340,7 @@ changing the variable `diary-include-string'." ...@@ -1360,7 +1340,7 @@ changing the variable `diary-include-string'."
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (while (re-search-forward
(concat (concat
"\\(?:\\`\\|\^M\\|\n\\)" "^"
(regexp-quote diary-include-string) (regexp-quote diary-include-string)
" \"\\([^\"]*\\)\"") " \"\\([^\"]*\\)\"")
nil t) nil t)
...@@ -1450,17 +1430,17 @@ XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm, or XX:XXPM. A period (.) can ...@@ -1450,17 +1430,17 @@ XXAM, XXpm, XXPM, XX:XXam, XX:XXAM XX:XXpm, or XX:XXPM. A period (.) can
be used instead of a colon (:) to separate the hour and minute parts." be used instead of a colon (:) to separate the hour and minute parts."
(let ((case-fold-search nil)) (let ((case-fold-search nil))
(cond ((string-match ; Military time (cond ((string-match ; Military time
"\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)[:.]?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)" "\\`[ \t\n]*\\([0-9]?[0-9]\\)[:.]?\\([0-9][0-9]\\)\\(\\>\\|[^ap]\\)"
s) s)
(+ (* 100 (string-to-number (match-string 1 s))) (+ (* 100 (string-to-number (match-string 1 s)))
(string-to-number (match-string 2 s)))) (string-to-number (match-string 2 s))))
((string-match ; Hour only XXam or XXpm ((string-match ; Hour only XXam or XXpm
"\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s) "\\`[ \t\n]*\\([0-9]?[0-9]\\)\\([ap]\\)m\\>" s)
(+ (* 100 (% (string-to-number (match-string 1 s)) 12)) (+ (* 100 (% (string-to-number (match-string 1 s)) 12))
(if (equal ?a (downcase (aref s (match-beginning 2)))) (if (equal ?a (downcase (aref s (match-beginning 2))))
0 1200))) 0 1200)))
((string-match ; Hour and minute XX:XXam or XX:XXpm ((string-match ; Hour and minute XX:XXam or XX:XXpm
"\\`[ \t\n\\^M]*\\([0-9]?[0-9]\\)[:.]\\([0-9][0-9]\\)\\([ap]\\)m\\>" s) "\\`[ \t\n]*\\([0-9]?[0-9]\\)[:.]\\([0-9][0-9]\\)\\([ap]\\)m\\>" s)
(+ (* 100 (% (string-to-number (match-string 1 s)) 12)) (+ (* 100 (% (string-to-number (match-string 1 s)) 12))
(string-to-number (match-string 2 s)) (string-to-number (match-string 2 s))
(if (equal ?a (downcase (aref s (match-beginning 3)))) (if (equal ?a (downcase (aref s (match-beginning 3))))
...@@ -1630,7 +1610,7 @@ A number of built-in functions are available for this type of diary entry: ...@@ -1630,7 +1610,7 @@ A number of built-in functions are available for this type of diary entry:
Marking these entries is *extremely* time consuming, so these entries are Marking these entries is *extremely* time consuming, so these entries are
best if they are nonmarking." best if they are nonmarking."
(let ((s-entry (concat "\\(\\`\\|\^M\\|\n\\)" (let ((s-entry (concat "^"
(regexp-quote diary-nonmarking-symbol) (regexp-quote diary-nonmarking-symbol)
"?" "?"
(regexp-quote sexp-diary-entry-symbol) (regexp-quote sexp-diary-entry-symbol)
...@@ -1645,27 +1625,21 @@ best if they are nonmarking." ...@@ -1645,27 +1625,21 @@ best if they are nonmarking."
sexp entry specifier entry-start line-start) sexp entry specifier entry-start line-start)
(forward-sexp) (forward-sexp)
(setq sexp (buffer-substring-no-properties sexp-start (point))) (setq sexp (buffer-substring-no-properties sexp-start (point)))
(save-excursion (setq line-start (line-end-position 0))
(re-search-backward "\^M\\|\n\\|\\`")
(setq line-start (point)))
(setq specifier (setq specifier
(buffer-substring-no-properties (1+ line-start) (point)) (buffer-substring-no-properties (1+ line-start) (point))
entry-start (1+ line-start)) entry-start (1+ line-start))
(forward-char 1) (forward-char 1)
(if (and (or (char-equal (preceding-char) ?\^M) (if (and (bolp) (not (looking-at "[ \t]")))
(char-equal (preceding-char) ?\n))
(not (looking-at " \\|\^I")))
(progn;; Diary entry consists only of the sexp (progn;; Diary entry consists only of the sexp
(backward-char 1) (backward-char 1)
(setq entry "")) (setq entry ""))
(setq entry-start (point)) (setq entry-start (point))
(re-search-forward "\^M\\|\n" nil t) (forward-line 1)
(while (looking-at " \\|\^I") (while (looking-at "[ \t]")
(re-search-forward "\^M\\|\n" nil t)) (forward-line 1))
(backward-char 1) (backward-char 1)
(setq entry (buffer-substring-no-properties entry-start (point))) (setq entry (buffer-substring-no-properties entry-start (point))))
(while (string-match "[\^M]" entry)
(aset entry (match-beginning 0) ?\n )))
(let ((diary-entry (diary-sexp-entry sexp entry date)) (let ((diary-entry (diary-sexp-entry sexp entry date))
temp literal) temp literal)
(setq literal entry ; before evaluation (setq literal entry ; before evaluation
...@@ -2255,7 +2229,6 @@ names." ...@@ -2255,7 +2229,6 @@ names."
;; `diary-outlook-formats'. ;; `diary-outlook-formats'.
;; Dynamically bound. ;; Dynamically bound.
(defvar body)
(defvar subject) (defvar subject)
(defun diary-from-outlook-internal (&optional test-only) (defun diary-from-outlook-internal (&optional test-only)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment