* [PATCH] Always run org-insert-heading-hook when creating headlines
@ 2010-09-26 14:15 Bernt Hansen
2010-09-29 14:44 ` Carsten Dominik
0 siblings, 1 reply; 3+ messages in thread
From: Bernt Hansen @ 2010-09-26 14:15 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Bernt Hansen
* lisp/org.el (org-insert-heading): Run org-insert-heading-hook when creating
the first heading in a file
The org-insert-heading-hook was skipped when creating the first
heading in a new org file.
---
I use an hook which creates an inactive timestamp for new headings. This was reported
by k-man on the mailing list stating it doesn't work for empty org files when creating
the first heading.
I use the following hook:
(defun bh/insert-inactive-timestamp ()
(interactive)
(org-insert-time-stamp nil t t nil nil nil))
(defun bh/insert-heading-inactive-timestamp ()
(save-excursion
(org-return)
(org-cycle)
(bh/insert-inactive-timestamp)))
(add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-timestamp)
-Bernt
lisp/org.el | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 75ee798..667a4e4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6752,8 +6752,8 @@ This is important for non-interactive uses of the command."
(when (and org-insert-heading-respect-content hide-previous)
(save-excursion
(goto-char previous-pos)
- (hide-subtree)))
- (run-hooks 'org-insert-heading-hook)))))
+ (hide-subtree))))))
+ (run-hooks 'org-insert-heading-hook))
(defun org-get-heading (&optional no-tags)
"Return the heading of the current entry, without the stars."
--
1.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Always run org-insert-heading-hook when creating headlines
2010-09-26 14:15 [PATCH] Always run org-insert-heading-hook when creating headlines Bernt Hansen
@ 2010-09-29 14:44 ` Carsten Dominik
2010-09-30 3:17 ` Bernt Hansen
0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2010-09-29 14:44 UTC (permalink / raw)
To: Bernt Hansen; +Cc: emacs-orgmode
Hi Bernt,
this patch does not work, it calls the hook also after inserting a new
item.
Please fix it by first reverting, and then call the hook also inside
the if clause, right after (insert "\n") - you need progn then, of
course.
Thanks.
- Carsten
On Sep 26, 2010, at 4:15 PM, Bernt Hansen wrote:
> * lisp/org.el (org-insert-heading): Run org-insert-heading-hook when
> creating
> the first heading in a file
>
> The org-insert-heading-hook was skipped when creating the first
> heading in a new org file.
> ---
>
> I use an hook which creates an inactive timestamp for new headings.
> This was reported
> by k-man on the mailing list stating it doesn't work for empty org
> files when creating
> the first heading.
>
> I use the following hook:
>
> (defun bh/insert-inactive-timestamp ()
> (interactive)
> (org-insert-time-stamp nil t t nil nil nil))
>
> (defun bh/insert-heading-inactive-timestamp ()
> (save-excursion
> (org-return)
> (org-cycle)
> (bh/insert-inactive-timestamp)))
>
> (add-hook 'org-insert-heading-hook 'bh/insert-heading-inactive-
> timestamp)
>
> -Bernt
>
> lisp/org.el | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 75ee798..667a4e4 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -6752,8 +6752,8 @@ This is important for non-interactive uses of
> the command."
> (when (and org-insert-heading-respect-content hide-previous)
> (save-excursion
> (goto-char previous-pos)
> - (hide-subtree)))
> - (run-hooks 'org-insert-heading-hook)))))
> + (hide-subtree))))))
> + (run-hooks 'org-insert-heading-hook))
>
> (defun org-get-heading (&optional no-tags)
> "Return the heading of the current entry, without the stars."
> --
> 1.7.3
>
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Always run org-insert-heading-hook when creating headlines
2010-09-29 14:44 ` Carsten Dominik
@ 2010-09-30 3:17 ` Bernt Hansen
0 siblings, 0 replies; 3+ messages in thread
From: Bernt Hansen @ 2010-09-30 3:17 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Bernt Hansen
* lisp/org.el (org-insert-heading): Run org-insert-heading-hook when creating
the first heading in a file
The org-insert-heading-hook was skipped when creating the first
heading in a new org file.
---
Carsten,
You're correct -- I completely missed the list details on this one. Here's an updated
patch.
Thanks for spotting this.
Regards,
Bernt
lisp/org.el | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 75ee798..32c6c4a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6673,7 +6673,9 @@ This is important for non-interactive uses of the command."
(and (not (save-excursion (and (ignore-errors (org-back-to-heading invisible-ok))
(org-on-heading-p))))
(not (org-in-item-p))))
- (insert "\n* ")
+ (progn
+ (insert "\n* ")
+ (run-hooks 'org-insert-heading-hook))
(when (or force-heading (not (org-insert-item)))
(let* ((empty-line-p nil)
(head (save-excursion
--
1.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-30 3:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-26 14:15 [PATCH] Always run org-insert-heading-hook when creating headlines Bernt Hansen
2010-09-29 14:44 ` Carsten Dominik
2010-09-30 3:17 ` Bernt Hansen
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).