emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Zachary Kanfer <zkanfer@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-read-date-overlay shown in other buffers, point in calendar window defaults to end of line
Date: Mon, 6 Feb 2012 11:22:16 -0500	[thread overview]
Message-ID: <CAFXT+RN3SyPpqaKXfXm-uGCir3mos6UkGc+Er5gGJ_eedtp6dQ@mail.gmail.com> (raw)


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

This patch fixes two bugs in the same section of code:

Bug 1: While running org-time-stamp, org-read-date-overlay is shown in the
current buffer, even when that buffer isn't the minibuffer. You can see
this by entering a file in org-mode, then pressing <C-c .> to run
org-time-stamp. The overlay is the yellow highlighted line showing the date
that will be entered into the org-mode window. For example, "=> <2012-01-23
Mon>". Move into another window with <C-x o>, and the overlay is displayed
there. I don't think this is desired behavior.

To fix this, I added a line that inserts org-read-date-overlay only if the
current buffer is a minibuffer.

Bug 2: While running org-time-stamp, when moving point into the calendar
window, there is an error: error in post-command hook (buffer-read-only
*Calendar*). Additionally, point is put at the end of the line containing
the current day. To reproduce this behavior, press <C-c .> to run
org-time-stamp, then press <C-x o> repeatedly until you move point into the
window with the Calendar.

You will see the aformentioned error, and the cursor will be at the end of
the line containing the current day. To fix this, I removed the process of
explicitly saving point in the minibuffer and restoring it after inserting
org-read-date-overlay, and replaced it with save-excursion.

-Zachary Kanfer

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

[-- Attachment #2: org-time-stamp-2012-02-06.diff --]
[-- Type: text/x-patch, Size: 2668 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index c93b7b2..3c93dff 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15051,35 +15051,35 @@ user."
   (when org-read-date-display-live
     (when org-read-date-overlay
       (delete-overlay org-read-date-overlay))
-    (let ((p (point)))
-      (end-of-line 1)
-      (while (not (equal (buffer-substring
-			  (max (point-min) (- (point) 4)) (point))
-			 "    "))
-	(insert " "))
-      (goto-char p))
-    (let* ((ans (concat (buffer-substring (point-at-bol) (point-max))
-			" " (or org-ans1 org-ans2)))
-	   (org-end-time-was-given nil)
-	   (f (org-read-date-analyze ans def defdecode))
-	   (fmts (if org-dcst
-		     org-time-stamp-custom-formats
-		   org-time-stamp-formats))
-	   (fmt (if (or with-time
-			(and (boundp 'org-time-was-given) org-time-was-given))
-		    (cdr fmts)
-		  (car fmts)))
-	   (txt (concat "=> " (format-time-string fmt (apply 'encode-time f)))))
-      (when (and org-end-time-was-given
-		 (string-match org-plain-time-of-day-regexp txt))
-	(setq txt (concat (substring txt 0 (match-end 0)) "-"
-			  org-end-time-was-given
-			  (substring txt (match-end 0)))))
-      (when org-read-date-analyze-futurep
-	(setq txt (concat txt " (=>F)")))
-      (setq org-read-date-overlay
-	    (make-overlay (1- (point-at-eol)) (point-at-eol)))
-      (org-overlay-display org-read-date-overlay txt 'secondary-selection))))
+    (when (minibufferp (current-buffer))
+      (save-excursion
+	(end-of-line 1)
+	(while (not (equal (buffer-substring
+			    (max (point-min) (- (point) 4)) (point))
+			   "    "))
+	  (insert " ")))
+      (let* ((ans (concat (buffer-substring (point-at-bol) (point-max))
+			  " " (or org-ans1 org-ans2)))
+	     (org-end-time-was-given nil)
+	     (f (org-read-date-analyze ans def defdecode))
+	     (fmts (if org-dcst
+		       org-time-stamp-custom-formats
+		     org-time-stamp-formats))
+	     (fmt (if (or with-time
+			  (and (boundp 'org-time-was-given) org-time-was-given))
+		      (cdr fmts)
+		    (car fmts)))
+	     (txt (concat "=> " (format-time-string fmt (apply 'encode-time f)))))
+	(when (and org-end-time-was-given
+		   (string-match org-plain-time-of-day-regexp txt))
+	  (setq txt (concat (substring txt 0 (match-end 0)) "-"
+			    org-end-time-was-given
+			    (substring txt (match-end 0)))))
+	(when org-read-date-analyze-futurep
+	  (setq txt (concat txt " (=>F)")))
+	(setq org-read-date-overlay
+	      (make-overlay (1- (point-at-eol)) (point-at-eol)))
+	(org-overlay-display org-read-date-overlay txt 'secondary-selection)))))
 
 (defun org-read-date-analyze (ans def defdecode)
   "Analyze the combined answer of the date prompt."

             reply	other threads:[~2012-02-06 16:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06 16:22 Zachary Kanfer [this message]
2012-04-23 13:13 ` [PATCH] org-read-date-overlay shown in other buffers, point in calendar window defaults to end of line Bastien

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=CAFXT+RN3SyPpqaKXfXm-uGCir3mos6UkGc+Er5gGJ_eedtp6dQ@mail.gmail.com \
    --to=zkanfer@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).