From: Leo Liu <sdl.web@gmail.com>
To: 13420@debbugs.gnu.org
Subject: bug#13420: 24.2.92; [PATCH] calendar-redraw moves window-point
Date: Sat, 12 Jan 2013 16:11:12 +0800 [thread overview]
Message-ID: <m28v7ylt27.fsf@gmail.com> (raw)
[-- 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)))
next reply other threads:[~2013-01-12 8:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-12 8:11 Leo Liu [this message]
2013-01-14 0:57 ` bug#13420: 24.2.92; [PATCH] calendar-redraw moves window-point Glenn Morris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m28v7ylt27.fsf@gmail.com \
--to=sdl.web@gmail.com \
--cc=13420@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).