annotate lisp/calendar/cal-move.el @ 92796:87ea46f93e54

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