Mercurial > emacs
annotate lisp/calendar/cal-move.el @ 84969:6e58c1c8c0fc
(Fgpm_mouse_start): Don't signal an error if already activated on this tty.
(Fgpm_mouse_stop): Only deactivate if it was activated on this tty.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 28 Sep 2007 20:07:54 +0000 |
parents | 0d322d300115 |
children | 107ccd98fa12 539530fa389c |
rev | line source |
---|---|
13053 | 1 ;;; cal-move.el --- calendar functions for movement in the calendar |
2 | |
75346 | 3 ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
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 | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
78216
93e11478c954
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77279
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
13053 | 16 ;; any later version. |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
13053 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; This collection of functions implements movement in the calendar for | |
31 ;; calendar.el. | |
32 | |
33 ;;; Code: | |
34 | |
52112
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
31670
diff
changeset
|
35 (defvar displayed-month) |
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
31670
diff
changeset
|
36 (defvar displayed-year) |
e7d0572ccca5
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
31670
diff
changeset
|
37 |
19892 | 38 (require 'calendar) |
39 | |
13053 | 40 (defun calendar-goto-today () |
41 "Reposition the calendar window so the current date is visible." | |
42 (interactive) | |
43 (let ((today (calendar-current-date)));; The date might have changed. | |
44 (if (not (calendar-date-is-visible-p today)) | |
45 (generate-calendar-window) | |
46 (update-calendar-mode-line) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
47 (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
|
48 (run-hooks 'calendar-move-hook)) |
13053 | 49 |
50 (defun calendar-forward-month (arg) | |
51 "Move the cursor forward ARG months. | |
52 Movement is backward if ARG is negative." | |
53 (interactive "p") | |
54 (calendar-cursor-to-nearest-date) | |
55 (let* ((cursor-date (calendar-cursor-to-date t)) | |
56 (month (extract-calendar-month cursor-date)) | |
57 (day (extract-calendar-day cursor-date)) | |
58 (year (extract-calendar-year cursor-date))) | |
59 (increment-calendar-month month year arg) | |
60 (let ((last (calendar-last-day-of-month month year))) | |
61 (if (< last day) | |
62 (setq day last))) | |
63 ;; Put the new month on the screen, if needed, and go to the new date. | |
64 (let ((new-cursor-date (list month day year))) | |
65 (if (not (calendar-date-is-visible-p new-cursor-date)) | |
66 (calendar-other-month month year)) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
67 (calendar-cursor-to-visible-date new-cursor-date))) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
68 (run-hooks 'calendar-move-hook)) |
13053 | 69 |
70 (defun calendar-forward-year (arg) | |
71 "Move the cursor forward by ARG years. | |
72 Movement is backward if ARG is negative." | |
73 (interactive "p") | |
74 (calendar-forward-month (* 12 arg))) | |
75 | |
76 (defun calendar-backward-month (arg) | |
77 "Move the cursor backward by ARG months. | |
78 Movement is forward if ARG is negative." | |
79 (interactive "p") | |
80 (calendar-forward-month (- arg))) | |
81 | |
82 (defun calendar-backward-year (arg) | |
83 "Move the cursor backward ARG years. | |
84 Movement is forward is ARG is negative." | |
85 (interactive "p") | |
86 (calendar-forward-month (* -12 arg))) | |
87 | |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
88 (defun calendar-scroll-left (&optional arg event) |
13053 | 89 "Scroll the displayed calendar left by ARG months. |
90 If ARG is negative the calendar is scrolled right. Maintains the relative | |
91 position of the cursor with respect to the calendar as well as possible." | |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
92 (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
|
93 last-nonmenu-event)) |
31670 | 94 (unless arg (setq arg 1)) |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
95 (save-selected-window |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
96 (select-window (posn-window (event-start event))) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
97 (calendar-cursor-to-nearest-date) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
98 (let ((old-date (calendar-cursor-to-date)) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
99 (today (calendar-current-date))) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
100 (if (/= arg 0) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
101 (let ((month displayed-month) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
102 (year displayed-year)) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
103 (increment-calendar-month month year arg) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
104 (generate-calendar-window month year) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
105 (calendar-cursor-to-visible-date |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
106 (cond |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
107 ((calendar-date-is-visible-p old-date) old-date) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
108 ((calendar-date-is-visible-p today) today) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
109 (t (list month 1 year))))))) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
110 (run-hooks 'calendar-move-hook))) |
13053 | 111 |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
112 (defun calendar-scroll-right (&optional arg event) |
13053 | 113 "Scroll the displayed calendar window right by ARG months. |
114 If ARG is negative the calendar is scrolled left. Maintains the relative | |
115 position of the cursor with respect to the calendar as well as possible." | |
82150
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
116 (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
|
117 last-nonmenu-event)) |
0d322d300115
(calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82148
diff
changeset
|
118 (calendar-scroll-left (- (or arg 1)) event)) |
13053 | 119 |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
120 (defun calendar-scroll-left-three-months (arg) |
13053 | 121 "Scroll the displayed calendar window left by 3*ARG months. |
122 If ARG is negative the calendar is scrolled right. Maintains the relative | |
123 position of the cursor with respect to the calendar as well as possible." | |
124 (interactive "p") | |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
125 (calendar-scroll-left (* 3 arg))) |
13053 | 126 |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
127 (defun calendar-scroll-right-three-months (arg) |
13053 | 128 "Scroll the displayed calendar window right by 3*ARG months. |
129 If ARG is negative the calendar is scrolled left. Maintains the relative | |
130 position of the cursor with respect to the calendar as well as possible." | |
131 (interactive "p") | |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
132 (calendar-scroll-left (* -3 arg))) |
13053 | 133 |
134 (defun calendar-cursor-to-nearest-date () | |
135 "Move the cursor to the closest date. | |
136 The position of the cursor is unchanged if it is already on a date. | |
137 Returns the list (month day year) giving the cursor position." | |
138 (let ((date (calendar-cursor-to-date)) | |
139 (column (current-column))) | |
140 (if date | |
141 date | |
142 (if (> 3 (count-lines (point-min) (point))) | |
143 (progn | |
144 (goto-line 3) | |
145 (move-to-column column))) | |
146 (if (not (looking-at "[0-9]")) | |
147 (if (and (not (looking-at " *$")) | |
148 (or (< column 25) | |
149 (and (> column 27) | |
150 (< column 50)) | |
151 (and (> column 52) | |
152 (< column 75)))) | |
153 (progn | |
154 (re-search-forward "[0-9]" nil t) | |
155 (backward-char 1)) | |
156 (re-search-backward "[0-9]" nil t))) | |
157 (calendar-cursor-to-date)))) | |
158 | |
159 (defun calendar-forward-day (arg) | |
160 "Move the cursor forward ARG days. | |
161 Moves backward if ARG is negative." | |
162 (interactive "p") | |
163 (if (/= 0 arg) | |
164 (let* | |
165 ((cursor-date (calendar-cursor-to-date)) | |
166 (cursor-date (if cursor-date | |
167 cursor-date | |
168 (if (> arg 0) (setq arg (1- arg))) | |
169 (calendar-cursor-to-nearest-date))) | |
170 (new-cursor-date | |
171 (calendar-gregorian-from-absolute | |
172 (+ (calendar-absolute-from-gregorian cursor-date) arg))) | |
173 (new-display-month (extract-calendar-month new-cursor-date)) | |
174 (new-display-year (extract-calendar-year new-cursor-date))) | |
175 ;; Put the new month on the screen, if needed, and go to the new date. | |
176 (if (not (calendar-date-is-visible-p new-cursor-date)) | |
177 (calendar-other-month new-display-month new-display-year)) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
178 (calendar-cursor-to-visible-date new-cursor-date))) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
179 (run-hooks 'calendar-move-hook)) |
13053 | 180 |
181 (defun calendar-backward-day (arg) | |
182 "Move the cursor back ARG days. | |
183 Moves forward if ARG is negative." | |
184 (interactive "p") | |
185 (calendar-forward-day (- arg))) | |
186 | |
187 (defun calendar-forward-week (arg) | |
188 "Move the cursor forward ARG weeks. | |
189 Moves backward if ARG is negative." | |
190 (interactive "p") | |
191 (calendar-forward-day (* arg 7))) | |
192 | |
193 (defun calendar-backward-week (arg) | |
194 "Move the cursor back ARG weeks. | |
195 Moves forward if ARG is negative." | |
196 (interactive "p") | |
197 (calendar-forward-day (* arg -7))) | |
198 | |
199 (defun calendar-beginning-of-week (arg) | |
200 "Move the cursor back ARG calendar-week-start-day's." | |
201 (interactive "p") | |
202 (calendar-cursor-to-nearest-date) | |
203 (let ((day (calendar-day-of-week (calendar-cursor-to-date)))) | |
204 (calendar-backward-day | |
205 (if (= day calendar-week-start-day) | |
206 (* 7 arg) | |
207 (+ (mod (- day calendar-week-start-day) 7) | |
208 (* 7 (1- arg))))))) | |
209 | |
210 (defun calendar-end-of-week (arg) | |
211 "Move the cursor forward ARG calendar-week-start-day+6's." | |
212 (interactive "p") | |
213 (calendar-cursor-to-nearest-date) | |
214 (let ((day (calendar-day-of-week (calendar-cursor-to-date)))) | |
215 (calendar-forward-day | |
216 (if (= day (mod (1- calendar-week-start-day) 7)) | |
217 (* 7 arg) | |
218 (+ (- 6 (mod (- day calendar-week-start-day) 7)) | |
219 (* 7 (1- arg))))))) | |
220 | |
221 (defun calendar-beginning-of-month (arg) | |
222 "Move the cursor backward ARG month beginnings." | |
223 (interactive "p") | |
224 (calendar-cursor-to-nearest-date) | |
225 (let* ((date (calendar-cursor-to-date)) | |
226 (month (extract-calendar-month date)) | |
227 (day (extract-calendar-day date)) | |
228 (year (extract-calendar-year date))) | |
229 (if (= day 1) | |
230 (calendar-backward-month arg) | |
231 (calendar-cursor-to-visible-date (list month 1 year)) | |
232 (calendar-backward-month (1- arg))))) | |
233 | |
234 (defun calendar-end-of-month (arg) | |
235 "Move the cursor forward ARG month ends." | |
236 (interactive "p") | |
237 (calendar-cursor-to-nearest-date) | |
238 (let* ((date (calendar-cursor-to-date)) | |
239 (month (extract-calendar-month date)) | |
240 (day (extract-calendar-day date)) | |
241 (year (extract-calendar-year date)) | |
242 (last-day (calendar-last-day-of-month month year))) | |
243 (if (/= day last-day) | |
244 (progn | |
245 (calendar-cursor-to-visible-date (list month last-day year)) | |
246 (setq arg (1- arg)))) | |
247 (increment-calendar-month month year arg) | |
248 (let ((last-day (list | |
249 month | |
250 (calendar-last-day-of-month month year) | |
251 year))) | |
252 (if (not (calendar-date-is-visible-p last-day)) | |
253 (calendar-other-month month year) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
254 (calendar-cursor-to-visible-date last-day)))) |
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
255 (run-hooks 'calendar-move-hook)) |
13053 | 256 |
257 (defun calendar-beginning-of-year (arg) | |
258 "Move the cursor backward ARG year beginnings." | |
259 (interactive "p") | |
260 (calendar-cursor-to-nearest-date) | |
261 (let* ((date (calendar-cursor-to-date)) | |
262 (month (extract-calendar-month date)) | |
263 (day (extract-calendar-day date)) | |
264 (year (extract-calendar-year date)) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
265 (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
|
266 (calendar-move-hook nil)) |
13053 | 267 (if (and (= day 1) (= 1 month)) |
268 (calendar-backward-month (* 12 arg)) | |
269 (if (and (= arg 1) | |
270 (calendar-date-is-visible-p jan-first)) | |
271 (calendar-cursor-to-visible-date jan-first) | |
60981
669da3d2cff9
Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents:
52401
diff
changeset
|
272 (calendar-other-month 1 (- year (1- arg))) |
669da3d2cff9
Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents:
52401
diff
changeset
|
273 (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
|
274 (run-hooks 'calendar-move-hook)) |
13053 | 275 |
276 (defun calendar-end-of-year (arg) | |
277 "Move the cursor forward ARG year beginnings." | |
278 (interactive "p") | |
279 (calendar-cursor-to-nearest-date) | |
280 (let* ((date (calendar-cursor-to-date)) | |
281 (month (extract-calendar-month date)) | |
282 (day (extract-calendar-day date)) | |
283 (year (extract-calendar-year date)) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
284 (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
|
285 (calendar-move-hook nil)) |
13053 | 286 (if (and (= day 31) (= 12 month)) |
287 (calendar-forward-month (* 12 arg)) | |
288 (if (and (= arg 1) | |
289 (calendar-date-is-visible-p dec-31)) | |
290 (calendar-cursor-to-visible-date dec-31) | |
60981
669da3d2cff9
Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents:
52401
diff
changeset
|
291 (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
|
292 (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
|
293 (run-hooks 'calendar-move-hook)) |
13053 | 294 |
295 (defun calendar-cursor-to-visible-date (date) | |
296 "Move the cursor to DATE that is on the screen." | |
297 (let* ((month (extract-calendar-month date)) | |
298 (day (extract-calendar-day date)) | |
299 (year (extract-calendar-year date)) | |
300 (first-of-month-weekday (calendar-day-of-week (list month 1 year)))) | |
301 (goto-line (+ 3 | |
302 (/ (+ day -1 | |
303 (mod | |
304 (- (calendar-day-of-week (list month 1 year)) | |
305 calendar-week-start-day) | |
306 7)) | |
307 7))) | |
308 (move-to-column (+ 6 | |
309 (* 25 | |
310 (1+ (calendar-interval | |
311 displayed-month displayed-year month year))) | |
312 (* 3 (mod | |
313 (- (calendar-day-of-week date) | |
314 calendar-week-start-day) | |
315 7)))))) | |
316 | |
317 (defun calendar-goto-date (date) | |
318 "Move cursor to DATE." | |
319 (interactive (list (calendar-read-date))) | |
320 (let ((month (extract-calendar-month date)) | |
321 (year (extract-calendar-year date))) | |
322 (if (not (calendar-date-is-visible-p date)) | |
323 (calendar-other-month | |
324 (if (and (= month 1) (= year 1)) | |
325 2 | |
326 month) | |
327 year))) | |
25411
0d68ae69cd8c
Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents:
24337
diff
changeset
|
328 (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
|
329 (run-hooks 'calendar-move-hook)) |
13053 | 330 |
52231
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
331 (defun calendar-goto-day-of-year (year day &optional noecho) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
332 "Move cursor to YEAR, DAY number; echo DAY/YEAR unless NOECHO is t. |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
333 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
|
334 (interactive |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
335 (let* ((year (calendar-read |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
336 "Year (>0): " |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
337 (lambda (x) (> x 0)) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
338 (int-to-string (extract-calendar-year |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
339 (calendar-current-date))))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
340 (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
|
341 (day (calendar-read |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
342 (format "Day number (+/- 1-%d): " last) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
343 '(lambda (x) (and (<= 1 (abs x)) (<= (abs x) last)))))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
344 (list year day))) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
345 (calendar-goto-date |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
346 (calendar-gregorian-from-absolute |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
347 (if (< 0 day) |
9529ff0804c2
Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents:
52112
diff
changeset
|
348 (+ -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
|
349 (+ 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
|
350 (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
|
351 |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
352 ;; Backward compatibility. |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
353 (define-obsolete-function-alias |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
354 'scroll-calendar-left 'calendar-scroll-left "23.1") |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
355 (define-obsolete-function-alias |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
356 'scroll-calendar-right 'calendar-scroll-right "23.1") |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
357 (define-obsolete-function-alias |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
358 'scroll-calendar-left-three-months 'calendar-scroll-left-three-months "23.1") |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
359 (define-obsolete-function-alias |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
360 'scroll-calendar-right-three-months 'calendar-scroll-right-three-months "23.1") |
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
361 |
13053 | 362 (provide 'cal-move) |
363 | |
82148
d979cb10446a
(calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
364 ;; arch-tag: d0883c46-7e16-4914-8ff8-8f67e699b781 |
13053 | 365 ;;; cal-move.el ends here |