Mercurial > emacs
annotate lisp/calendar/cal-move.el @ 110149:4ac2b883320e
Forgor to save ChangeLog for previous commit.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Thu, 02 Sep 2010 12:20:20 +0200 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
rev | line source |
---|---|
13053 | 1 ;;; cal-move.el --- calendar functions for movement in the calendar |
2 | |
106815 | 3 ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
67465
a55ee709ec8d
Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents:
65919
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
13053 | 5 |
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
65919
5c09efcfc1d9
Update maintainer email address.
Glenn Morris <rgm@gnu.org>
parents:
64085
diff
changeset
|
7 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
13053 | 8 ;; Keywords: calendar |
9 ;; Human-Keywords: calendar | |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
10 ;; Package: calendar |
13053 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94312
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
13053 | 15 ;; it under the terms of the GNU General Public License as published by |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94312
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94312
diff
changeset
|
17 ;; (at your option) any later version. |
13053 | 18 |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94312
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
13053 | 26 |
27 ;;; Commentary: | |
28 | |
93486
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
29 ;; See calendar.el. |
13053 | 30 |
31 ;;; Code: | |
32 | |
96159
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
33 ;; FIXME should calendar just require this? |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
34 (require 'calendar) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
35 |
96296
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
36 |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
37 ;; Note that this is not really the "closest" date. |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
38 ;; In most cases, it just searches forwards for the next day. |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
39 ;;;###cal-autoload |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
40 (defun calendar-cursor-to-nearest-date () |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
41 "Move the cursor to the closest date. |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
42 The position of the cursor is unchanged if it is already on a date. |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
43 Returns the list (month day year) giving the cursor position." |
93329
6139daabcf5f
(calendar-cursor-to-nearest-date): Remove un-needed local `date'.
Glenn Morris <rgm@gnu.org>
parents:
92916
diff
changeset
|
44 (or (calendar-cursor-to-date) |
96296
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
45 (let* ((col (current-column)) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
46 (edges (cdr (assoc (calendar-column-to-segment) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
47 calendar-month-edges))) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
48 (last (nth 2 edges)) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
49 (right (nth 3 edges))) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
50 (when (< (count-lines (point-min) (point)) calendar-first-date-row) |
104385
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
51 (goto-char (point-min)) |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
52 (forward-line (1- calendar-first-date-row)) |
96296
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
53 (move-to-column col)) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
54 ;; The date positions are fixed and computable, but searching |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
55 ;; is probably more flexible. Need to consider blank days at |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
56 ;; start and end of month if computing positions. |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
57 ;; 'date text-property is used to exclude intermonth text. |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
58 (unless (and (looking-at "[0-9]") |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
59 (get-text-property (point) 'date)) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
60 ;; We search forwards for a number, except close to the RH |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
61 ;; margin of a month, where we search backwards. |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
62 ;; Note that the searches can go to other lines. |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
63 (if (or (looking-at " *$") |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
64 (and (> col last) (< col right))) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
65 (while (and (re-search-backward "[0-9]" nil t) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
66 (not (get-text-property (point) 'date)))) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
67 (while (and (re-search-forward "[0-9]" nil t) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
68 (not (get-text-property (1- (point)) 'date)))) |
e8b908e44add
(calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents:
96159
diff
changeset
|
69 (backward-char 1))) |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
70 (calendar-cursor-to-date)))) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
71 |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
72 (defvar displayed-month) ; from calendar-generate |
52112
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
31670
diff
changeset
|
73 (defvar displayed-year) |
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
31670
diff
changeset
|
74 |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
75 ;;;###cal-autoload |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
76 (defun calendar-cursor-to-visible-date (date) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
77 "Move the cursor to DATE that is on the screen." |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
78 (let ((month (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
79 (day (calendar-extract-day date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
80 (year (calendar-extract-year date))) |
104385
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
81 (goto-char (point-min)) |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
82 (forward-line (+ calendar-first-date-row -1 |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
83 (/ (+ day -1 |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
84 (mod |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
85 (- (calendar-day-of-week (list month 1 year)) |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
86 calendar-week-start-day) |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
87 7)) |
bc2e79adb401
(calendar-cursor-to-nearest-date, calendar-cursor-to-visible-date):
Glenn Morris <rgm@gnu.org>
parents:
103269
diff
changeset
|
88 7))) |
96159
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
89 (move-to-column (+ calendar-left-margin (1- calendar-day-digit-width) |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
90 (* calendar-month-width |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
91 (1+ (calendar-interval |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
92 displayed-month displayed-year month year))) |
96159
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
93 (* calendar-column-width |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
94 (mod |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
95 (- (calendar-day-of-week date) |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
96 calendar-week-start-day) |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
97 7)))))) |
19892 | 98 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
99 ;;;###cal-autoload |
13053 | 100 (defun calendar-goto-today () |
101 "Reposition the calendar window so the current date is visible." | |
102 (interactive) | |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
103 (let ((today (calendar-current-date))) ; the date might have changed |
13053 | 104 (if (not (calendar-date-is-visible-p today)) |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
105 (calendar-generate-window) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
106 (calendar-update-mode-line) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
107 (calendar-cursor-to-visible-date today))) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
108 (run-hooks 'calendar-move-hook)) |
13053 | 109 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
110 ;;;###cal-autoload |
13053 | 111 (defun calendar-forward-month (arg) |
112 "Move the cursor forward ARG months. | |
113 Movement is backward if ARG is negative." | |
114 (interactive "p") | |
115 (calendar-cursor-to-nearest-date) | |
116 (let* ((cursor-date (calendar-cursor-to-date t)) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
117 (month (calendar-extract-month cursor-date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
118 (day (calendar-extract-day cursor-date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
119 (year (calendar-extract-year cursor-date)) |
93486
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
120 (last (progn |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
121 (calendar-increment-month month year arg) |
93486
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
122 (calendar-last-day-of-month month year))) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
123 (day (min last day)) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
124 ;; Put the new month on the screen, if needed, and go to the new date. |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
125 (new-cursor-date (list month day year))) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
126 (if (not (calendar-date-is-visible-p new-cursor-date)) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
127 (calendar-other-month month year)) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
128 (calendar-cursor-to-visible-date new-cursor-date)) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
129 (run-hooks 'calendar-move-hook)) |
13053 | 130 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
131 ;;;###cal-autoload |
13053 | 132 (defun calendar-forward-year (arg) |
133 "Move the cursor forward by ARG years. | |
134 Movement is backward if ARG is negative." | |
135 (interactive "p") | |
136 (calendar-forward-month (* 12 arg))) | |
137 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
138 ;;;###cal-autoload |
13053 | 139 (defun calendar-backward-month (arg) |
140 "Move the cursor backward by ARG months. | |
141 Movement is forward if ARG is negative." | |
142 (interactive "p") | |
143 (calendar-forward-month (- arg))) | |
144 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
145 ;;;###cal-autoload |
13053 | 146 (defun calendar-backward-year (arg) |
147 "Move the cursor backward ARG years. | |
148 Movement is forward is ARG is negative." | |
149 (interactive "p") | |
150 (calendar-forward-month (* -12 arg))) | |
151 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
152 ;;;###cal-autoload |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
153 (defun calendar-scroll-left (&optional arg event) |
13053 | 154 "Scroll the displayed calendar left by ARG months. |
155 If ARG is negative the calendar is scrolled right. Maintains the relative | |
92634
decf6dfe9876
(calendar-scroll-left, calendar-scroll-right): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92590
diff
changeset
|
156 position of the cursor with respect to the calendar as well as possible. |
decf6dfe9876
(calendar-scroll-left, calendar-scroll-right): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92590
diff
changeset
|
157 EVENT is an event like `last-nonmenu-event'." |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
158 (interactive (list (prefix-numeric-value current-prefix-arg) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
159 last-nonmenu-event)) |
31670 | 160 (unless arg (setq arg 1)) |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
161 (save-selected-window |
94312
eaaf578ce48f
(calendar-scroll-left): Handle case when event-start is nil.
Glenn Morris <rgm@gnu.org>
parents:
93844
diff
changeset
|
162 ;; Nil if called from menu-bar. |
eaaf578ce48f
(calendar-scroll-left): Handle case when event-start is nil.
Glenn Morris <rgm@gnu.org>
parents:
93844
diff
changeset
|
163 (if (setq event (event-start event)) (select-window (posn-window event))) |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
164 (calendar-cursor-to-nearest-date) |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
165 (unless (zerop arg) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
166 (let ((old-date (calendar-cursor-to-date)) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
167 (today (calendar-current-date)) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
168 (month displayed-month) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
169 (year displayed-year)) |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
170 (calendar-increment-month month year arg) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
171 (calendar-generate-window month year) |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
172 (calendar-cursor-to-visible-date |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
173 (cond |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
174 ((calendar-date-is-visible-p old-date) old-date) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
175 ((calendar-date-is-visible-p today) today) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
176 (t (list month 1 year)))))) |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
177 (run-hooks 'calendar-move-hook))) |
13053 | 178 |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
179 (define-obsolete-function-alias |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
180 'scroll-calendar-left 'calendar-scroll-left "23.1") |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
181 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
182 ;;;###cal-autoload |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
183 (defun calendar-scroll-right (&optional arg event) |
13053 | 184 "Scroll the displayed calendar window right by ARG months. |
185 If ARG is negative the calendar is scrolled left. Maintains the relative | |
92634
decf6dfe9876
(calendar-scroll-left, calendar-scroll-right): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92590
diff
changeset
|
186 position of the cursor with respect to the calendar as well as possible. |
decf6dfe9876
(calendar-scroll-left, calendar-scroll-right): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
92590
diff
changeset
|
187 EVENT is an event like `last-nonmenu-event'." |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
188 (interactive (list (prefix-numeric-value current-prefix-arg) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
189 last-nonmenu-event)) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
190 (calendar-scroll-left (- (or arg 1)) event)) |
13053 | 191 |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
192 (define-obsolete-function-alias |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
193 'scroll-calendar-right 'calendar-scroll-right "23.1") |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
194 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
195 ;;;###cal-autoload |
101085
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
196 (defun calendar-scroll-left-three-months (arg &optional event) |
13053 | 197 "Scroll the displayed calendar window left by 3*ARG months. |
198 If ARG is negative the calendar is scrolled right. Maintains the relative | |
101085
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
199 position of the cursor with respect to the calendar as well as possible. |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
200 EVENT is an event like `last-nonmenu-event'." |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
201 (interactive (list (prefix-numeric-value current-prefix-arg) |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
202 last-nonmenu-event)) |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
203 (calendar-scroll-left (* 3 arg) event)) |
13053 | 204 |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
205 (define-obsolete-function-alias 'scroll-calendar-left-three-months |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
206 'calendar-scroll-left-three-months "23.1") |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
207 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
208 ;;;###cal-autoload |
101085
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
209 (defun calendar-scroll-right-three-months (arg &optional event) |
13053 | 210 "Scroll the displayed calendar window right by 3*ARG months. |
211 If ARG is negative the calendar is scrolled left. Maintains the relative | |
101085
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
212 position of the cursor with respect to the calendar as well as possible. |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
213 EVENT is an event like `last-nonmenu-event'." |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
214 (interactive (list (prefix-numeric-value current-prefix-arg) |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
215 last-nonmenu-event)) |
8d9cf977e8f5
(calendar-scroll-left-three-months, calendar-scroll-right-three-months):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
216 (calendar-scroll-left (* -3 arg) event)) |
13053 | 217 |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
218 (define-obsolete-function-alias 'scroll-calendar-right-three-months |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
219 'calendar-scroll-right-three-months "23.1") |
13053 | 220 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
221 ;;;###cal-autoload |
13053 | 222 (defun calendar-forward-day (arg) |
223 "Move the cursor forward ARG days. | |
224 Moves backward if ARG is negative." | |
225 (interactive "p") | |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
226 (unless (zerop arg) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
227 (let* ((cursor-date (or (calendar-cursor-to-date) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
228 (progn |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
229 (if (> arg 0) (setq arg (1- arg))) |
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
230 (calendar-cursor-to-nearest-date)))) |
13053 | 231 (new-cursor-date |
232 (calendar-gregorian-from-absolute | |
233 (+ (calendar-absolute-from-gregorian cursor-date) arg))) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
234 (new-display-month (calendar-extract-month new-cursor-date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
235 (new-display-year (calendar-extract-year new-cursor-date))) |
103269
9e868e938ebb
(calendar-forward-day): Fix 2008-06-21 change -
Glenn Morris <rgm@gnu.org>
parents:
101085
diff
changeset
|
236 ;; Put the new month on the screen, if needed. |
9e868e938ebb
(calendar-forward-day): Fix 2008-06-21 change -
Glenn Morris <rgm@gnu.org>
parents:
101085
diff
changeset
|
237 (unless (calendar-date-is-visible-p new-cursor-date) |
96159
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
238 ;; The next line gives smoother scrolling IMO (one month at a |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
239 ;; time rather than two). |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
240 (calendar-increment-month new-display-month new-display-year |
cb4a9a7913cd
(calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents:
94653
diff
changeset
|
241 (if (< arg 0) 1 -1)) |
103269
9e868e938ebb
(calendar-forward-day): Fix 2008-06-21 change -
Glenn Morris <rgm@gnu.org>
parents:
101085
diff
changeset
|
242 (calendar-other-month new-display-month new-display-year)) |
9e868e938ebb
(calendar-forward-day): Fix 2008-06-21 change -
Glenn Morris <rgm@gnu.org>
parents:
101085
diff
changeset
|
243 ;; Go to the new date. |
9e868e938ebb
(calendar-forward-day): Fix 2008-06-21 change -
Glenn Morris <rgm@gnu.org>
parents:
101085
diff
changeset
|
244 (calendar-cursor-to-visible-date new-cursor-date))) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
245 (run-hooks 'calendar-move-hook)) |
13053 | 246 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
247 ;;;###cal-autoload |
13053 | 248 (defun calendar-backward-day (arg) |
249 "Move the cursor back ARG days. | |
250 Moves forward if ARG is negative." | |
251 (interactive "p") | |
252 (calendar-forward-day (- arg))) | |
253 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
254 ;;;###cal-autoload |
13053 | 255 (defun calendar-forward-week (arg) |
256 "Move the cursor forward ARG weeks. | |
257 Moves backward if ARG is negative." | |
258 (interactive "p") | |
259 (calendar-forward-day (* arg 7))) | |
260 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
261 ;;;###cal-autoload |
13053 | 262 (defun calendar-backward-week (arg) |
263 "Move the cursor back ARG weeks. | |
264 Moves forward if ARG is negative." | |
265 (interactive "p") | |
266 (calendar-forward-day (* arg -7))) | |
267 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
268 ;;;###cal-autoload |
13053 | 269 (defun calendar-beginning-of-week (arg) |
270 "Move the cursor back ARG calendar-week-start-day's." | |
271 (interactive "p") | |
272 (calendar-cursor-to-nearest-date) | |
273 (let ((day (calendar-day-of-week (calendar-cursor-to-date)))) | |
274 (calendar-backward-day | |
275 (if (= day calendar-week-start-day) | |
276 (* 7 arg) | |
277 (+ (mod (- day calendar-week-start-day) 7) | |
278 (* 7 (1- arg))))))) | |
279 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
280 ;;;###cal-autoload |
13053 | 281 (defun calendar-end-of-week (arg) |
282 "Move the cursor forward ARG calendar-week-start-day+6's." | |
283 (interactive "p") | |
284 (calendar-cursor-to-nearest-date) | |
285 (let ((day (calendar-day-of-week (calendar-cursor-to-date)))) | |
286 (calendar-forward-day | |
287 (if (= day (mod (1- calendar-week-start-day) 7)) | |
288 (* 7 arg) | |
289 (+ (- 6 (mod (- day calendar-week-start-day) 7)) | |
290 (* 7 (1- arg))))))) | |
291 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
292 ;;;###cal-autoload |
13053 | 293 (defun calendar-beginning-of-month (arg) |
294 "Move the cursor backward ARG month beginnings." | |
295 (interactive "p") | |
296 (calendar-cursor-to-nearest-date) | |
297 (let* ((date (calendar-cursor-to-date)) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
298 (month (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
299 (day (calendar-extract-day date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
300 (year (calendar-extract-year date))) |
13053 | 301 (if (= day 1) |
302 (calendar-backward-month arg) | |
303 (calendar-cursor-to-visible-date (list month 1 year)) | |
304 (calendar-backward-month (1- arg))))) | |
305 | |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
306 ;;;###cal-autoload |
13053 | 307 (defun calendar-end-of-month (arg) |
308 "Move the cursor forward ARG month ends." | |
309 (interactive "p") | |
310 (calendar-cursor-to-nearest-date) | |
311 (let* ((date (calendar-cursor-to-date)) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
312 (month (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
313 (day (calendar-extract-day date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
314 (year (calendar-extract-year date)) |
93486
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
315 (last-day (calendar-last-day-of-month month year)) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
316 (last-day (progn |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
317 (unless (= day last-day) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
318 (calendar-cursor-to-visible-date |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
319 (list month last-day year)) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
320 (setq arg (1- arg))) |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
321 (calendar-increment-month month year arg) |
93486
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
322 (list month |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
323 (calendar-last-day-of-month month year) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
324 year)))) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
325 (if (not (calendar-date-is-visible-p last-day)) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
326 (calendar-other-month month year) |
b9615f927009
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93329
diff
changeset
|
327 (calendar-cursor-to-visible-date last-day))) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
328 (run-hooks 'calendar-move-hook)) |
13053 | 329 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
330 ;;;###cal-autoload |
13053 | 331 (defun calendar-beginning-of-year (arg) |
332 "Move the cursor backward ARG year beginnings." | |
333 (interactive "p") | |
334 (calendar-cursor-to-nearest-date) | |
335 (let* ((date (calendar-cursor-to-date)) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
336 (month (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
337 (day (calendar-extract-day date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
338 (year (calendar-extract-year date)) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
339 (jan-first (list 1 1 year)) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
340 (calendar-move-hook nil)) |
13053 | 341 (if (and (= day 1) (= 1 month)) |
342 (calendar-backward-month (* 12 arg)) | |
343 (if (and (= arg 1) | |
344 (calendar-date-is-visible-p jan-first)) | |
345 (calendar-cursor-to-visible-date jan-first) | |
60981
669da3d2cff9
Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents:
52401
diff
changeset
|
346 (calendar-other-month 1 (- year (1- arg))) |
669da3d2cff9
Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents:
52401
diff
changeset
|
347 (calendar-cursor-to-visible-date (list 1 1 displayed-year))))) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
348 (run-hooks 'calendar-move-hook)) |
13053 | 349 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
350 ;;;###cal-autoload |
13053 | 351 (defun calendar-end-of-year (arg) |
352 "Move the cursor forward ARG year beginnings." | |
353 (interactive "p") | |
354 (calendar-cursor-to-nearest-date) | |
355 (let* ((date (calendar-cursor-to-date)) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
356 (month (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
357 (day (calendar-extract-day date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
358 (year (calendar-extract-year date)) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
359 (dec-31 (list 12 31 year)) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
360 (calendar-move-hook nil)) |
13053 | 361 (if (and (= day 31) (= 12 month)) |
362 (calendar-forward-month (* 12 arg)) | |
363 (if (and (= arg 1) | |
364 (calendar-date-is-visible-p dec-31)) | |
365 (calendar-cursor-to-visible-date dec-31) | |
60981
669da3d2cff9
Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents:
52401
diff
changeset
|
366 (calendar-other-month 12 (+ year (1- arg))) |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
367 (calendar-cursor-to-visible-date (list 12 31 displayed-year))))) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
368 (run-hooks 'calendar-move-hook)) |
13053 | 369 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
370 ;;;###cal-autoload |
13053 | 371 (defun calendar-goto-date (date) |
372 "Move cursor to DATE." | |
373 (interactive (list (calendar-read-date))) | |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
374 (let ((month (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93486
diff
changeset
|
375 (year (calendar-extract-year date))) |
13053 | 376 (if (not (calendar-date-is-visible-p date)) |
377 (calendar-other-month | |
378 (if (and (= month 1) (= year 1)) | |
379 2 | |
380 month) | |
381 year))) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
382 (calendar-cursor-to-visible-date date) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
383 (run-hooks 'calendar-move-hook)) |
13053 | 384 |
92836
e4347538b00b
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92634
diff
changeset
|
385 ;;;###cal-autoload |
52231
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
386 (defun calendar-goto-day-of-year (year day &optional noecho) |
92916
f296fd96bd7c
(calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
92855
diff
changeset
|
387 "Move cursor to YEAR, DAY number; echo DAY/YEAR unless NOECHO is non-nil. |
52231
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
388 Negative DAY counts backward from end of year." |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
389 (interactive |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
390 (let* ((year (calendar-read |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
391 "Year (>0): " |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
392 (lambda (x) (> x 0)) |
93844
bf9ef749c23e
Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
393 (number-to-string (calendar-extract-year |
52231
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
394 (calendar-current-date))))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
395 (last (if (calendar-leap-year-p year) 366 365)) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
396 (day (calendar-read |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
397 (format "Day number (+/- 1-%d): " last) |
92590
8ef3d5355402
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
398 (lambda (x) (and (<= 1 (abs x)) (<= (abs x) last)))))) |
52231
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
399 (list year day))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
400 (calendar-goto-date |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
401 (calendar-gregorian-from-absolute |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
402 (if (< 0 day) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
403 (+ -1 day (calendar-absolute-from-gregorian (list 1 1 year))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
404 (+ 1 day (calendar-absolute-from-gregorian (list 12 31 year)))))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
405 (or noecho (calendar-print-day-of-year))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
406 |
13053 | 407 (provide 'cal-move) |
408 | |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
409 ;; arch-tag: d0883c46-7e16-4914-8ff8-8f67e699b781 |
13053 | 410 ;;; cal-move.el ends here |