emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Patch for windowing problem
@ 2009-07-16 19:32 Robert Goldman
  2009-07-16 23:26 ` Bastien
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Goldman @ 2009-07-16 19:32 UTC (permalink / raw)
  To: emacs-orgmode

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

In an earlier posting, I mentioned that I had a problem with org-mode on
aquamacs; the cursor (really input focus) was getting "trapped" in a
different frame when the *Calendar* buffer was not in the same frame as
the source of the org-schedule command (either an org-mode buffer or a
remember buffer).  The attached patch to org.el fixes this problem for
me.  Would some of you all mind testing it out?  It just wraps current
frame save and pop around the use of the calendar (frames aren't managed
by the save-excursion and save-window-excursion that already wrap this
interaction).

Thanks,
Robert

[-- Attachment #2: git-schedule-frame.patch --]
[-- Type: text/plain, Size: 8599 bytes --]

index feaa115..be07d58 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12010,6 +12010,15 @@ So these are more for recording a certain time/date."
 (defvar org-read-date-history nil)
 (defvar org-read-date-final-answer nil)
 
+(defmacro save-frame-excursion (&rest body)
+  "Carry out some operations and then 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.
@@ -12088,77 +12097,78 @@ user."
      (org-read-date-popup-calendar
       (save-excursion
 	(save-window-excursion
-	  (calendar)
-	  (calendar-forward-day (- (time-to-days def)
-				   (calendar-absolute-from-gregorian
-				    (calendar-current-date))))
-	  (org-eval-in-calendar nil t)
-	  (let* ((old-map (current-local-map))
-		 (map (copy-keymap calendar-mode-map))
-		 (minibuffer-local-map (copy-keymap minibuffer-local-map)))
-	    (org-defkey map (kbd "RET") 'org-calendar-select)
-	    (org-defkey map (if (featurep 'xemacs) [button1] [mouse-1])
-	      'org-calendar-select-mouse)
-	    (org-defkey map (if (featurep 'xemacs) [button2] [mouse-2])
-	      'org-calendar-select-mouse)
-	    (org-defkey minibuffer-local-map [(meta shift left)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-backward-month 1))))
-	    (org-defkey minibuffer-local-map [(meta shift right)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-forward-month 1))))
-	    (org-defkey minibuffer-local-map [(meta shift up)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-backward-year 1))))
-	    (org-defkey minibuffer-local-map [(meta shift down)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-forward-year 1))))
-	    (org-defkey minibuffer-local-map [?\e (shift left)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-backward-month 1))))
-	    (org-defkey minibuffer-local-map [?\e (shift right)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-forward-month 1))))
-	    (org-defkey minibuffer-local-map [?\e (shift up)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-backward-year 1))))
-	    (org-defkey minibuffer-local-map [?\e (shift down)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-forward-year 1))))
-	    (org-defkey minibuffer-local-map [(shift up)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-backward-week 1))))
-	    (org-defkey minibuffer-local-map [(shift down)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-forward-week 1))))
-	    (org-defkey minibuffer-local-map [(shift left)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-backward-day 1))))
-	    (org-defkey minibuffer-local-map [(shift right)]
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(calendar-forward-day 1))))
-	    (org-defkey minibuffer-local-map ">"
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(scroll-calendar-left 1))))
-	    (org-defkey minibuffer-local-map "<"
-	      (lambda () (interactive)
-		(org-eval-in-calendar '(scroll-calendar-right 1))))
-	    (run-hooks 'org-read-date-minibuffer-setup-hook)
-	    (unwind-protect
-		(progn
-		  (use-local-map map)
-		  (add-hook 'post-command-hook 'org-read-date-display)
-		  (setq org-ans0 (read-string prompt default-input
-					      'org-read-date-history nil))
-		  ;; org-ans0: from prompt
-		  ;; org-ans1: from mouse click
-		  ;; org-ans2: from calendar motion
-		  (setq ans (concat org-ans0 " " (or org-ans1 org-ans2))))
-	      (remove-hook 'post-command-hook 'org-read-date-display)
-	      (use-local-map old-map)
-	      (when org-read-date-overlay
-		(org-delete-overlay org-read-date-overlay)
-		(setq org-read-date-overlay nil)))))))
+          (save-frame-excursion
+           (calendar)
+           (calendar-forward-day (- (time-to-days def)
+                                    (calendar-absolute-from-gregorian
+                                     (calendar-current-date))))
+           (org-eval-in-calendar nil t)
+           (let* ((old-map (current-local-map))
+                  (map (copy-keymap calendar-mode-map))
+                  (minibuffer-local-map (copy-keymap minibuffer-local-map)))
+             (org-defkey map (kbd "RET") 'org-calendar-select)
+             (org-defkey map (if (featurep 'xemacs) [button1] [mouse-1])
+                         'org-calendar-select-mouse)
+             (org-defkey map (if (featurep 'xemacs) [button2] [mouse-2])
+                         'org-calendar-select-mouse)
+             (org-defkey minibuffer-local-map [(meta shift left)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-backward-month 1))))
+             (org-defkey minibuffer-local-map [(meta shift right)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-forward-month 1))))
+             (org-defkey minibuffer-local-map [(meta shift up)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-backward-year 1))))
+             (org-defkey minibuffer-local-map [(meta shift down)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-forward-year 1))))
+             (org-defkey minibuffer-local-map [?\e (shift left)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-backward-month 1))))
+             (org-defkey minibuffer-local-map [?\e (shift right)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-forward-month 1))))
+             (org-defkey minibuffer-local-map [?\e (shift up)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-backward-year 1))))
+             (org-defkey minibuffer-local-map [?\e (shift down)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-forward-year 1))))
+             (org-defkey minibuffer-local-map [(shift up)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-backward-week 1))))
+             (org-defkey minibuffer-local-map [(shift down)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-forward-week 1))))
+             (org-defkey minibuffer-local-map [(shift left)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-backward-day 1))))
+             (org-defkey minibuffer-local-map [(shift right)]
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(calendar-forward-day 1))))
+             (org-defkey minibuffer-local-map ">"
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(scroll-calendar-left 1))))
+             (org-defkey minibuffer-local-map "<"
+                         (lambda () (interactive)
+                                 (org-eval-in-calendar '(scroll-calendar-right 1))))
+             (run-hooks 'org-read-date-minibuffer-setup-hook)
+             (unwind-protect
+                 (progn
+                   (use-local-map map)
+                   (add-hook 'post-command-hook 'org-read-date-display)
+                   (setq org-ans0 (read-string prompt default-input
+                                               'org-read-date-history nil))
+                   ;; org-ans0: from prompt
+                   ;; org-ans1: from mouse click
+                   ;; org-ans2: from calendar motion
+                   (setq ans (concat org-ans0 " " (or org-ans1 org-ans2))))
+               (remove-hook 'post-command-hook 'org-read-date-display)
+               (use-local-map old-map)
+               (when org-read-date-overlay
+                 (org-delete-overlay org-read-date-overlay)
+                 (setq org-read-date-overlay nil))))))))
 
      (t ; Naked prompt only
       (unwind-protect

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2009-07-22 12:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-16 19:32 Patch for windowing problem Robert Goldman
2009-07-16 23:26 ` Bastien
2009-07-17  0:36   ` Robert Goldman
2009-07-17  7:54     ` Bastien
2009-07-17 12:50       ` Robert Goldman
2009-07-18  8:53         ` Bastien
2009-07-20 19:30           ` Robert Goldman
2009-07-20 20:05             ` Bastien
2009-07-20 22:20               ` Robert Goldman
2009-07-21  7:32                 ` Bastien
2009-07-22  4:25                   ` Nick Dokos
2009-07-22  7:48                     ` Bastien
2009-07-22 12:58                       ` Robert Goldman

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).