Bugfix about using the calendar on a separate frame.

`org-read-date' was loosing the focus when the calendar was displayed on
a separate frame.  This patch by Robert Goldman solves it by introducing
a new macro `org-save-frame-excursion' which preserve the frame focus.

See this thread: http://article.gmane.org/gmane.emacs.orgmode/15528

(This fixes the issue I was trying to fix in a previous commit.)
This commit is contained in:
Bastien Guerry 2009-07-22 09:42:11 +02:00
parent 4df0d4cc34
commit 898049066a
1 changed files with 84 additions and 74 deletions

View File

@ -12031,6 +12031,14 @@ So these are more for recording a certain time/date."
(defvar org-read-date-history nil)
(defvar org-read-date-final-answer nil)
(defmacro org-save-frame-excursion (&rest body)
"Eval BODY and return to the currently selected frame."
(let ((frame-var (gensym "FRAME")))
`(let ((,frame-var (selected-frame)))
(unwind-protect
(progn ,@body)
(select-frame-set-input-focus ,frame-var)))))
(defun org-read-date (&optional with-time to-time from-string prompt
default-time default-input)
"Read a date, possibly a time, and make things smooth for the user.
@ -12109,6 +12117,7 @@ user."
(org-read-date-popup-calendar
(save-excursion
(save-window-excursion
(org-save-frame-excursion
(calendar)
(calendar-forward-day (- (time-to-days def)
(calendar-absolute-from-gregorian
@ -12179,7 +12188,7 @@ user."
(use-local-map old-map)
(when org-read-date-overlay
(org-delete-overlay org-read-date-overlay)
(setq org-read-date-overlay nil)))))))
(setq org-read-date-overlay nil))))))))
(t ; Naked prompt only
(unwind-protect
@ -12199,6 +12208,7 @@ user."
(nth 5 final) (nth 4 final) (nth 3 final)
(nth 2 final) (nth 1 final))
(format "%04d-%02d-%02d" (nth 5 final) (nth 4 final) (nth 3 final))))))
(defvar def)
(defvar defdecode)
(defvar with-time)