diff options
| author | Stefan Monnier | 2007-07-25 21:59:26 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-07-25 21:59:26 +0000 |
| commit | 458cf788b792055cb8f40e5faaf1085c48fdf7c4 (patch) | |
| tree | 7aaa0813a9e3da03ecba97377f15350a04f94830 | |
| parent | 05efa389a5bb4f99824037596a347278eb58fa85 (diff) | |
| download | emacs-458cf788b792055cb8f40e5faaf1085c48fdf7c4.tar.gz emacs-458cf788b792055cb8f40e5faaf1085c48fdf7c4.zip | |
(calendar-mode-map): Move initialization into declaration.
Add menu bindings (used to be done in cal-menu).
(calendar-mode): Don't add an activate-menubar-hook.
| -rw-r--r-- | lisp/ChangeLog | 24 | ||||
| -rw-r--r-- | lisp/calendar/calendar.el | 53 |
2 files changed, 59 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ef350751248..1870551ca77 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,27 @@ | |||
| 1 | 2007-07-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * calendar/calendar.el (calendar-mode-map): Move initialization | ||
| 4 | into declaration. Add menu bindings (used to be done in cal-menu). | ||
| 5 | (calendar-mode): Don't add an activate-menubar-hook. | ||
| 6 | |||
| 7 | * calendar/cal-menu.el: Break dependency on calendar.el (i.e. do not | ||
| 8 | modify calendar-mode-map), use easy-menu, and make sure that C-h k | ||
| 9 | can be used on the menu entries. | ||
| 10 | (cal-menu-holiday-window-suffix, cal-menu-set-date-title): New funs. | ||
| 11 | (cal-menu-moon-menu, cal-menu-diary-menu, cal-menu-holidays-menu) | ||
| 12 | (cal-menu-goto-menu, cal-menu-scroll-menu): New consts. | ||
| 13 | (cal-menu-context-mouse-menu, cal-menu-global-mouse-menu): New menus. | ||
| 14 | (calendar-flatten, cal-menu-update): Remove. | ||
| 15 | (calendar-mouse-insert-hebrew-diary-entry) | ||
| 16 | (calendar-mouse-insert-islamic-diary-entry) | ||
| 17 | (calendar-mouse-insert-bahai-diary-entry): | ||
| 18 | Remove (fold into cal-menu-diary-menu). | ||
| 19 | (calendar-mouse-2-date-menu, calendar-mouse-cal-tex-menu) | ||
| 20 | (cal-tex-mouse-filofax): Remove (fold into cal-menu-context-mouse-menu). | ||
| 21 | (calendar-mouse-3-map): Remove (turn into cal-menu-global-mouse-menu). | ||
| 22 | (calendar-mouse-view-diary-entries): Minor simplifications. | ||
| 23 | (calendar-event-to-date): Use with-current-buffer. | ||
| 24 | |||
| 1 | 2007-07-25 Nick Roberts <nickrob@snap.net.nz> | 25 | 2007-07-25 Nick Roberts <nickrob@snap.net.nz> |
| 2 | 26 | ||
| 3 | * add-log.el (change-log-redate): Remove (not needed anymore and | 27 | * add-log.el (change-log-redate): Remove (not needed anymore and |
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 74ee75f295b..b2369dec0b0 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el | |||
| @@ -1677,9 +1677,11 @@ to be replaced by asterisks to highlight it whenever it is in the window." | |||
| 1677 | ;; (calendar-read-date t) returns a date with day = nil, which is | 1677 | ;; (calendar-read-date t) returns a date with day = nil, which is |
| 1678 | ;; not a legal date for the visible test in the diary section. | 1678 | ;; not a legal date for the visible test in the diary section. |
| 1679 | (if arg (setcar (cdr date) 1)) | 1679 | (if arg (setcar (cdr date) 1)) |
| 1680 | (pop-to-buffer calendar-buffer) | ||
| 1681 | (increment-calendar-month month year (- calendar-offset)) | 1680 | (increment-calendar-month month year (- calendar-offset)) |
| 1682 | (generate-calendar-window month year) | 1681 | (generate-calendar-window month year) |
| 1682 | ;; Display the buffer *after* generating it, so that menu entries that | ||
| 1683 | ;; use display-month do not fail when creating the new frame. | ||
| 1684 | (pop-to-buffer calendar-buffer) | ||
| 1683 | (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) | 1685 | (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) |
| 1684 | (diary-view-entries))) | 1686 | (diary-view-entries))) |
| 1685 | (let* ((diary-buffer (get-file-buffer diary-file)) | 1687 | (let* ((diary-buffer (get-file-buffer diary-file)) |
| @@ -2102,10 +2104,10 @@ Or, for optional MON, YR." | |||
| 2102 | 2104 | ||
| 2103 | (defun generate-calendar (month year) | 2105 | (defun generate-calendar (month year) |
| 2104 | "Generate a three-month Gregorian calendar centered around MONTH, YEAR." | 2106 | "Generate a three-month Gregorian calendar centered around MONTH, YEAR." |
| 2105 | ;;; A negative YEAR is interpreted as BC; -1 being 1 BC, and so on. | 2107 | ;; A negative YEAR is interpreted as BC; -1 being 1 BC, and so on. |
| 2106 | ;;; Note that while calendars for years BC could be displayed as it | 2108 | ;; Note that while calendars for years BC could be displayed as it |
| 2107 | ;;; stands, almost all other calendar functions (eg holidays) would | 2109 | ;; stands, almost all other calendar functions (eg holidays) would |
| 2108 | ;;; at best have unpredictable results for such dates. | 2110 | ;; at best have unpredictable results for such dates. |
| 2109 | (if (< (+ month (* 12 (1- year))) 2) | 2111 | (if (< (+ month (* 12 (1- year))) 2) |
| 2110 | (error "Months before January, 1 AD cannot be displayed")) | 2112 | (error "Months before January, 1 AD cannot be displayed")) |
| 2111 | (setq displayed-month month | 2113 | (setq displayed-month month |
| @@ -2212,9 +2214,9 @@ movement commands will not work correctly." | |||
| 2212 | :type 'boolean | 2214 | :type 'boolean |
| 2213 | :group 'calendar) | 2215 | :group 'calendar) |
| 2214 | 2216 | ||
| 2215 | (defvar calendar-mode-map nil) | 2217 | (require 'cal-menu) |
| 2216 | (if calendar-mode-map | 2218 | |
| 2217 | nil | 2219 | (defvar calendar-mode-map |
| 2218 | (let ((map (make-keymap))) | 2220 | (let ((map (make-keymap))) |
| 2219 | (suppress-keymap map) | 2221 | (suppress-keymap map) |
| 2220 | (dolist (c '(narrow-to-region mark-word mark-sexp mark-paragraph | 2222 | (dolist (c '(narrow-to-region mark-word mark-sexp mark-paragraph |
| @@ -2250,7 +2252,7 @@ movement commands will not work correctly." | |||
| 2250 | (define-key map "\e>" 'calendar-end-of-year) | 2252 | (define-key map "\e>" 'calendar-end-of-year) |
| 2251 | (define-key map "\C-@" 'calendar-set-mark) | 2253 | (define-key map "\C-@" 'calendar-set-mark) |
| 2252 | ;; Many people are used to typing C-SPC and getting C-@. | 2254 | ;; Many people are used to typing C-SPC and getting C-@. |
| 2253 | (define-key map [?\C- ] 'calendar-set-mark) | 2255 | (define-key map [?\C-\s] 'calendar-set-mark) |
| 2254 | (define-key map "\C-x\C-x" 'calendar-exchange-point-and-mark) | 2256 | (define-key map "\C-x\C-x" 'calendar-exchange-point-and-mark) |
| 2255 | (define-key map "\e=" 'calendar-count-days-region) | 2257 | (define-key map "\e=" 'calendar-count-days-region) |
| 2256 | (define-key map "gd" 'calendar-goto-date) | 2258 | (define-key map "gd" 'calendar-goto-date) |
| @@ -2338,9 +2340,26 @@ movement commands will not work correctly." | |||
| 2338 | (define-key map "tfy" 'cal-tex-cursor-filofax-year) | 2340 | (define-key map "tfy" 'cal-tex-cursor-filofax-year) |
| 2339 | (define-key map "ty" 'cal-tex-cursor-year) | 2341 | (define-key map "ty" 'cal-tex-cursor-year) |
| 2340 | (define-key map "tY" 'cal-tex-cursor-year-landscape) | 2342 | (define-key map "tY" 'cal-tex-cursor-year-landscape) |
| 2341 | (setq calendar-mode-map map) | 2343 | |
| 2342 | ;; Require cal-menu after initializing calendar-mode-map because it uses it. | 2344 | (define-key map [menu-bar edit] 'undefined) |
| 2343 | (require 'cal-menu))) | 2345 | (define-key map [menu-bar search] 'undefined) |
| 2346 | ;; This ignores the mouse-up event after the mouse-down that pops up the | ||
| 2347 | ;; context menu. It should not be necessary because the mouse-up event | ||
| 2348 | ;; should be eaten up by the menu-handling toolkit. | ||
| 2349 | ;; (define-key map [mouse-2] 'ignore) | ||
| 2350 | |||
| 2351 | (easy-menu-define nil map nil cal-menu-moon-menu) | ||
| 2352 | (easy-menu-define nil map nil cal-menu-diary-menu) | ||
| 2353 | (easy-menu-define nil map nil cal-menu-holidays-menu) | ||
| 2354 | (easy-menu-define nil map nil cal-menu-goto-menu) | ||
| 2355 | (easy-menu-define nil map nil cal-menu-scroll-menu) | ||
| 2356 | |||
| 2357 | (define-key map [down-mouse-3] | ||
| 2358 | (easy-menu-binding cal-menu-context-mouse-menu)) | ||
| 2359 | (define-key map [down-mouse-2] | ||
| 2360 | (easy-menu-binding cal-menu-global-mouse-menu)) | ||
| 2361 | |||
| 2362 | map)) | ||
| 2344 | 2363 | ||
| 2345 | (defun describe-calendar-mode () | 2364 | (defun describe-calendar-mode () |
| 2346 | "Create a help buffer with a brief description of the `calendar-mode'." | 2365 | "Create a help buffer with a brief description of the `calendar-mode'." |
| @@ -2401,8 +2420,8 @@ evaluated and concatenated together, evenly separated by blanks. The variable | |||
| 2401 | `date' is available for use as the date under (or near) the cursor; `date' | 2420 | `date' is available for use as the date under (or near) the cursor; `date' |
| 2402 | defaults to the current date if it is otherwise undefined. Here is an example | 2421 | defaults to the current date if it is otherwise undefined. Here is an example |
| 2403 | value that has the Hebrew date, the day number/days remaining in the year, | 2422 | value that has the Hebrew date, the day number/days remaining in the year, |
| 2404 | and the ISO week/year numbers in the mode. When calendar-move-hook is set to | 2423 | and the ISO week/year numbers in the mode. When `calendar-move-hook' is set |
| 2405 | 'update-calendar-mode-line, these mode line shows these values for the date | 2424 | to `update-calendar-mode-line', these mode line shows these values for the date |
| 2406 | under the cursor: | 2425 | under the cursor: |
| 2407 | 2426 | ||
| 2408 | (list | 2427 | (list |
| @@ -2418,8 +2437,7 @@ under the cursor: | |||
| 2418 | (format \"ISO week %d of %d\" | 2437 | (format \"ISO week %d of %d\" |
| 2419 | (extract-calendar-month iso-date) | 2438 | (extract-calendar-month iso-date) |
| 2420 | (extract-calendar-year iso-date))) | 2439 | (extract-calendar-year iso-date))) |
| 2421 | \"\")) | 2440 | \"\"))") |
| 2422 | ") | ||
| 2423 | 2441 | ||
| 2424 | (defun mouse-scroll-calendar-left (event) | 2442 | (defun mouse-scroll-calendar-left (event) |
| 2425 | "Scroll the displayed calendar left by one month. | 2443 | "Scroll the displayed calendar left by one month. |
| @@ -2474,7 +2492,6 @@ For a complete description, type \ | |||
| 2474 | (setq buffer-read-only t) | 2492 | (setq buffer-read-only t) |
| 2475 | (setq indent-tabs-mode nil) | 2493 | (setq indent-tabs-mode nil) |
| 2476 | (update-calendar-mode-line) | 2494 | (update-calendar-mode-line) |
| 2477 | (add-hook 'activate-menubar-hook 'cal-menu-update nil t) | ||
| 2478 | (make-local-variable 'calendar-mark-ring) | 2495 | (make-local-variable 'calendar-mark-ring) |
| 2479 | (make-local-variable 'displayed-month);; Month in middle of window. | 2496 | (make-local-variable 'displayed-month);; Month in middle of window. |
| 2480 | (make-local-variable 'displayed-year) ;; Year in middle of window. | 2497 | (make-local-variable 'displayed-year) ;; Year in middle of window. |
| @@ -2598,7 +2615,7 @@ ERROR is t, otherwise just returns nil." | |||
| 2598 | (< 2 (count-lines (point-min) (point)))) | 2615 | (< 2 (count-lines (point-min) (point)))) |
| 2599 | (save-excursion | 2616 | (save-excursion |
| 2600 | (if (not (looking-at " ")) | 2617 | (if (not (looking-at " ")) |
| 2601 | (re-search-backward "[^0-9]")) | 2618 | (re-search-backward "[^0-9]")) |
| 2602 | (list month | 2619 | (list month |
| 2603 | (string-to-number (buffer-substring (1+ (point)) (+ 4 (point)))) | 2620 | (string-to-number (buffer-substring (1+ (point)) (+ 4 (point)))) |
| 2604 | year)) | 2621 | year)) |