emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Bury calendar buffer after "C-c ."?
@ 2011-03-29 23:12 Ben North
  2011-04-01 17:10 ` Anthony Lander
  2011-05-16  6:38 ` Carsten Dominik
  0 siblings, 2 replies; 3+ messages in thread
From: Ben North @ 2011-03-29 23:12 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi,

I've been using org-mode for a little while now, and finding it very
useful --- thanks!

Would you consider a patch along the lines of the attached, to bury the
calendar buffer once you've chosen a date via "C-c ."?  I often want to
do switch-to-other-buffer to check something in the most recently used
buffer, and find myself looking at the calendar instead.

Regards,

Ben.

(The '-diff-wU10' one ignores whitespace changes, so you can see what
I've done; the '-diff-U10' one includes all whitespace changes, for
better applying.)

[-- Attachment #2: org.el.patch-diff-wU10 --]
[-- Type: application/octet-stream, Size: 1883 bytes --]

--- ORIG--org.el	2011-03-30 00:02:17.304180280 +0100
+++ NEW--org.el	2011-03-30 00:04:31.191679300 +0100
@@ -14442,20 +14442,22 @@
 	 (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)
+          (unwind-protect
+              (progn
 	  (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 [mouse-1] 'org-calendar-select-mouse)
 	    (org-defkey map [mouse-2] 'org-calendar-select-mouse)
@@ -14517,21 +14519,22 @@
 		  (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
 		(delete-overlay org-read-date-overlay)
-		(setq org-read-date-overlay nil)))))))
+                      (setq org-read-date-overlay nil)))))
+            (bury-buffer "*Calendar*")))))
 
      (t ; Naked prompt only
       (unwind-protect
 	  (setq ans (read-string prompt default-input
 				 'org-read-date-history timestr))
 	(when org-read-date-overlay
 	  (delete-overlay org-read-date-overlay)
 	  (setq org-read-date-overlay nil)))))
 
     (setq final (org-read-date-analyze ans def defdecode))

[-- Attachment #3: org.el.patch-diff-U10 --]
[-- Type: application/octet-stream, Size: 9305 bytes --]

--- ORIG--org.el	2011-03-30 00:02:17.304180280 +0100
+++ NEW--org.el	2011-03-30 00:04:31.191679300 +0100
@@ -14442,96 +14442,99 @@
 	 (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 [mouse-1] 'org-calendar-select-mouse)
-	    (org-defkey map [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))))
-	    (org-defkey minibuffer-local-map "\C-v"
-			(lambda () (interactive)
-			  (org-eval-in-calendar
-			   '(calendar-scroll-left-three-months 1))))
-	    (org-defkey minibuffer-local-map "\M-v"
-			(lambda () (interactive)
-			  (org-eval-in-calendar
-			   '(calendar-scroll-right-three-months 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
-		(delete-overlay org-read-date-overlay)
-		(setq org-read-date-overlay nil)))))))
+          (unwind-protect
+              (progn
+                (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 [mouse-1] 'org-calendar-select-mouse)
+                  (org-defkey map [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))))
+                  (org-defkey minibuffer-local-map "\C-v"
+                              (lambda () (interactive)
+                                (org-eval-in-calendar
+                                 '(calendar-scroll-left-three-months 1))))
+                  (org-defkey minibuffer-local-map "\M-v"
+                              (lambda () (interactive)
+                                (org-eval-in-calendar
+                                 '(calendar-scroll-right-three-months 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
+                      (delete-overlay org-read-date-overlay)
+                      (setq org-read-date-overlay nil)))))
+            (bury-buffer "*Calendar*")))))
 
      (t ; Naked prompt only
       (unwind-protect
 	  (setq ans (read-string prompt default-input
 				 'org-read-date-history timestr))
 	(when org-read-date-overlay
 	  (delete-overlay org-read-date-overlay)
 	  (setq org-read-date-overlay nil)))))
 
     (setq final (org-read-date-analyze ans def defdecode))

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

* Re: [PATCH] Bury calendar buffer after "C-c ."?
  2011-03-29 23:12 [PATCH] Bury calendar buffer after "C-c ."? Ben North
@ 2011-04-01 17:10 ` Anthony Lander
  2011-05-16  6:38 ` Carsten Dominik
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Lander @ 2011-04-01 17:10 UTC (permalink / raw)
  To: Ben North


On 11-Mar-29, at 7:12 PM, Ben North wrote:

> Hi,
>
> I've been using org-mode for a little while now, and finding it very
> useful --- thanks!
>
> Would you consider a patch along the lines of the attached, to bury  
> the
> calendar buffer once you've chosen a date via "C-c ."?  I often want  
> to
> do switch-to-other-buffer to check something in the most recently used
> buffer, and find myself looking at the calendar instead.


Personally, I think this is a great idea as well.

  -Anthony

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

* Re: [PATCH] Bury calendar buffer after "C-c ."?
  2011-03-29 23:12 [PATCH] Bury calendar buffer after "C-c ."? Ben North
  2011-04-01 17:10 ` Anthony Lander
@ 2011-05-16  6:38 ` Carsten Dominik
  1 sibling, 0 replies; 3+ messages in thread
From: Carsten Dominik @ 2011-05-16  6:38 UTC (permalink / raw)
  To: Ben North; +Cc: emacs-orgmode


On Mar 30, 2011, at 1:12 AM, Ben North wrote:

> Hi,
> 
> I've been using org-mode for a little while now, and finding it very
> useful --- thanks!
> 
> Would you consider a patch along the lines of the attached, to bury the
> calendar buffer once you've chosen a date via "C-c ."?  I often want to
> do switch-to-other-buffer to check something in the most recently used
> buffer, and find myself looking at the calendar instead.

This patch has been accepted, thanks.

- Carsten

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

end of thread, other threads:[~2011-05-16  6:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-29 23:12 [PATCH] Bury calendar buffer after "C-c ."? Ben North
2011-04-01 17:10 ` Anthony Lander
2011-05-16  6:38 ` Carsten Dominik

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