annotate lisp/calendar/cal-move.el @ 95063:b309a7cbf6e1

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