Browse Source

Fix bug with insertion of date lines into a tree from the agenda

Reports by Stephen Eglen and Eric S Fraga.
Carsten Dominik 15 years ago
parent
commit
b8a4d004f2
4 changed files with 16 additions and 6 deletions
  1. 8 0
      lisp/ChangeLog
  2. 1 1
      lisp/org-agenda.el
  3. 1 1
      lisp/org-mac-message.el
  4. 6 4
      lisp/org.el

+ 8 - 0
lisp/ChangeLog

@@ -1,5 +1,13 @@
 2010-02-01  Carsten Dominik  <carsten.dominik@gmail.com>
 2010-02-01  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
+	* org-agenda.el (org-agenda-insert-diary-make-new-entry): Call
+	`org-insert-heading' with the INVISIBLE-OK argument.
+
+	* org-mac-message.el (org-mac-message-insert-flagged): Call
+	`org-insert-heading' with the INVISIBLE-OK argument.
+
+	* org.el (org-insert-heading):  New argument INVISIBLE-OK.
+
 	* org-agenda.el (org-agenda-view-mode-dispatch): Improve the
 	* org-agenda.el (org-agenda-view-mode-dispatch): Improve the
 	prompt message.
 	prompt message.
 
 

+ 1 - 1
lisp/org-agenda.el

@@ -6946,7 +6946,7 @@ a timestamp can be added there."
     (org-back-over-empty-lines)
     (org-back-over-empty-lines)
     (or (looking-at "[ \t]*$")
     (or (looking-at "[ \t]*$")
 	(progn (insert "\n") (backward-char 1)))
 	(progn (insert "\n") (backward-char 1)))
-    (org-insert-heading)
+    (org-insert-heading nil t)
     (org-do-demote)
     (org-do-demote)
     (setq col (current-column))
     (setq col (current-column))
     (insert text "\n")
     (insert text "\n")

+ 1 - 1
lisp/org-mac-message.el

@@ -209,7 +209,7 @@ list of message:// links to flagged mail after heading."
 	    (insert "\n" (org-mac-message-get-links "f")))
 	    (insert "\n" (org-mac-message-get-links "f")))
 	(goto-char (point-max))
 	(goto-char (point-max))
 	(insert "\n")
 	(insert "\n")
-	(org-insert-heading)
+	(org-insert-heading nil t)
 	(insert org-heading "\n" (org-mac-message-get-links "f"))))))
 	(insert org-heading "\n" (org-mac-message-get-links "f"))))))
 
 
 (provide 'org-mac-message)
 (provide 'org-mac-message)

+ 6 - 4
lisp/org.el

@@ -6087,15 +6087,17 @@ frame is not changed."
 	 (save-match-data
 	 (save-match-data
 	   (looking-at "[ \t]*$")))))
 	   (looking-at "[ \t]*$")))))
 
 
-(defun org-insert-heading (&optional force-heading)
+(defun org-insert-heading (&optional force-heading invisible-ok)
   "Insert a new heading or item with same depth at point.
   "Insert a new heading or item with same depth at point.
 If point is in a plain list and FORCE-HEADING is nil, create a new list item.
 If point is in a plain list and FORCE-HEADING is nil, create a new list item.
 If point is at the beginning of a headline, insert a sibling before the
 If point is at the beginning of a headline, insert a sibling before the
 current headline.  If point is not at the beginning, do not split the line,
 current headline.  If point is not at the beginning, do not split the line,
-but create the new headline after the current line."
+but create the new headline after the current line.
+When INVISIBLE-OK is set, stop at invisible headlines when going back.
+This is important for non-interactive uses of the command."
   (interactive "P")
   (interactive "P")
   (if (or (= (buffer-size) 0)
   (if (or (= (buffer-size) 0)
-	  (and (not (save-excursion (and (ignore-errors (org-back-to-heading))
+	  (and (not (save-excursion (and (ignore-errors (org-back-to-heading invisible-ok))
 					 (org-on-heading-p))))
 					 (org-on-heading-p))))
 	       (not (org-in-item-p))))
 	       (not (org-in-item-p))))
       (insert "\n* ")
       (insert "\n* ")
@@ -6104,7 +6106,7 @@ but create the new headline after the current line."
 	     (head (save-excursion
 	     (head (save-excursion
 		     (condition-case nil
 		     (condition-case nil
 			 (progn
 			 (progn
-			   (org-back-to-heading)
+			   (org-back-to-heading invisible-ok)
 			   (setq empty-line-p (org-previous-line-empty-p))
 			   (setq empty-line-p (org-previous-line-empty-p))
 			   (match-string 0))
 			   (match-string 0))
 		       (error "*"))))
 		       (error "*"))))