annotate lisp/calendar/cal-move.el @ 100530:ae1a8b13c8fc

File name fix, for AUTHORS.
author Glenn Morris <rgm@gnu.org>
date Fri, 19 Dec 2008 03:12:18 +0000
parents e8b908e44add
children a9dc0e7c3f2b
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
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94312
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
13053
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
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94312
diff changeset
15 ;; 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
16 ;; (at your option) any later version.
13053
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
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94312
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
25
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
26 ;;; Commentary:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
27
93486
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
28 ;; See calendar.el.
13053
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 ;;; Code:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
31
96159
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
32 ;; 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
33 (require 'calendar)
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
34
96296
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
35
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
36 ;; 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
37 ;; 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
38 ;;;###cal-autoload
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
39 (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
40 "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
41 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
42 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
43 (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
44 (let* ((col (current-column))
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
45 (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
46 calendar-month-edges)))
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
47 (last (nth 2 edges))
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
48 (right (nth 3 edges)))
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
49 (when (< (count-lines (point-min) (point)) calendar-first-date-row)
96159
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
50 (goto-line 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
51 (move-to-column col))
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
52 ;; 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
53 ;; 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
54 ;; 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
55 ;; '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
56 (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
57 (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
58 ;; 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
59 ;; 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
60 ;; 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
61 (if (or (looking-at " *$")
e8b908e44add (calendar-cursor-to-nearest-date): Use calendar-column-to-segment,
Glenn Morris <rgm@gnu.org>
parents: 96159
diff changeset
62 (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
63 (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
64 (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
65 (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
66 (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
67 (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
68 (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
69
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
70 (defvar displayed-month) ; from calendar-generate
52112
e7d0572ccca5 (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 31670
diff changeset
71 (defvar displayed-year)
e7d0572ccca5 (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 31670
diff changeset
72
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
73 ;;;###cal-autoload
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
74 (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
75 "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
76 (let ((month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
77 (day (calendar-extract-day date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
78 (year (calendar-extract-year date)))
96159
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
79 (goto-line (+ calendar-first-date-row
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
80 (/ (+ day -1
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
81 (mod
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
82 (- (calendar-day-of-week (list month 1 year))
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
83 calendar-week-start-day)
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
84 7))
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
85 7)))
96159
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
86 (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
87 (* 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
88 (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
89 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
90 (* calendar-column-width
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
91 (mod
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
92 (- (calendar-day-of-week date)
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
93 calendar-week-start-day)
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
94 7))))))
19892
b3d4cde6e4c3 Require calendar.el.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
95
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
96 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
97 (defun calendar-goto-today ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
98 "Reposition the calendar window so the current date is visible."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
99 (interactive)
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
100 (let ((today (calendar-current-date))) ; the date might have changed
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
101 (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
102 (calendar-generate-window)
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
103 (calendar-update-mode-line)
25411
0d68ae69cd8c Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents: 24337
diff changeset
104 (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
105 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
106
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
107 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
108 (defun calendar-forward-month (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
109 "Move the cursor forward ARG months.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
110 Movement is backward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
111 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
112 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
113 (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
114 (month (calendar-extract-month cursor-date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
115 (day (calendar-extract-day cursor-date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
116 (year (calendar-extract-year cursor-date))
93486
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
117 (last (progn
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
118 (calendar-increment-month month year arg)
93486
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
119 (calendar-last-day-of-month month year)))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
120 (day (min last day))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
121 ;; 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
122 (new-cursor-date (list month day year)))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
123 (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
124 (calendar-other-month month year))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
125 (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
126 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
127
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
128 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
129 (defun calendar-forward-year (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
130 "Move the cursor forward by ARG years.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
131 Movement is backward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
132 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
133 (calendar-forward-month (* 12 arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
134
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
135 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
136 (defun calendar-backward-month (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
137 "Move the cursor backward by ARG months.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
138 Movement is forward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
139 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
140 (calendar-forward-month (- arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
141
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
142 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
143 (defun calendar-backward-year (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
144 "Move the cursor backward ARG years.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
145 Movement is forward is ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
146 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
147 (calendar-forward-month (* -12 arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
148
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
149 ;;;###cal-autoload
82150
0d322d300115 (calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82148
diff changeset
150 (defun calendar-scroll-left (&optional arg event)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
151 "Scroll the displayed calendar left by ARG months.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
152 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
153 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
154 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
155 (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
156 last-nonmenu-event))
31670
4560c1d5e629 (scroll-calendar-left)
Dave Love <fx@gnu.org>
parents: 25411
diff changeset
157 (unless arg (setq arg 1))
82150
0d322d300115 (calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82148
diff changeset
158 (save-selected-window
94312
eaaf578ce48f (calendar-scroll-left): Handle case when event-start is nil.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
159 ;; 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
160 (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
161 (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
162 (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
163 (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
164 (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
165 (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
166 (year displayed-year))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
167 (calendar-increment-month month year arg)
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
168 (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
169 (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
170 (cond
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
171 ((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
172 ((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
173 (t (list month 1 year))))))
82150
0d322d300115 (calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82148
diff changeset
174 (run-hooks 'calendar-move-hook)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
175
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
176 (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
177 '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
178
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
179 ;;;###cal-autoload
82150
0d322d300115 (calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82148
diff changeset
180 (defun calendar-scroll-right (&optional arg event)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
181 "Scroll the displayed calendar window right by ARG months.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
182 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
183 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
184 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
185 (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
186 last-nonmenu-event))
0d322d300115 (calendar-scroll-left, calendar-scroll-right):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 82148
diff changeset
187 (calendar-scroll-left (- (or arg 1)) event))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
188
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
189 (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
190 '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
191
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
192 ;;;###cal-autoload
82148
d979cb10446a (calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
193 (defun calendar-scroll-left-three-months (arg)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
194 "Scroll the displayed calendar window left by 3*ARG months.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
195 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
196 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
197 (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
198 (calendar-scroll-left (* 3 arg)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
199
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
200 (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
201 '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
202
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
203 ;;;###cal-autoload
82148
d979cb10446a (calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
204 (defun calendar-scroll-right-three-months (arg)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
205 "Scroll the displayed calendar window right by 3*ARG months.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
206 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
207 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
208 (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
209 (calendar-scroll-left (* -3 arg)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
210
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
211 (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
212 'calendar-scroll-right-three-months "23.1")
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
213
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
214 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
215 (defun calendar-forward-day (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
216 "Move the cursor forward ARG days.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
217 Moves backward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
218 (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
219 (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
220 (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
221 (progn
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
222 (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
223 (calendar-cursor-to-nearest-date))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
224 (new-cursor-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
225 (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
226 (+ (calendar-absolute-from-gregorian cursor-date) arg)))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
227 (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
228 (new-display-year (calendar-extract-year new-cursor-date)))
92916
f296fd96bd7c (calendar-cursor-to-nearest-date): Use or, when. Move definition before use.
Glenn Morris <rgm@gnu.org>
parents: 92855
diff changeset
229 ;; Put the new month on the screen, if needed, and go to the new date.
96159
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
230 (if (calendar-date-is-visible-p new-cursor-date)
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
231 (calendar-cursor-to-visible-date new-cursor-date)
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
232 ;; 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
233 ;; time rather than two).
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
234 (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
235 (if (< arg 0) 1 -1))
cb4a9a7913cd (calendar-forward-day): Scroll in one month increments.
Glenn Morris <rgm@gnu.org>
parents: 94653
diff changeset
236 (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
237 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
238
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
239 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
240 (defun calendar-backward-day (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
241 "Move the cursor back ARG days.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
242 Moves forward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
243 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
244 (calendar-forward-day (- arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
245
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
246 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
247 (defun calendar-forward-week (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
248 "Move the cursor forward ARG weeks.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
249 Moves backward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
250 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
251 (calendar-forward-day (* arg 7)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
252
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
253 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
254 (defun calendar-backward-week (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
255 "Move the cursor back ARG weeks.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
256 Moves forward if ARG is negative."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
257 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
258 (calendar-forward-day (* arg -7)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
259
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
260 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
261 (defun calendar-beginning-of-week (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
262 "Move the cursor back ARG calendar-week-start-day's."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
263 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
264 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
265 (let ((day (calendar-day-of-week (calendar-cursor-to-date))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
266 (calendar-backward-day
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
267 (if (= day calendar-week-start-day)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
268 (* 7 arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
269 (+ (mod (- day calendar-week-start-day) 7)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
270 (* 7 (1- arg)))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
271
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
272 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
273 (defun calendar-end-of-week (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
274 "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
275 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
276 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
277 (let ((day (calendar-day-of-week (calendar-cursor-to-date))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
278 (calendar-forward-day
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
279 (if (= day (mod (1- calendar-week-start-day) 7))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
280 (* 7 arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
281 (+ (- 6 (mod (- day calendar-week-start-day) 7))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
282 (* 7 (1- arg)))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
283
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
284 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
285 (defun calendar-beginning-of-month (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
286 "Move the cursor backward ARG month beginnings."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
287 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
288 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
289 (let* ((date (calendar-cursor-to-date))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
290 (month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
291 (day (calendar-extract-day date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
292 (year (calendar-extract-year date)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
293 (if (= day 1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
294 (calendar-backward-month arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
295 (calendar-cursor-to-visible-date (list month 1 year))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
296 (calendar-backward-month (1- arg)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
297
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
298 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
299 (defun calendar-end-of-month (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
300 "Move the cursor forward ARG month ends."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
301 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
302 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
303 (let* ((date (calendar-cursor-to-date))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
304 (month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
305 (day (calendar-extract-day date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
306 (year (calendar-extract-year date))
93486
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
307 (last-day (calendar-last-day-of-month month year))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
308 (last-day (progn
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
309 (unless (= day last-day)
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
310 (calendar-cursor-to-visible-date
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
311 (list month last-day year))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
312 (setq arg (1- arg)))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
313 (calendar-increment-month month year arg)
93486
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
314 (list month
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
315 (calendar-last-day-of-month month year)
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
316 year))))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
317 (if (not (calendar-date-is-visible-p last-day))
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
318 (calendar-other-month month year)
b9615f927009 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93329
diff changeset
319 (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
320 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
321
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
322 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
323 (defun calendar-beginning-of-year (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
324 "Move the cursor backward ARG year beginnings."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
325 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
326 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
327 (let* ((date (calendar-cursor-to-date))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
328 (month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
329 (day (calendar-extract-day date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
330 (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
331 (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
332 (calendar-move-hook nil))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
333 (if (and (= day 1) (= 1 month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
334 (calendar-backward-month (* 12 arg))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
335 (if (and (= arg 1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
336 (calendar-date-is-visible-p jan-first))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
337 (calendar-cursor-to-visible-date jan-first)
60981
669da3d2cff9 Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
338 (calendar-other-month 1 (- year (1- arg)))
669da3d2cff9 Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
339 (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
340 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
341
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
342 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
343 (defun calendar-end-of-year (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
344 "Move the cursor forward ARG year beginnings."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
345 (interactive "p")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
346 (calendar-cursor-to-nearest-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
347 (let* ((date (calendar-cursor-to-date))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
348 (month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
349 (day (calendar-extract-day date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
350 (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
351 (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
352 (calendar-move-hook nil))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
353 (if (and (= day 31) (= 12 month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
354 (calendar-forward-month (* 12 arg))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
355 (if (and (= arg 1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
356 (calendar-date-is-visible-p dec-31))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
357 (calendar-cursor-to-visible-date dec-31)
60981
669da3d2cff9 Update copyright and maintainer.
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
358 (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
359 (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
360 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
361
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
362 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
363 (defun calendar-goto-date (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
364 "Move cursor to DATE."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
365 (interactive (list (calendar-read-date)))
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
366 (let ((month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93486
diff changeset
367 (year (calendar-extract-year date)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
368 (if (not (calendar-date-is-visible-p date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
369 (calendar-other-month
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
370 (if (and (= month 1) (= year 1))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
371 2
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
372 month)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
373 year)))
25411
0d68ae69cd8c Call the new hook in every movement function.
Richard M. Stallman <rms@gnu.org>
parents: 24337
diff changeset
374 (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
375 (run-hooks 'calendar-move-hook))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
376
92836
e4347538b00b (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92634
diff changeset
377 ;;;###cal-autoload
52231
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
378 (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
379 "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
380 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
381 (interactive
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
382 (let* ((year (calendar-read
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
383 "Year (>0): "
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
384 (lambda (x) (> x 0))
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
385 (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
386 (calendar-current-date)))))
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
387 (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
388 (day (calendar-read
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
389 (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
390 (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
391 (list year day)))
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
392 (calendar-goto-date
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
393 (calendar-gregorian-from-absolute
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
394 (if (< 0 day)
9529ff0804c2 Edward M. Reingold <reingold@emr.cs.iit.edu>
Glenn Morris <rgm@gnu.org>
parents: 52112
diff changeset
395 (+ -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
396 (+ 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
397 (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
398
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
399 (provide 'cal-move)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
400
82148
d979cb10446a (calendar-scroll-left, calendar-scroll-right, calendar-scroll-left-three-months)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
401 ;; arch-tag: d0883c46-7e16-4914-8ff8-8f67e699b781
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
402 ;;; cal-move.el ends here