Re: [PATCH] Add org-after-note-stored-hook

2024-05-12 Thread General discussions about Org-mode.
Ihor Radchenko  writes:
> Although, removing heading from inside
> `org-after-todo-state-change-hook' is a bad idea - Org mode does not
> expect the heading to disappear from under the cursor when this hook is
> executed. I recommend using `org-trigger-hook' instead.

Thanks for your help! I switched to `org-trigger-hook' without issue.

> An easier way would be forcing note earlier by calling
> `org-add-log-note' from your hook.

I remember trying that before adding the hook (and I tried again today)
but the problem with adding the note directly is that I only seem to
manage storing the note where the task was before being archived,
eg. with this (or any variants I could think of while making sense of
what note functions do):

#+begin_src elisp
  (when (member (plist-get properties ':to) '("CANCELLED" "READ"))
(org-add-log-note)
(my/org-roam-archive-to-today))
#+end_src

which I find logical, since `org-store-log-note' is only called after
=C-c C-c= is pressed, whereas the archival function is called just after
the note buffer is created. So I still struggle to see how I could do
without the hook (maybe if the archival function would return the
position of the task after moving it, but that seems more complicated
than just using the hook).

> It will probably be better to run such new hooks right before (message "Note 
> stored")
> in `org-store-log-note'.

A patch modified to match the suggested location for the `run-hooks' is
attached.

>From 779d6b85acf9c30d7230bffccb2f98764372034a Mon Sep 17 00:00:00 2001
From: Joris Caravati 
Date: Sun, 12 May 2024 21:29:52 +0200
Subject: [PATCH] lisp/org.el: Add `org-after-note-stored-hook'

* lisp/org.el: Add `org-after-note-stored-hook' which is called at the
end of the `org-store-log-note' function.
* etc/ORG-NEWS: Document the new hook.

This change allows customization after a note is taken. One case where
it is useful is when one wants to move a task after a state change but
cannot do so in `org-after-todo-state-change' because the new state is
configured to take a note (with '@' in `org-todo-keywords').

Setting this hook in `org-after-todo-state-change' allows to defer the
move after the note is taken and prevents the note to be placed where
the task was before being moved.

TINYCHANGE
---
 etc/ORG-NEWS | 4 
 lisp/org.el  | 4 
 2 files changed, 8 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87b72ad12..4b7636765 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -1569,6 +1569,10 @@ optional argument =NEW-HEADING-CONTAINER= specifies where in the
 buffer it will be added.  If not specified, new headings are created
 at level 1 at the end of the accessible part of the buffer, as before.
 
+*** New hook [[doc::org-after-note-stored-hook][org-after-note-stored-hook]]
+
+This new hook runs when a note has been stored.
+
 ** Miscellaneous
 *** =org-crypt.el= now applies initial visibility settings to decrypted entries
 
diff --git a/lisp/org.el b/lisp/org.el
index 598b4ca23..64f6d07ee 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1990,6 +1990,9 @@ Lisp variable `org-state'."
   :group 'org-todo
   :type 'hook)
 
+(defcustom org-after-note-stored-hook nil
+  "Hook which is run after a note was stored")
+
 (defvar org-blocker-hook nil
   "Hook for functions that are allowed to block a state change.
 
@@ -10845,6 +10848,7 @@ items are State notes."
(unless (string-empty-p line)
 	 (indent-line-to ind)
 	 (insert-and-inherit line
+   (run-hooks 'org-after-note-stored-hook)
 	   (message "Note stored")
 	   (org-back-to-heading t))
   ;; Don't add undo information when called from `org-agenda-todo'.
-- 
2.44.0



Re: [PATCH] Fix some emacs-30 byte-compile warnings

2024-05-12 Thread Ihor Radchenko
Ihor Radchenko  writes:

> It is clearly a bug of some kind - the code is not doing what it
> intended originally. But we need to understand org-table.el better to
> fix this...

Upon further review, I dropped that branch of if completely.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=bd5665e01

No more warnings on main.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Fontification of scheme code blocks

2024-05-12 Thread Ihor Radchenko
Ihor Radchenko  writes:

> We have recently got WORG build failures because running scheme-mode
> spawns an interactive prompt to select Scheme implementation.
>
> This happens when Org export attempts to fontify scheme source blocks,
> and calling major mode (scheme-mode) expects user interaction -
> something we do not anticipate.
>
> The failure is https://builds.sr.ht/~bzg/job/1036834

This is no longer happening.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Pending contents in org documents (Re: Asynchronous blocks for everything (was Re: ...))

2024-05-12 Thread Bruno Barbier


Thanks for the review Ihor!

>> Thanks. I've improved the documentation of `org-pending' to mention
>> that one may want to customize the following fields of a reglock:
>> before-kill-function, user-cancel-function and
>> insert-details-function.  And, also, I added that one can attach
>> custom properties using the "properties" field.
>
> Thanks, but I still feel confused.
> May you:
>
> 1. Explain what does "kill" and "cancel" mean in the context of the
>REGLOCK.

I tried to document that as part of the function `org-pending. That is:

   |- Emacs may have to kill your locks; see the field
   |  `before-kill-function' if you wish to do something before your
   |  lock is killed.

In other words, Emacs has to kill the locks, because the user decided
to kill Emacs or some buffers.  The user has no say about this.  This
is when org-pending calls the private function
`org-pending--forced-kill'.
   
   
   |- The user may ask Emacs to cancel your lock; see the field
   |  `user-cancel-function' to override the default cancel function.

The user is not interested anymore by the lock.  He makes a polite
request to the library that locked the region to unlock it, the sooner
the better.

I added some documentation about them to the top level commentary.
   
> 2. Add information about visual hints, "kill", and "cancel" to the
>top-level commentary.
>
> For now, when reading the top commentary:
>
> ;; This library contains an API to lock a region while it is "being
> ;; updated"; the content of the region is "pending" and cannot be
> ;; modified.  It will be updated, later, when the new content is
> ;; available.
>
> I have an impression that the only side effect of "locking" is that the
> region becomes read-only. It is not clear at all that any other
> visual indication will be provided.

I added a description of the user interface at top-level.


[...]
> Yes, I do think that top commentary should explain this.
> The very idea that lock may be "canceled" or "killed" is important when
> designing Elisp code that uses the org-pending library.
>

Both "killed" and "canceled" are now described in the user interface
top-level section.


[...]
>
> I hope that the above clarifies what I am looking for.

I think it did.  And I even hope the improved top-level documentation
shows it :)


I've pushed the modification to my branch.

Thanks again for the review, your time and useful comments,


Bruno




Re: Is it possible to embed youtube video in wordpress post created with org2blog

2024-05-12 Thread Ihor Radchenko
Steinar Bang  writes:

> I use org2blog to create posts for https://steinar.bang.priv.no
>
> Right now I'm working on a blog post where I would like to embed a
> youtuble video, but I can't figure out how.
>
> Is it possible?
>
> I tried the obvious approach, which is the same way I embed images, i.e.
>  [[https://www.youtube.com/watch?v=tcihVdB7oU8]]
>
> But that only showed the URL in the blog post

You will probably need to embed youtube iframe.
For example, using
https://github.com/org2blog/org2blog?tab=readme-ov-file#raw-html-creation

Also, you can define a custom link type as described in
https://bitspook.in/blog/extending-org-mode-to-handle-youtube-links/ or
as done in https://github.com/TobiasZawada/org-yt
Although, you may need to adjust things for org2blog export backend,
which is not html AFAIU.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Q: org-publish-project-alist and :exclude

2024-05-12 Thread Ihor Radchenko
David Masterson  writes:

>>> When you have '(:foo bar :baz eet), nothing inside is evaluated because
>>> of the quote. To evaluate expressions selectively, use backquote:
>>>
>>> `(:foo bar:baz ,(concat "foo" "bar"))
> ...
> I spoke too soon -- I'm still getting the same error about expecting a
> string.  You mentioned '`' above, but use ',' in your manual diff.  I
> tried both (along with rx-to-string).  

Check out 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Update contact info

2024-05-12 Thread Bastien Guerry
Ihor Radchenko  writes:

> Bastien, may you please confirm? 

I do, thanks!

-- 
 Bastien Guerry



Re: How to organize tasks about Worg within Worg documents

2024-05-12 Thread Adam Porter

On 5/12/24 07:18, Ihor Radchenko wrote:


I looked into this further, and found
exporters/taskjuggler/ox-taskjuggler.org

that has whole "TODO" subtrees hidden with :noexport: tag.

Such half-ready subtrees are not really ready for normal viewing and are
mostly a material for WORG hackers to work on. Not sure how they fit
into the discussed todo records and notes concept.


Seems like a reasonable solution in that case.



Re: How to organize tasks about Worg within Worg documents

2024-05-12 Thread Ihor Radchenko
Adam Porter  writes:

>> 2. Put notes into LOGBOOK drawers (set `org-log-into-drawer' in WORG
>> dirlocals)
>> 3. Change `org-html-format-drawer-function' during publishing to mark
>> the LOGBOOK drawers with a distinct class.
>> 4. Enable org-inlinetask library during publishing.
>> 
>> Then, the CSS switch will involve toggling visibility of (1) todo
>> keyword classes; (2) inlinetask class; (3) LOGBOOK drawer class.

I looked into this further, and found
exporters/taskjuggler/ox-taskjuggler.org

that has whole "TODO" subtrees hidden with :noexport: tag.

Such half-ready subtrees are not really ready for normal viewing and are
mostly a material for WORG hackers to work on. Not sure how they fit
into the discussed todo records and notes concept.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Add option to export mixed Setext and ATX-style Markdown headlines

2024-05-12 Thread Ihor Radchenko
Lee Thompson  writes:

> ...
> I hope this explains more clearly what I'm trying to achieve, do let me
> know if not.

Yes.
Applied, onto main, with amendments.
I changed the commit message and news style to imperative and tweaked
one place in the code to not rely upon the existing set of the possible
options.

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=1a7d7a5a5
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fffb87174

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [FR] :noweb-wrap header arg

2024-05-12 Thread Ihor Radchenko
Amy Grinn  writes:

>> +1
>> You may even use obsolete alias (add it to lisp/org-compat.el)
>
> Here's a patch to rename org-babel-noweb-wrap to
> org-babel-noweb-make-regexp.

Thanks!
News entry is not necessary here - we are just renaming a function.
Otherwise, the patch looks good.
I am not yet merging it though - let's have all the patches you plan for
the new noweb-wrap argument first and then apply them together.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Update contact info

2024-05-12 Thread Ihor Radchenko
Amy Grinn  writes:

> Bastien Guerry  writes:
>
>> Ihor Radchenko  writes:
>>
>>> Bastien, may you check which name is used in the FSF records?
>>
>> I've taken this offlist.
>
> The name in the FSF records should be correct now.

Bastien, may you please confirm? We can then update WORG records.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at