emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Robert Goldman <rpgoldman@sift.info>
To: emacs-orgmode@gnu.org
Subject: Patch for windowing problem
Date: Thu, 16 Jul 2009 14:32:48 -0500	[thread overview]
Message-ID: <4A5F8060.3060607@sift.info> (raw)

[-- 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

             reply	other threads:[~2009-07-16 19:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-16 19:32 Robert Goldman [this message]
2009-07-16 23:26 ` Patch for windowing problem 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

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A5F8060.3060607@sift.info \
    --to=rpgoldman@sift.info \
    --cc=emacs-orgmode@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/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).