emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nathaniel Flath <flat0103@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Close calendar buffer after scheduling an item
Date: Fri, 5 Feb 2010 22:24:23 -0500	[thread overview]
Message-ID: <5e3a506e1002051924jce1863fgbf70ee64e05df0ff@mail.gmail.com> (raw)


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

If you schedule an item with org-schedule, the *Calendar* buffer will stay
around.  This also occurs with org-deadline, and any other functions that
use org-read-date.  The patch attached just closes this buffer once the date
is read.

I've filled out the FSF forms already, so copyright shouldn't be a problem.

Thanks,
Nathaniel Flath

[-- Attachment #1.2: Type: text/html, Size: 367 bytes --]

[-- Attachment #2: org-calendar.patch --]
[-- Type: text/x-patch, Size: 12256 bytes --]

diff --git a/lisp/org/org.el b/lisp/org/org.el
index 325a524..8206cf2 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -12970,125 +12970,127 @@ the user.  PROMPT can overwrite the default prompt.  DEFAULT-TIME is
 the time/date that is used for everything that is not specified by the
 user."
   (require 'parse-time)
-  (let* ((org-time-stamp-rounding-minutes
-	  (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
-	 (org-dcst org-display-custom-times)
-	 (ct (org-current-time))
-	 (def (or org-overriding-default-time default-time ct))
-	 (defdecode (decode-time def))
-	 (dummy (progn
-		  (when (< (nth 2 defdecode) org-extend-today-until)
-		    (setcar (nthcdr 2 defdecode) -1)
-		    (setcar (nthcdr 1 defdecode) 59)
-		    (setq def (apply 'encode-time defdecode)
-			  defdecode (decode-time def)))))
-	 (calendar-frame-setup nil)
-	 (calendar-move-hook nil)
-	 (calendar-view-diary-initially-flag nil)
-	 (view-diary-entries-initially nil)
-	 (calendar-view-holidays-initially-flag nil)
-	 (view-calendar-holidays-initially nil)
-	 (timestr (format-time-string
-		   (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def))
-	 (prompt (concat (if prompt (concat prompt " ") "")
-			 (format "Date+time [%s]: " timestr)))
-	 ans (org-ans0 "") org-ans1 org-ans2 final)
-
-    (cond
-     (from-string (setq ans from-string))
-     (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)))))))
-
-     (t ; Naked prompt only
-      (unwind-protect
-	  (setq ans (read-string prompt default-input
-				 'org-read-date-history timestr))
-	(when org-read-date-overlay
-	  (org-delete-overlay org-read-date-overlay)
-	  (setq org-read-date-overlay nil)))))
-
-    (setq final (org-read-date-analyze ans def defdecode))
-    (setq org-read-date-final-answer ans)
-
-    (if to-time
-	(apply 'encode-time final)
-      (if (and (boundp 'org-time-was-given) org-time-was-given)
-	  (format "%04d-%02d-%02d %02d:%02d"
-		  (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))))))
+  (prog1
+      (let* ((org-time-stamp-rounding-minutes
+              (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
+             (org-dcst org-display-custom-times)
+             (ct (org-current-time))
+             (def (or org-overriding-default-time default-time ct))
+             (defdecode (decode-time def))
+             (dummy (progn
+                      (when (< (nth 2 defdecode) org-extend-today-until)
+                        (setcar (nthcdr 2 defdecode) -1)
+                        (setcar (nthcdr 1 defdecode) 59)
+                        (setq def (apply 'encode-time defdecode)
+                              defdecode (decode-time def)))))
+             (calendar-frame-setup nil)
+             (calendar-move-hook nil)
+             (calendar-view-diary-initially-flag nil)
+             (view-diary-entries-initially nil)
+             (calendar-view-holidays-initially-flag nil)
+             (view-calendar-holidays-initially nil)
+             (timestr (format-time-string
+                       (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def))
+             (prompt (concat (if prompt (concat prompt " ") "")
+                             (format "Date+time [%s]: " timestr)))
+             ans (org-ans0 "") org-ans1 org-ans2 final)
+
+        (cond
+         (from-string (setq ans from-string))
+         (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)))))))
+
+         (t ; Naked prompt only
+          (unwind-protect
+              (setq ans (read-string prompt default-input
+                                     'org-read-date-history timestr))
+            (when org-read-date-overlay
+              (org-delete-overlay org-read-date-overlay)
+              (setq org-read-date-overlay nil)))))
+
+        (setq final (org-read-date-analyze ans def defdecode))
+        (setq org-read-date-final-answer ans)
+
+        (if to-time
+            (apply 'encode-time final)
+          (if (and (boundp 'org-time-was-given) org-time-was-given)
+              (format "%04d-%02d-%02d %02d:%02d"
+                      (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)))))
+    (kill-buffer "*Calendar*")))
 
 (defvar def)
 (defvar defdecode)

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

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

             reply	other threads:[~2010-02-06  3:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06  3:24 Nathaniel Flath [this message]
2010-02-06  4:11 ` [PATCH] Close calendar buffer after scheduling an item Matt Lundin
2010-02-06  6:21   ` Carsten Dominik

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=5e3a506e1002051924jce1863fgbf70ee64e05df0ff@mail.gmail.com \
    --to=flat0103@gmail.com \
    --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).