Browse Source

Add facility for commit log messages from Org documents

* lisp/org-compat.el (org-add-log-current-headline): New function.
* lisp/org.el (org-mode): Use new function.
Nicolas Goaziou 3 years ago
parent
commit
f50f373389
2 changed files with 10 additions and 0 deletions
  1. 8 0
      lisp/org-compat.el
  2. 2 0
      lisp/org.el

+ 8 - 0
lisp/org-compat.el

@@ -712,6 +712,14 @@ To get rid of the restriction, use `\\[org-agenda-remove-restriction-lock]'."
      (add-hook 'speedbar-visiting-tag-hook
 	       (lambda () (and (derived-mode-p 'org-mode) (org-show-context 'org-goto))))))
 
+;;;; Add Log
+
+(defun org-add-log-current-headline ()
+  "Return current headline or nil.
+This function ignores inlinetasks.  It is meant to be used as
+`add-log-current-defun-function' value."
+  (org-with-limited-levels (org-get-heading t t t t)))
+
 ;;;; Flyspell
 
 (defun org--flyspell-object-check-p (element)

+ 2 - 0
lisp/org.el

@@ -5509,6 +5509,8 @@ The following commands are available:
 		  (forward-char -1))))
   ;; Next error for sparse trees
   (setq-local next-error-function 'org-occur-next-match)
+  ;; Make commit log messages from Org documents easier.
+  (setq-local add-log-current-defun-function #'org-add-log-current-headline)
   ;; Make sure dependence stuff works reliably, even for users who set it
   ;; too late :-(
   (if org-enforce-todo-dependencies