lisp/org-indent.el: Add hook to run after it initializes a buffer

* lisp/org-indent.el (org-indent-initialize-buffer): Define and call
hook after it initializes a buffer.
* etc/ORG-NEWS: Announce new custom option.

This will allow to enrich org-indent properties without requiring
hacks to detect initialization.
See https://list.orgmode.org/orgmode/5f4cdb77-8f43-4f2d-91a7-bc4ce57df8ad@app.fastmail.com/#r

TINYCHANGE
This commit is contained in:
Alexandre Avanian 2024-01-02 18:08:09 +08:00 committed by Ihor Radchenko
parent dfeff03c5a
commit 3aac00e45d
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 15 additions and 1 deletions

View File

@ -581,6 +581,11 @@ The main change will be for users who did not configure
~ob-python~ will now start interactive sessions in a more consistent ~ob-python~ will now start interactive sessions in a more consistent
manner with ~run-python~. manner with ~run-python~.
*** New hook option ~org-indent-post-buffer-init-functions~
This allows to run functions after ~org-indent~ intializes a buffer to
enrich its properties.
** New features ** New features
*** =ob-plantuml.el=: Support tikz file format output *** =ob-plantuml.el=: Support tikz file format output

View File

@ -103,6 +103,14 @@ For details see the variable `org-adapt-indentation'."
:group 'org-indent :group 'org-indent
:type 'integer) :type 'integer)
(defcustom org-indent-post-buffer-init-functions nil
"Hook run after org-indent finishes initializing a buffer.
The function(s) in in this hook must accept a single argument representing
the initialized buffer."
:group 'org-indent
:package-version '(Org . "9.7")
:type 'hook)
(defface org-indent '((t (:inherit org-hide))) (defface org-indent '((t (:inherit org-hide)))
"Face for outline indentation. "Face for outline indentation.
The default is to make it look like whitespace. But you may find it The default is to make it look like whitespace. But you may find it
@ -290,7 +298,8 @@ a time value."
;; Job is complete: un-agentize buffer. ;; Job is complete: un-agentize buffer.
(unless interruptp (unless interruptp
(setq org-indent-agentized-buffers (setq org-indent-agentized-buffers
(delq buffer org-indent-agentized-buffers)))))))) (delq buffer org-indent-agentized-buffers))
(run-hook-with-args 'org-indent-post-buffer-init-functions buffer)))))))
(defun org-indent-set-line-properties (level indentation &optional heading) (defun org-indent-set-line-properties (level indentation &optional heading)
"Set prefix properties on current line an move to next one. "Set prefix properties on current line an move to next one.