emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: dark.key8799@151e.ai
To: "Ihor Radchenko" <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Re: Suggestion to add hook to be run when org-indent completes a buffer's initialization
Date: Tue, 02 Jan 2024 18:56:29 +0800	[thread overview]
Message-ID: <afc8f2e9-ce6b-461e-8855-1715cf3845f2@app.fastmail.com> (raw)
In-Reply-To: <87r0j277sf.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 161 bytes --]

On Sun, Dec 31, 2023, at 22:42, Ihor Radchenko wrote:

> I do not see why we shouldn't add such a hook. Patches welcome!

Would this work?

-- 
Alexandre Avanian

[-- Attachment #2: 0001-lisp-org-indent.el-Add-hook-to-run-after-it-initiali.patch --]
[-- Type: application/octet-stream, Size: 1711 bytes --]

From d11dc9bfdb3a659ca56884a98a7a0bf703f2a4ce 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.

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
---
 lisp/org-indent.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index 62ebd6be0..4dc883c01 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-hook 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-hook 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


  reply	other threads:[~2024-01-02 10:57 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   ` dark.key8799 [this message]
2024-01-02 11:15     ` [PATCH] " Ihor Radchenko
2024-01-02 15:53       ` dark.key8799
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=afc8f2e9-ce6b-461e-8855-1715cf3845f2@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).