aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2007-07-27 06:23:45 +0000
committerStefan Monnier2007-07-27 06:23:45 +0000
commitab8950895b46b8435c88c8767faa878af111cb6c (patch)
treec2bda38781290a11819efb015d99a325001d179d
parentcca1dde04dfc3298c71b6446e5884a6e786120f2 (diff)
downloademacs-ab8950895b46b8435c88c8767faa878af111cb6c.tar.gz
emacs-ab8950895b46b8435c88c8767faa878af111cb6c.zip
(calendar-scroll-left, calendar-scroll-right):
Behave like mouse-scroll-calendar-* when used from the mouse.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/calendar/cal-move.el44
2 files changed, 27 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 56c3294ea1c..2a81d3da737 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12007-07-27 Stefan Monnier <monnier@iro.umontreal.ca> 12007-07-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * calendar/cal-move.el (calendar-scroll-left, calendar-scroll-right):
4 Behave like mouse-scroll-calendar-* when used from the mouse.
5
3 * calendar/cal-menu.el (cal-menu-scroll-menu) 6 * calendar/cal-menu.el (cal-menu-scroll-menu)
4 (cal-menu-global-mouse-menu): Use new names. 7 (cal-menu-global-mouse-menu): Use new names.
5 8
diff --git a/lisp/calendar/cal-move.el b/lisp/calendar/cal-move.el
index 87f577ccb28..81f75114a3f 100644
--- a/lisp/calendar/cal-move.el
+++ b/lisp/calendar/cal-move.el
@@ -85,33 +85,37 @@ Movement is forward is ARG is negative."
85 (interactive "p") 85 (interactive "p")
86 (calendar-forward-month (* -12 arg))) 86 (calendar-forward-month (* -12 arg)))
87 87
88(defun calendar-scroll-left (&optional arg) 88(defun calendar-scroll-left (&optional arg event)
89 "Scroll the displayed calendar left by ARG months. 89 "Scroll the displayed calendar left by ARG months.
90If ARG is negative the calendar is scrolled right. Maintains the relative 90If ARG is negative the calendar is scrolled right. Maintains the relative
91position of the cursor with respect to the calendar as well as possible." 91position of the cursor with respect to the calendar as well as possible."
92 (interactive "p") 92 (interactive (list (prefix-numeric-value current-prefix-arg)
93 last-nonmenu-event))
93 (unless arg (setq arg 1)) 94 (unless arg (setq arg 1))
94 (calendar-cursor-to-nearest-date) 95 (save-selected-window
95 (let ((old-date (calendar-cursor-to-date)) 96 (select-window (posn-window (event-start event)))
96 (today (calendar-current-date))) 97 (calendar-cursor-to-nearest-date)
97 (if (/= arg 0) 98 (let ((old-date (calendar-cursor-to-date))
98 (let ((month displayed-month) 99 (today (calendar-current-date)))
99 (year displayed-year)) 100 (if (/= arg 0)
100 (increment-calendar-month month year arg) 101 (let ((month displayed-month)
101 (generate-calendar-window month year) 102 (year displayed-year))
102 (calendar-cursor-to-visible-date 103 (increment-calendar-month month year arg)
103 (cond 104 (generate-calendar-window month year)
104 ((calendar-date-is-visible-p old-date) old-date) 105 (calendar-cursor-to-visible-date
105 ((calendar-date-is-visible-p today) today) 106 (cond
106 (t (list month 1 year))))))) 107 ((calendar-date-is-visible-p old-date) old-date)
107 (run-hooks 'calendar-move-hook)) 108 ((calendar-date-is-visible-p today) today)
108 109 (t (list month 1 year)))))))
109(defun calendar-scroll-right (&optional arg) 110 (run-hooks 'calendar-move-hook)))
111
112(defun calendar-scroll-right (&optional arg event)
110 "Scroll the displayed calendar window right by ARG months. 113 "Scroll the displayed calendar window right by ARG months.
111If ARG is negative the calendar is scrolled left. Maintains the relative 114If ARG is negative the calendar is scrolled left. Maintains the relative
112position of the cursor with respect to the calendar as well as possible." 115position of the cursor with respect to the calendar as well as possible."
113 (interactive "p") 116 (interactive (list (prefix-numeric-value current-prefix-arg)
114 (calendar-scroll-left (- (or arg 1)))) 117 last-nonmenu-event))
118 (calendar-scroll-left (- (or arg 1)) event))
115 119
116(defun calendar-scroll-left-three-months (arg) 120(defun calendar-scroll-left-three-months (arg)
117 "Scroll the displayed calendar window left by 3*ARG months. 121 "Scroll the displayed calendar window left by 3*ARG months.