diff options
| author | Glenn Morris | 2004-09-28 22:24:47 +0000 |
|---|---|---|
| committer | Glenn Morris | 2004-09-28 22:24:47 +0000 |
| commit | ba55e59fd94798ae9b30b38c198a0571bbad2e80 (patch) | |
| tree | f55929e36102b5c4121556b8f7efe3fcb1c25ad7 | |
| parent | 4676d6f34d22d9f5575574f76b59a6ba32cd4e1d (diff) | |
| download | emacs-ba55e59fd94798ae9b30b38c198a0571bbad2e80.tar.gz emacs-ba55e59fd94798ae9b30b38c198a0571bbad2e80.zip | |
Update maintainer.
From Matthew Mundell <matt@mundell.ukfsn.org> (tiny change):
(list-diary-entries): Save diary buffer from diary display excursion.
Store diary buffer's point for `simple-diary-display'.
(simple-diary-display): Set window point and start when displaying
buffer, to preserve point.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/calendar/diary-lib.el | 227 |
2 files changed, 127 insertions, 108 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c411ccf6a45..5ed7c848de8 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2004-09-28 Matthew Mundell <matt@mundell.ukfsn.org> (tiny change) | ||
| 2 | |||
| 3 | * calendar/diary-lib.el (list-diary-entries): Save diary buffer | ||
| 4 | from diary display excursion. Store diary buffer's point for | ||
| 5 | `simple-diary-display'. | ||
| 6 | (simple-diary-display): Set window point and start when | ||
| 7 | displaying buffer, to preserve point. | ||
| 8 | |||
| 1 | 2004-09-27 Luc Teirlinck <teirllm@auburn.edu> | 9 | 2004-09-27 Luc Teirlinck <teirllm@auburn.edu> |
| 2 | 10 | ||
| 3 | * textmodes/enriched.el (enriched-translations): Replace defconst | 11 | * textmodes/enriched.el (enriched-translations): Replace defconst |
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 45bb3c0e4c0..945119f06df 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; Free Software Foundation, Inc. |
| 5 | 5 | ||
| 6 | ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | 6 | ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> |
| 7 | ;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk> | ||
| 7 | ;; Keywords: calendar | 8 | ;; Keywords: calendar |
| 8 | 9 | ||
| 9 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| @@ -296,6 +297,8 @@ Only used if `diary-header-line-flag' is non-nil." | |||
| 296 | :type 'sexp | 297 | :type 'sexp |
| 297 | :version "21.4") | 298 | :version "21.4") |
| 298 | 299 | ||
| 300 | (defvar diary-saved-point) ; internal | ||
| 301 | |||
| 299 | (defun list-diary-entries (date number) | 302 | (defun list-diary-entries (date number) |
| 300 | "Create and display a buffer containing the relevant lines in diary-file. | 303 | "Create and display a buffer containing the relevant lines in diary-file. |
| 301 | The arguments are DATE and NUMBER; the entries selected are those | 304 | The arguments are DATE and NUMBER; the entries selected are those |
| @@ -345,112 +348,116 @@ These hooks have the following distinct roles: | |||
| 345 | (set-buffer diary-buffer) | 348 | (set-buffer diary-buffer) |
| 346 | (or (verify-visited-file-modtime diary-buffer) | 349 | (or (verify-visited-file-modtime diary-buffer) |
| 347 | (revert-buffer t t)))) | 350 | (revert-buffer t t)))) |
| 348 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil ""))) | 351 | ;; d-s-p is passed to the diary display function. |
| 349 | (setq selective-display t) | 352 | (let ((diary-saved-point (point))) |
| 350 | (setq selective-display-ellipses nil) | 353 | (save-excursion |
| 351 | (if diary-header-line-flag | 354 | (setq file-glob-attrs (nth 1 (diary-pull-attrs nil ""))) |
| 352 | (setq header-line-format diary-header-line-format)) | 355 | (setq selective-display t) |
| 353 | (setq old-diary-syntax-table (syntax-table)) | 356 | (setq selective-display-ellipses nil) |
| 354 | (set-syntax-table diary-syntax-table) | 357 | (if diary-header-line-flag |
| 355 | (unwind-protect | 358 | (setq header-line-format diary-header-line-format)) |
| 356 | (let ((buffer-read-only nil) | 359 | (setq old-diary-syntax-table (syntax-table)) |
| 357 | (diary-modified (buffer-modified-p)) | 360 | (set-syntax-table diary-syntax-table) |
| 358 | (mark (regexp-quote diary-nonmarking-symbol))) | 361 | (unwind-protect |
| 359 | ;; First and last characters must be ^M or \n for | 362 | (let ((buffer-read-only nil) |
| 360 | ;; selective display to work properly | 363 | (diary-modified (buffer-modified-p)) |
| 361 | (goto-char (1- (point-max))) | 364 | (mark (regexp-quote diary-nonmarking-symbol))) |
| 362 | (if (not (looking-at "\^M\\|\n")) | 365 | ;; First and last characters must be ^M or \n for |
| 363 | (progn | 366 | ;; selective display to work properly |
| 364 | (goto-char (point-max)) | 367 | (goto-char (1- (point-max))) |
| 365 | (insert "\^M"))) | 368 | (if (not (looking-at "\^M\\|\n")) |
| 366 | (goto-char (point-min)) | 369 | (progn |
| 367 | (if (not (looking-at "\^M\\|\n")) | 370 | (goto-char (point-max)) |
| 368 | (insert "\^M")) | 371 | (insert "\^M"))) |
| 369 | (subst-char-in-region (point-min) (point-max) ?\n ?\^M t) | 372 | (goto-char (point-min)) |
| 370 | (calendar-for-loop i from 1 to number do | 373 | (if (not (looking-at "\^M\\|\n")) |
| 371 | (let ((d diary-date-forms) | 374 | (insert "\^M")) |
| 372 | (month (extract-calendar-month date)) | 375 | (subst-char-in-region (point-min) (point-max) ?\n ?\^M t) |
| 373 | (day (extract-calendar-day date)) | 376 | (calendar-for-loop |
| 374 | (year (extract-calendar-year date)) | 377 | i from 1 to number do |
| 375 | (entry-found (list-sexp-diary-entries date))) | 378 | (let ((d diary-date-forms) |
| 376 | (while d | 379 | (month (extract-calendar-month date)) |
| 377 | (let* | 380 | (day (extract-calendar-day date)) |
| 378 | ((date-form (if (equal (car (car d)) 'backup) | 381 | (year (extract-calendar-year date)) |
| 379 | (cdr (car d)) | 382 | (entry-found (list-sexp-diary-entries date))) |
| 380 | (car d))) | 383 | (while d |
| 381 | (backup (equal (car (car d)) 'backup)) | 384 | (let* |
| 382 | (dayname | 385 | ((date-form (if (equal (car (car d)) 'backup) |
| 383 | (format "%s\\|%s\\.?" | 386 | (cdr (car d)) |
| 384 | (calendar-day-name date) | 387 | (car d))) |
| 385 | (calendar-day-name date 'abbrev))) | 388 | (backup (equal (car (car d)) 'backup)) |
| 386 | (monthname | 389 | (dayname |
| 387 | (format "\\*\\|%s\\|%s\\.?" | 390 | (format "%s\\|%s\\.?" |
| 388 | (calendar-month-name month) | 391 | (calendar-day-name date) |
| 389 | (calendar-month-name month 'abbrev))) | 392 | (calendar-day-name date 'abbrev))) |
| 390 | (month (concat "\\*\\|0*" (int-to-string month))) | 393 | (monthname |
| 391 | (day (concat "\\*\\|0*" (int-to-string day))) | 394 | (format "\\*\\|%s\\|%s\\.?" |
| 392 | (year | 395 | (calendar-month-name month) |
| 393 | (concat | 396 | (calendar-month-name month 'abbrev))) |
| 394 | "\\*\\|0*" (int-to-string year) | 397 | (month (concat "\\*\\|0*" (int-to-string month))) |
| 395 | (if abbreviated-calendar-year | 398 | (day (concat "\\*\\|0*" (int-to-string day))) |
| 396 | (concat "\\|" (format "%02d" (% year 100))) | 399 | (year |
| 397 | ""))) | 400 | (concat |
| 398 | (regexp | 401 | "\\*\\|0*" (int-to-string year) |
| 399 | (concat | 402 | (if abbreviated-calendar-year |
| 400 | "\\(\\`\\|\^M\\|\n\\)" mark "?\\(" | 403 | (concat "\\|" (format "%02d" (% year 100))) |
| 401 | (mapconcat 'eval date-form "\\)\\(") | 404 | ""))) |
| 402 | "\\)")) | 405 | (regexp |
| 403 | (case-fold-search t)) | 406 | (concat |
| 404 | (goto-char (point-min)) | 407 | "\\(\\`\\|\^M\\|\n\\)" mark "?\\(" |
| 405 | (while (re-search-forward regexp nil t) | 408 | (mapconcat 'eval date-form "\\)\\(") |
| 406 | (if backup (re-search-backward "\\<" nil t)) | 409 | "\\)")) |
| 407 | (if (and (or (char-equal (preceding-char) ?\^M) | 410 | (case-fold-search t)) |
| 408 | (char-equal (preceding-char) ?\n)) | 411 | (goto-char (point-min)) |
| 409 | (not (looking-at " \\|\^I"))) | 412 | (while (re-search-forward regexp nil t) |
| 410 | ;; Diary entry that consists only of date. | 413 | (if backup (re-search-backward "\\<" nil t)) |
| 411 | (backward-char 1) | 414 | (if (and (or (char-equal (preceding-char) ?\^M) |
| 412 | ;; Found a nonempty diary entry--make it visible and | 415 | (char-equal (preceding-char) ?\n)) |
| 413 | ;; add it to the list. | 416 | (not (looking-at " \\|\^I"))) |
| 414 | (setq entry-found t) | 417 | ;; Diary entry that consists only of date. |
| 415 | (let ((entry-start (point)) | 418 | (backward-char 1) |
| 416 | date-start temp) | 419 | ;; Found a nonempty diary entry--make it |
| 417 | (re-search-backward "\^M\\|\n\\|\\`") | 420 | ;; visible and add it to the list. |
| 418 | (setq date-start (point)) | 421 | (setq entry-found t) |
| 419 | (re-search-forward "\^M\\|\n" nil t 2) | 422 | (let ((entry-start (point)) |
| 420 | (while (looking-at " \\|\^I") | 423 | date-start temp) |
| 421 | (re-search-forward "\^M\\|\n" nil t)) | 424 | (re-search-backward "\^M\\|\n\\|\\`") |
| 422 | (backward-char 1) | 425 | (setq date-start (point)) |
| 423 | (subst-char-in-region date-start | 426 | (re-search-forward "\^M\\|\n" nil t 2) |
| 424 | (point) ?\^M ?\n t) | 427 | (while (looking-at " \\|\^I") |
| 425 | (setq entry (buffer-substring entry-start (point)) | 428 | (re-search-forward "\^M\\|\n" nil t)) |
| 426 | temp (diary-pull-attrs entry file-glob-attrs) | 429 | (backward-char 1) |
| 427 | entry (nth 0 temp)) | 430 | (subst-char-in-region date-start |
| 428 | (add-to-diary-list | 431 | (point) ?\^M ?\n t) |
| 429 | date | 432 | (setq entry (buffer-substring entry-start (point)) |
| 430 | entry | 433 | temp (diary-pull-attrs entry file-glob-attrs) |
| 431 | (buffer-substring | 434 | entry (nth 0 temp)) |
| 432 | (1+ date-start) (1- entry-start)) | 435 | (add-to-diary-list |
| 433 | (copy-marker entry-start) (nth 1 temp)))))) | 436 | date |
| 434 | (setq d (cdr d))) | 437 | entry |
| 435 | (or entry-found | 438 | (buffer-substring |
| 436 | (not diary-list-include-blanks) | 439 | (1+ date-start) (1- entry-start)) |
| 437 | (setq diary-entries-list | 440 | (copy-marker entry-start) (nth 1 temp)))))) |
| 438 | (append diary-entries-list | 441 | (setq d (cdr d))) |
| 439 | (list (list date "" "" "" ""))))) | 442 | (or entry-found |
| 440 | (setq date | 443 | (not diary-list-include-blanks) |
| 441 | (calendar-gregorian-from-absolute | 444 | (setq diary-entries-list |
| 442 | (1+ (calendar-absolute-from-gregorian date)))) | 445 | (append diary-entries-list |
| 443 | (setq entry-found nil))) | 446 | (list (list date "" "" "" ""))))) |
| 444 | (set-buffer-modified-p diary-modified)) | 447 | (setq date |
| 445 | (set-syntax-table old-diary-syntax-table)) | 448 | (calendar-gregorian-from-absolute |
| 446 | (goto-char (point-min)) | 449 | (1+ (calendar-absolute-from-gregorian date)))) |
| 447 | (run-hooks 'nongregorian-diary-listing-hook | 450 | (setq entry-found nil))) |
| 448 | 'list-diary-entries-hook) | 451 | (set-buffer-modified-p diary-modified)) |
| 449 | (if diary-display-hook | 452 | (set-syntax-table old-diary-syntax-table)) |
| 450 | (run-hooks 'diary-display-hook) | 453 | (goto-char (point-min)) |
| 451 | (simple-diary-display)) | 454 | (run-hooks 'nongregorian-diary-listing-hook |
| 452 | (run-hooks 'diary-hook) | 455 | 'list-diary-entries-hook) |
| 453 | diary-entries-list)))) | 456 | (if diary-display-hook |
| 457 | (run-hooks 'diary-display-hook) | ||
| 458 | (simple-diary-display)) | ||
| 459 | (run-hooks 'diary-hook) | ||
| 460 | diary-entries-list)))))) | ||
| 454 | 461 | ||
| 455 | (defun include-other-diary-files () | 462 | (defun include-other-diary-files () |
| 456 | "Include the diary entries from other diary files with those of diary-file. | 463 | "Include the diary entries from other diary files with those of diary-file. |
| @@ -528,8 +535,12 @@ changing the variable `diary-include-string'." | |||
| 528 | (setq buffer-read-only t) | 535 | (setq buffer-read-only t) |
| 529 | (display-buffer holiday-buffer) | 536 | (display-buffer holiday-buffer) |
| 530 | (message "No diary entries for %s" date-string)) | 537 | (message "No diary entries for %s" date-string)) |
| 531 | (display-buffer (find-buffer-visiting | 538 | (with-current-buffer |
| 532 | (substitute-in-file-name diary-file))) | 539 | (find-buffer-visiting (substitute-in-file-name diary-file)) |
| 540 | (let ((window (display-buffer (current-buffer)))) | ||
| 541 | ;; d-s-p is passed from list-diary-entries. | ||
| 542 | (set-window-point window diary-saved-point) | ||
| 543 | (set-window-start window (point-min)))) | ||
| 533 | (message "Preparing diary...done")))) | 544 | (message "Preparing diary...done")))) |
| 534 | 545 | ||
| 535 | (defface diary-button-face '((((type pc) (class color)) | 546 | (defface diary-button-face '((((type pc) (class color)) |