org.el: Allow calendars to be in their own frame

* lisp/org.el (org-read-date): Create and delete frames if
`calendar-setup' is set to 'calendar-only.
This commit is contained in:
Alan Schmitt 2014-12-11 19:01:45 +01:00
parent 389274c1c4
commit 57b76e2771
1 changed files with 14 additions and 6 deletions

View File

@ -16733,9 +16733,10 @@ user."
(setcar (nthcdr 1 org-defdecode) 59) (setcar (nthcdr 1 org-defdecode) 59)
(setq org-def (apply 'encode-time org-defdecode) (setq org-def (apply 'encode-time org-defdecode)
org-defdecode (decode-time org-def))))) org-defdecode (decode-time org-def)))))
(cur-frame (selected-frame))
(mouse-autoselect-window nil) ; Don't let the mouse jump (mouse-autoselect-window nil) ; Don't let the mouse jump
(calendar-frame-setup nil) (calendar-frame-setup nil)
(calendar-setup nil) (calendar-setup (when (eq calendar-setup 'calendar-only) 'calendar-only))
(calendar-move-hook nil) (calendar-move-hook nil)
(calendar-view-diary-initially-flag nil) (calendar-view-diary-initially-flag nil)
(calendar-view-holidays-initially-flag nil) (calendar-view-holidays-initially-flag nil)
@ -16743,7 +16744,7 @@ user."
(if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") org-def)) (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") org-def))
(prompt (concat (if prompt (concat prompt " ") "") (prompt (concat (if prompt (concat prompt " ") "")
(format "Date+time [%s]: " timestr))) (format "Date+time [%s]: " timestr)))
ans (org-ans0 "") org-ans1 org-ans2 final) ans (org-ans0 "") org-ans1 org-ans2 final cal-frame)
(cond (cond
(from-string (setq ans from-string)) (from-string (setq ans from-string))
@ -16751,9 +16752,13 @@ user."
(save-excursion (save-excursion
(save-window-excursion (save-window-excursion
(calendar) (calendar)
(when (eq calendar-setup 'calendar-only)
(setq cal-frame
(window-frame (get-buffer-window "*Calendar*" 'visible)))
(select-frame cal-frame))
(org-eval-in-calendar '(setq cursor-type nil) t) (org-eval-in-calendar '(setq cursor-type nil) t)
(unwind-protect (unwind-protect
(progn (progn
(calendar-forward-day (- (time-to-days org-def) (calendar-forward-day (- (time-to-days org-def)
(calendar-absolute-from-gregorian (calendar-absolute-from-gregorian
(calendar-current-date)))) (calendar-current-date))))
@ -16780,8 +16785,11 @@ user."
(use-local-map old-map) (use-local-map old-map)
(when org-read-date-overlay (when org-read-date-overlay
(delete-overlay org-read-date-overlay) (delete-overlay org-read-date-overlay)
(setq org-read-date-overlay nil))))) (setq org-read-date-overlay nil)))))
(bury-buffer "*Calendar*"))))) (bury-buffer "*Calendar*")
(when cal-frame
(delete-frame cal-frame)
(select-frame-set-input-focus cur-frame))))))
(t ; Naked prompt only (t ; Naked prompt only
(unwind-protect (unwind-protect