Explorar o código

Call `org-insert-heading' instead of (insert "* ")

* lisp/org-agenda.el (org-agenda-insert-diary-as-top-level):
* lisp/org.el (org-link-search):  Call `org-insert-heading' instead
  of (insert "* ").

This allows, in particular, to run `org-insert-heading-hook' and
possibly fix up blank lines around.
Nicolas Goaziou %!s(int64=10) %!d(string=hai) anos
pai
achega
0be8495d01
Modificáronse 2 ficheiros con 6 adicións e 5 borrados
  1. 3 3
      lisp/org-agenda.el
  2. 3 2
      lisp/org.el

+ 3 - 3
lisp/org-agenda.el

@@ -9487,12 +9487,12 @@ Add TEXT as headline, and position the cursor in the second line so that
 a timestamp can be added there."
   (widen)
   (goto-char (point-max))
-  (or (bolp) (insert "\n"))
-  (org-insert-heading)
+  (unless (bolp) (insert "\n"))
+  (org-insert-heading nil t t)
   (insert text)
   (org-end-of-meta-data)
   (unless (bolp) (insert "\n"))
-  (if org-adapt-indentation (org-indent-to-column 2)))
+  (when org-adapt-indentation (org-indent-to-column 2)))
 
 (defun org-agenda-insert-diary-make-new-entry (text)
   "Make a new entry with TEXT as the first child of the current subtree.

+ 3 - 2
lisp/org.el

@@ -11101,8 +11101,9 @@ visibility around point, thus ignoring
 	     (eq org-link-search-must-match-exact-headline 'query-to-create)
 	     (y-or-n-p "No match - create this as a new heading? "))
 	(goto-char (point-max))
-	(or (bolp) (newline))
-	(insert "* " s "\n")
+	(unless (bolp) (newline))
+	(org-insert-heading nil t t)
+	(insert s "\n")
 	(beginning-of-line 0))
        (t
 	(goto-char pos)