* bug#13420: 24.2.92; [PATCH] calendar-redraw moves window-point
@ 2013-01-12 8:11 Leo Liu
2013-01-14 0:57 ` Glenn Morris
0 siblings, 1 reply; 2+ messages in thread
From: Leo Liu @ 2013-01-12 8:11 UTC (permalink / raw)
To: 13420
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
Due to a bug/trap as reported in http://debbugs.gnu.org/13361, here is
one bug in calendar that moves window-point to (point-min).
1. Emacs -q
2. M-x calendar
3. C-x o so that the *calendar* window is not selected
4. M-x calendar-redraw
When you C-x o back to the calendar window, your window-point is no
longer at today's date but (point-min).
Note also calendar-redraw is called when saving in the diary file where
it has a save-hook: diary-redraw-calendar; so it is not uncommon for
this annoyance to happen.
[-- Attachment #2: emacs-cal-bug.png --]
[-- Type: image/png, Size: 90321 bytes --]
[-- Attachment #3: Type: text/plain, Size: 1382 bytes --]
For example, I often move to a future date and `i d' to insert a
reminder in the diary file and then C-x C-s. When I switch back to
calendar for further work, point is at the inconvenient point-min.
The proposed fix is in the patch attached.
I'd bet there are more occurrences in emacs source that fall into this
trap.
Leo
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 9b0eb3e9..74d3ce80 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1562,11 +1562,13 @@ (defun calendar-generate-month (month year indent)
(defun calendar-redraw ()
"Redraw the calendar display, if `calendar-buffer' is live."
(interactive)
- (if (get-buffer calendar-buffer)
- (with-current-buffer calendar-buffer
- (let ((cursor-date (calendar-cursor-to-nearest-date)))
- (calendar-generate-window displayed-month displayed-year)
- (calendar-cursor-to-visible-date cursor-date)))))
+ (when (get-buffer calendar-buffer)
+ (with-current-buffer calendar-buffer
+ (let ((cursor-date (calendar-cursor-to-nearest-date)))
+ (calendar-generate-window displayed-month displayed-year)
+ (calendar-cursor-to-visible-date cursor-date))
+ (when (window-live-p (get-buffer-window))
+ (set-window-point (get-buffer-window) (point))))))
(defvar calendar-mode-map
(let ((map (make-keymap)))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#13420: 24.2.92; [PATCH] calendar-redraw moves window-point
2013-01-12 8:11 bug#13420: 24.2.92; [PATCH] calendar-redraw moves window-point Leo Liu
@ 2013-01-14 0:57 ` Glenn Morris
0 siblings, 0 replies; 2+ messages in thread
From: Glenn Morris @ 2013-01-14 0:57 UTC (permalink / raw)
To: Leo Liu; +Cc: 13420
Please apply to trunk, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-14 0:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-12 8:11 bug#13420: 24.2.92; [PATCH] calendar-redraw moves window-point Leo Liu
2013-01-14 0:57 ` Glenn Morris
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).