emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-read-date with pop-up-frames set to t
@ 2014-11-30 15:47 Alan Schmitt
  2014-12-03 13:37 ` Alan Schmitt
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2014-11-30 15:47 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]

Hello,

I'm experimenting with using frames instead of windows, and I'm seeing
some strange behavior with `org-read-date'. Here is an ECM starting from
an emacs -Q (with an emacs 24.4 and the bundled org):

#+begin_src emacs-lisp
(setq pop-up-frames t)
(setq frame-auto-hide-function 'delete-frame)

(require 'org)
(org-read-date)
#+end_src

When evaluating the `org-read-date' function, a new frame opens (great)
with two windows, the bottom one being the calendar window.

Question 1: is it possible just to have the calendar window in the new
frame?

When I select a date, I see the selected date echoed in the minibuffer
(the function has returned a value), but the frame and the two windows
stay there, and I have to manually delete the frame to get back where
I was.

Question 2: is there a way to delete this frame when I'm done selecting
the date?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-read-date with pop-up-frames set to t
  2014-11-30 15:47 org-read-date with pop-up-frames set to t Alan Schmitt
@ 2014-12-03 13:37 ` Alan Schmitt
  2014-12-11 18:13   ` Alan Schmitt
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2014-12-03 13:37 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1607 bytes --]

On 2014-11-30 16:47, Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Hello,
>
> I'm experimenting with using frames instead of windows, and I'm seeing
> some strange behavior with `org-read-date'. Here is an ECM starting from
> an emacs -Q (with an emacs 24.4 and the bundled org):
>
> #+begin_src emacs-lisp
> (setq pop-up-frames t)
> (setq frame-auto-hide-function 'delete-frame)
>
> (require 'org)
> (org-read-date)
> #+end_src
>
> When evaluating the `org-read-date' function, a new frame opens (great)
> with two windows, the bottom one being the calendar window.
>
> Question 1: is it possible just to have the calendar window in the new
> frame?
>
> When I select a date, I see the selected date echoed in the minibuffer
> (the function has returned a value), but the frame and the two windows
> stay there, and I have to manually delete the frame to get back where
> I was.
>
> Question 2: is there a way to delete this frame when I'm done selecting
> the date?

As a follow-up, I discussed this with a friend who understand emacs-lisp
much better than I do. Here is what he said about `org-read-date':

> It uses (save-excursion (save-window-excursion...)), but that
> does not save the selected frame (save which frame was selected).
> Also, it does not remove frame *Calendar* because it uses only
> (bury-buffer "*Calendar*").  It should perhaps use something
> like `frame-auto-hide-function' as well.

I can start looking into this. Would a patch around these issues be
considered?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-read-date with pop-up-frames set to t
  2014-12-03 13:37 ` Alan Schmitt
@ 2014-12-11 18:13   ` Alan Schmitt
  2014-12-12 22:47     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2014-12-11 18:13 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 314 bytes --]

Hello,

Here is a patch that honors the setting for `calendar-setup' when it's
'calendar-only: is now correctly creates a new frame for the calendar,
and removes is and restores the focus when the date is selected. As a
side effect, is also fixes the bug I reported in this thread.

I have signed the FSF papers.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org.el-Allow-calendars-to-be-in-their-own-frame.patch --]
[-- Type: text/x-patch, Size: 2491 bytes --]

From 40c1905f77d706c52cc964449c88c16b64b5a449 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
Date: Thu, 11 Dec 2014 19:01:45 +0100
Subject: [PATCH] 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.
---
 lisp/org.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index bed5cb9..144d038 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16728,9 +16728,10 @@ user."
 		    (setcar (nthcdr 1 org-defdecode) 59)
 		    (setq org-def (apply 'encode-time org-defdecode)
 			  org-defdecode (decode-time org-def)))))
+         (cur-frame (selected-frame))
 	 (mouse-autoselect-window nil) ; Don't let the mouse jump
 	 (calendar-frame-setup nil)
-	 (calendar-setup nil)
+	 (calendar-setup (when (eq calendar-setup 'calendar-only) 'calendar-only))
 	 (calendar-move-hook nil)
 	 (calendar-view-diary-initially-flag nil)
 	 (calendar-view-holidays-initially-flag nil)
@@ -16738,7 +16739,7 @@ user."
 		   (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") org-def))
 	 (prompt (concat (if prompt (concat prompt " ") "")
 			 (format "Date+time [%s]: " timestr)))
-	 ans (org-ans0 "") org-ans1 org-ans2 final)
+	 ans (org-ans0 "") org-ans1 org-ans2 final cal-frame)
 
     (cond
      (from-string (setq ans from-string))
@@ -16746,9 +16747,13 @@ user."
       (save-excursion
 	(save-window-excursion
 	  (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)
-          (unwind-protect
-              (progn
+	  (unwind-protect
+	      (progn
 		(calendar-forward-day (- (time-to-days org-def)
 					 (calendar-absolute-from-gregorian
 					  (calendar-current-date))))
@@ -16775,8 +16780,11 @@ user."
 		    (use-local-map old-map)
 		    (when org-read-date-overlay
 		      (delete-overlay org-read-date-overlay)
-                      (setq org-read-date-overlay nil)))))
-	    (bury-buffer "*Calendar*")))))
+		      (setq org-read-date-overlay nil)))))
+	    (bury-buffer "*Calendar*")
+	    (when cal-frame
+	      (delete-frame cal-frame)
+	      (select-frame-set-input-focus cur-frame))))))
 
      (t ; Naked prompt only
       (unwind-protect
-- 
2.2.0


[-- Attachment #1.3: Type: text/plain, Size: 59 bytes --]


Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: org-read-date with pop-up-frames set to t
  2014-12-11 18:13   ` Alan Schmitt
@ 2014-12-12 22:47     ` Nicolas Goaziou
  2014-12-17  7:49       ` Alan Schmitt
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2014-12-12 22:47 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Here is a patch that honors the setting for `calendar-setup' when it's
> 'calendar-only: is now correctly creates a new frame for the calendar,
> and removes is and restores the focus when the date is selected. As a
> side effect, is also fixes the bug I reported in this thread.

Thank you. It looks good. Please push.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: org-read-date with pop-up-frames set to t
  2014-12-12 22:47     ` Nicolas Goaziou
@ 2014-12-17  7:49       ` Alan Schmitt
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Schmitt @ 2014-12-17  7:49 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

On 2014-12-12 23:47, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Here is a patch that honors the setting for `calendar-setup' when it's
>> 'calendar-only: is now correctly creates a new frame for the calendar,
>> and removes is and restores the focus when the date is selected. As a
>> side effect, is also fixes the bug I reported in this thread.
>
> Thank you. It looks good. Please push.

Pushed.

Best,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-17  7:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-30 15:47 org-read-date with pop-up-frames set to t Alan Schmitt
2014-12-03 13:37 ` Alan Schmitt
2014-12-11 18:13   ` Alan Schmitt
2014-12-12 22:47     ` Nicolas Goaziou
2014-12-17  7:49       ` Alan Schmitt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).