From: dark.key8799@151e.ai
To: "Ihor Radchenko" <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: Suggestion to add hook to be run when org-indent completes a buffer's initialization
Date: Tue, 02 Jan 2024 23:53:46 +0800 [thread overview]
Message-ID: <a57e1074-5304-44ff-9383-e11d66ba092f@app.fastmail.com> (raw)
In-Reply-To: <87o7e43s21.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 306 bytes --]
On Tue, Jan 2, 2024, at 19:15, Ihor Radchenko wrote:
> By convention, abnormal hooks (hooks that require arguments) are named
> as *-functions, not *-hook.
>
> Also, when adding new customizations, we generally announce them in
> etc/ORG-NEWS.
Understood. Please find amended patch.
--
Alexandre Avanian
[-- Attachment #2: 0001-lisp-org-indent.el-Add-hook-to-run-after-it-initiali.patch --]
[-- Type: application/octet-stream, Size: 2322 bytes --]
From 12edb4205a87be187900a55de5c37b9264a7a27c Mon Sep 17 00:00:00 2001
From: Alexandre Avanian <git@alexandre.avanian.net>
Date: Tue, 2 Jan 2024 18:08:09 +0800
Subject: [PATCH] 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
---
etc/ORG-NEWS | 5 +++++
lisp/org-indent.el | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 7d0822faf..a906d116f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -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
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
*** =ob-plantuml.el=: Support tikz file format output
diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index 62ebd6be0..aebd95743 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -103,6 +103,13 @@
:group 'org-indent
: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
+ :type 'hook)
+
(defface org-indent '((t (:inherit org-hide)))
"Face for outline indentation.
The default is to make it look like whitespace. But you may find it
@@ -290,7 +297,8 @@
;; Job is complete: un-agentize buffer.
(unless interruptp
(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)
"Set prefix properties on current line an move to next one.
--
2.43.0
next prev parent reply other threads:[~2024-01-02 15:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-30 5:24 Suggestion to add hook to be run when org-indent completes a buffer's initialization dark.key8799
2023-12-31 14:42 ` Ihor Radchenko
2024-01-02 10:56 ` [PATCH] " dark.key8799
2024-01-02 11:15 ` Ihor Radchenko
2024-01-02 15:53 ` dark.key8799 [this message]
2024-01-03 15:38 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a57e1074-5304-44ff-9383-e11d66ba092f@app.fastmail.com \
--to=dark.key8799@151e.ai \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).