Re: How to organize tasks about Worg within Worg documents

2024-03-29 Thread Adam Porter

Hi Tom,

On 3/29/24 18:30, Thomas S. Dye wrote:

Here's another potential solution that I find useful.

d. Keeping tasks under a heading held back from export.
I have a capture template that saves tasks about the document under a * 
Tasks :no-export: heading.  To keep the agenda sane, I don't add the 
file.  Instead, I show buffer local tasks with org-sidebar.


Yes, that's a good solution if we want the tasks hidden from the 
exported HTML on Worg.  I'm not sure if we do want that; that may be 
another minor policy decision to be made.  (Maybe it's not a big deal, 
but a bit of consistency in this regard would make Worg seem more 
serious and polished, which might encourage more contribution.)




Re: How to organize tasks about Worg within Worg documents (was: Re: [Worg] CSS improvements)

2024-03-29 Thread Thomas S. Dye

Aloha all,

Adam Porter  writes:


On 3/29/24 04:48, Ihor Radchenko wrote:

Also, we may consider re-using inlinetask style for TODO: 
entries.


Rather than
#+begin_center
TODO: Even better, find a volunteer to maintain this 
information!

#+end_center

We can do

 TODO Even better, ...


That is a lot of asterisks, and I can't remember if inline 
tasks are
enabled by default.  :)  But in general, sure, I've no 
objection.  I
think that we should have some standard way to encode tasks 
within Worg

documents, regardless of what it is.

Yeah. And... we do.
https://orgmode.org/worg/worg-editing.html#orgce51883
Just a normal heading with TODO keyword.


I'm not sure that page really covers the question of how to 
present tasks about

the document within the same document.

Using a normal heading for a task would "commandeer" the 
structure of the

document, which I think is a real problem.

ISTM that there are a few potential solutions:

a. Using inline tasks.  Although not enabled by default, they 
seem to

   solve the problem pretty well.

b. Using commented lines, i.e.

 # TODO: Improve this information.

   Potentially we could even comment Org syntax within the file, 
   like:


 # * TODO Improve this information  :research_needed:

   Which encodes a normal Org heading but as a commented line, 
   so it 	
   wouldn't affect the structure of the document itself.  Of 
   course,
   that would not appear in the exported content, which is 
   probably not
   what we want; but those headings could still be collected, 
   e.g. by

   something like magit-todos.

c. Keeping tasks in a separate file.  We do already have the 
/todo.org
   file, so maybe this is what we should standardize on, i.e. 
   never
   putting tasks in the documents themselves but only in this 
   file.


Here's another potential solution that I find useful.

d. Keeping tasks under a heading held back from export.
I have a capture template that saves tasks about the document 
under a * Tasks :no-export: heading.  To keep the agenda sane, I 
don't add the file.  Instead, I show buffer local tasks with 
org-sidebar.


hth,
Tom

--
Thomas S. Dye
https://tsdye.online/tsdye



How to organize tasks about Worg within Worg documents (was: Re: [Worg] CSS improvements)

2024-03-29 Thread Adam Porter

On 3/29/24 04:48, Ihor Radchenko wrote:


Also, we may consider re-using inlinetask style for TODO: entries.

Rather than
#+begin_center
TODO: Even better, find a volunteer to maintain this information!
#+end_center

We can do

 TODO Even better, ...


That is a lot of asterisks, and I can't remember if inline tasks are
enabled by default.  :)  But in general, sure, I've no objection.  I
think that we should have some standard way to encode tasks within Worg
documents, regardless of what it is.


Yeah. And... we do.
https://orgmode.org/worg/worg-editing.html#orgce51883

Just a normal heading with TODO keyword.


I'm not sure that page really covers the question of how to present 
tasks about the document within the same document.


Using a normal heading for a task would "commandeer" the structure of 
the document, which I think is a real problem.


ISTM that there are a few potential solutions:

a. Using inline tasks.  Although not enabled by default, they seem to
   solve the problem pretty well.

b. Using commented lines, i.e.

 # TODO: Improve this information.

   Potentially we could even comment Org syntax within the file, like:

 # * TODO Improve this information  :research_needed:

   Which encodes a normal Org heading but as a commented line, so it
   wouldn't affect the structure of the document itself.  Of course,
   that would not appear in the exported content, which is probably not
   what we want; but those headings could still be collected, e.g. by
   something like magit-todos.

c. Keeping tasks in a separate file.  We do already have the /todo.org
   file, so maybe this is what we should standardize on, i.e. never
   putting tasks in the documents themselves but only in this file.

Regardless of the decision, I do think that having this stated as a 
policy somewhere would be helpful.


WDYT?



SVG Previews for org mode

2024-03-29 Thread Robert
Hello,

I created the attached code to be able to preview SVG in org mode. Please 
comment if you have suggestions for a better approach.

It works by having svg in a #+begin_src svg block and running org-format-svg on 
it.

I took inspiration from org-format-latex and wonder whether it should be merged 
with that function.

Upsides:
- The same keybinding (C-c C-x C-l) could be used.
- Less duplicated code
- More?

Downsides: 
- The name of the function would be misleading
- Other breakage
- More?

It could also be integrated with the C-c mechanisms on src_blocks. But I don’t 
know how to do that.

Best regards

Robert

(defun org--make-svg-preview-overlay (beg end image)
  "Build an overlay between BEG and END using the svg image data."
  (let ((ov (make-overlay beg end)))
(overlay-put ov 'org-overlay-type 'org-svg-overlay)
(overlay-put ov 'evaporate t)
(overlay-put ov
 'modification-hooks
 (list (lambda (o _flag _beg _end  _l)
 (delete-overlay o
(overlay-put ov
 'display
 (find-image `((:type svg :data ,image :scale 1 
:transform-smoothing t))

(defun org-format-svg ( beg end)
  (let ((context-regexp "#\\+begin_src +svg"))
(goto-char (or beg (point-min)))
(while (re-search-forward context-regexp end t)
  (let* ((context (org-element-context))
 (type (org-element-type context)))
(when (and (eq type 'src-block) 
   (string= (org-element-property :language context) "svg"))
  (let* ((value (org-element-property :value context))
 (beg (org-element-property :begin context))
 (end (save-excursion
(goto-char (org-element-property :end context))
(skip-chars-backward " \r\t\n")
(point
(progn
  (dolist (o (overlays-in beg end))
(when (eq (overlay-get o 'org-overlay-type) 'org-svg-overlay)
  (delete-overlay o
(org--make-svg-preview-overlay beg end value)
(goto-char end)))

(defun org-clear-svg-preview ( beg end)
  (let ((overlays (cl-remove-if-not
   (lambda (o) (eq (overlay-get o 'org-overlay-type) 
'org-svg-overlay))
   (overlays-in (or beg (point-min)) (or end (point-max))
(mapc #'delete-overlay overlays)
overlays))

(defun org-svg-preview ( arg)
  "Toggle the preview of the svg fragment at point"
  (interactive)
  (cond
   ((not (display-graphic-p)) nil)  ;; noop on non-graphic displays
   ((use-region-p)
(org-format-svg (region-beginning) (region-end)))
   ((let ((context (org-element-context)))
  (and (eq (org-element-type context) 'src-block)
   (string= (org-element-property :language context) "svg")
   (let ((beg (org-element-property :begin context))
 (end (org-element-property :end context)))
 (if (org-clear-svg-preview beg end)
 (message "SVG preview removed")
   (message "Creating SVG preview...")
   (org-format-svg beg end)
   (message "Creating SVG preview... done."))
 t))
(provide 'bob-org-svg)




Re: [PATCH] Create commands for org-read-date-minibuffer-local-map

2024-03-29 Thread Bastien Guerry
Ihor Radchenko  writes:

> Bastien, may you please check FSF records?

Yes, Laurence copyright status is okay.

-- 
 Bastien Guerry



Re: [WORG] 2680e65 * org-maintenance.org (Copyright assignments): Minor improvements

2024-03-29 Thread Bastien Guerry
Adam Porter  writes:

> Sure.  I've pushed that, adding a "co-authored-by" line for Bastien.

Thanks!

-- 
 Bastien Guerry



Re: Support for whitespace prefix for :noweb-prefix

2024-03-29 Thread Doerthous
Thanks, I'll check it out.



Re: Support for whitespace prefix for :noweb-prefix

2024-03-29 Thread Ihor Radchenko
Doerthous  writes:

> I kind of understand what you mean: what I need is just the no
> option, after the expansion (maybe with the help of some
> after-expansion-hooks), indent the source block according to
> major-mode. Right?
>
> I will try to find some hooks after expansion and some APIs to
> indent a source block?
>
> Are the any tips for doing this? :-)

Maybe `org-babel-tangle-body-hook'. If your problem is how the tangled
code looks like.

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



Re: Support for whitespace prefix for :noweb-prefix

2024-03-29 Thread Doerthous
Ihor Radchenko  writes:

> I still feel that what you are really looking for is major-mode-specific
> indentation, not a prefix. Because indentation may require tabs, not
> spaces. Or may interfere with programming language.

I kind of understand what you mean: what I need is just the no
option, after the expansion (maybe with the help of some
after-expansion-hooks), indent the source block according to
major-mode. Right?

I will try to find some hooks after expansion and some APIs to
indent a source block?

Are the any tips for doing this? :-)

Thanks in advance.



Re: Support for whitespace prefix for :noweb-prefix

2024-03-29 Thread Ihor Radchenko
Doerthous  writes:

> Ihor Radchenko  writes:
>
>> I think that a more general approach could be allowing :noweb-prefix to
>> have a value of string that will be appended to each line on the
>> expansion.
>
> With the use case discussed before, is allowing :noweb-prefix to have a
> value of string means I need to provide a string with 5 space
> characters to :noweb-ref like this?

> #+begin_src elisp :noweb yes :noweb-prefix " "
>   (let (<>)
> <>)
> #+end_src

Yes.

I still feel that what you are really looking for is major-mode-specific
indentation, not a prefix. Because indentation may require tabs, not
spaces. Or may interfere with programming language.

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



Re: Support for whitespace prefix for :noweb-prefix

2024-03-29 Thread Doerthous
Ihor Radchenko  writes:

> I think that a more general approach could be allowing :noweb-prefix to
> have a value of string that will be appended to each line on the
> expansion.

With the use case discussed before, is allowing :noweb-prefix to have a
value of string means I need to provide a string with 5 space
characters to :noweb-ref like this?

#+begin_src elisp :noweb yes :noweb-prefix " "
  (let (<>)
<>)
#+end_src

Or is it some other way?



Re: [BUG] Prompt appears in async shell results

2024-03-29 Thread Ihor Radchenko
Matt  writes:

>   On Wed, 27 Mar 2024 11:59:06 +0100  Ihor Radchenko  wrote --- 
>
>  > Over a week have passed. No objections have been raised.
>  > Feel free to apply the patches.
>
> Done.  See: 
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e9c288dfaccc2960e5b6889e6aabea700ad4e05a
>  and parents.

Fixed.
(this is a message to tracker)

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



Re: [BUG] Prompt appears in async shell results

2024-03-29 Thread Matt


  On Wed, 27 Mar 2024 11:59:06 +0100  Ihor Radchenko  wrote --- 

 > Over a week have passed. No objections have been raised.
 > Feel free to apply the patches.

Done.  See: 
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e9c288dfaccc2960e5b6889e6aabea700ad4e05a
 and parents.

--
Matt Trzcinski
Emacs Org contributor (ob-shell)
Learn more about Org mode at https://orgmode.org
Support Org development at https://liberapay.com/org-mode





Re: [Worg] CSS improvements

2024-03-29 Thread Ihor Radchenko
Adam Porter  writes:

>> It is not about democracy or veto. We disagree about expectations for
>> #+begin_center. Expectations are not about me or you, but rather about
>> what WORG authors will expect. So, asking people makes sense.
>
> If you feel strongly enough about the background color idea (which would 
> be an interesting reversal ;), I'll leave that in your hands. 
> Otherwise, I don't feel strongly enough about it to pursue a poll.

No poll then :) I was worried that you feel strongly about this.

>> Also, we may consider re-using inlinetask style for TODO: entries.
>> 
>> Rather than
>> #+begin_center
>> TODO: Even better, find a volunteer to maintain this information!
>> #+end_center
>> 
>> We can do
>> 
>>  TODO Even better, ...
>
> That is a lot of asterisks, and I can't remember if inline tasks are 
> enabled by default.  :)  But in general, sure, I've no objection.  I 
> think that we should have some standard way to encode tasks within Worg 
> documents, regardless of what it is.

Yeah. And... we do.
https://orgmode.org/worg/worg-editing.html#orgce51883

Just a normal heading with TODO keyword.

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



Re: Support for whitespace prefix for :noweb-prefix

2024-03-29 Thread Ihor Radchenko
Doerthous  writes:

>> Do you mean that you want the code to be indented according to the major
>> mode rules?
>>
>
> Why it relates to major mode,
>
> Currently, with :noweb-prefix set to yes, the above code will be expand to
> #+begin_src elisp
> (let ((a 0)
> (let ((b 1))
>`(,a ,b))
> #+end_src
>
> ~(let (~ is the prefix of <>.
>
> I thought we can replace just the prefix in current code[1]  with
> ~(setq prefix (replace-regexp-in-string "[^ \t]" " " prefix))~ ?

I see.
So, you want a custom prefix before the expanded noweb reference lines.

I think that a more general approach could be allowing :noweb-prefix to
have a value of string that will be appended to each line on the
expansion.

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



[PATCH] ox-publish: Do not store :title, :date, and :index in project cache

2024-03-29 Thread Ihor Radchenko

This patch fixes situation when :title/:date/:index properties are
stored in the project cache and then not updated even when the
corresponding project file does get updated.

>From 06bd6a52686ec868a336d89a0ceef4359a71fb14 Mon Sep 17 00:00:00 2001
Message-ID: <06bd6a52686ec868a336d89a0ceef4359a71fb14.1711703988.git.yanta...@posteo.net>
From: Ihor Radchenko 
Date: Fri, 29 Mar 2024 12:17:09 +0300
Subject: [PATCH] ox-publish: Do not store :title, :date, and :index in project
 cache

* lisp/ox-publish.el (org-publish-transient-cache): New transient
cache, used just during current publish process.
(org-publish-initialize-cache):
(org-publish-reset-cache): Initialize the transient cache.
(org-publish-cache-set-file-property): Add new optional argument to
store property in transient cache rather than persistent cache.
(org-publish-cache-get-file-property): Query transient cache first.
(org-publish-collect-index):
(org-publish-find-title):
(org-publish-find-date): Use transient cache.

This commit fixes situation when :title/:date/:index properties are
not updated even when the corresponding project file does get updated.
---
 lisp/ox-publish.el | 49 +++---
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 9bfd333a4..3e526b813 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -56,6 +56,9 @@ (defvar org-publish-cache nil
   "This will cache timestamps and titles for files in publishing projects.
 Blocks could hash sha1 values here.")
 
+(defvar org-publish-transient-cache nil
+  "This will cache information during publishing process.")
+
 (defvar org-publish-after-publishing-hook nil
   "Hook run each time a file is published.
 Every function in this hook will be called with two arguments:
@@ -867,7 +870,7 @@ (defun org-publish-find-title (file project)
 		(org-no-properties
 		 (org-element-interpret-data parsed-title))
 		  (file-name-nondirectory (file-name-sans-extension file)
-	  (org-publish-cache-set-file-property file :title title)
+	  (org-publish-cache-set-file-property file :title title nil 'transient)
 
 (defun org-publish-find-date (file project)
   "Find the date of FILE in PROJECT.
@@ -892,7 +895,8 @@ (defun org-publish-find-date (file project)
   (org-time-string-to-time value))
 		   ((file-exists-p file)
 		(file-attribute-modification-time (file-attributes file)))
-		   (t (error "No such file: \"%s\"" file)
+		   (t (error "No such file: \"%s\"" file)
+ nil 'transient
 
 (defun org-publish-sitemap-default-entry (entry style project)
   "Default format for site map ENTRY, as a string.
@@ -1048,7 +1052,8 @@ (defun org-publish-collect-index (output _backend info)
 			  (replace-regexp-in-string
 			   "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" ""
 			   (org-element-property :raw-value parent)
-	info
+	info))
+ nil 'transient))
   ;; Return output unchanged.
   output)
 
@@ -1251,6 +1256,9 @@ (defun org-publish-initialize-cache (project-name)
 (error "Org publish timestamp: %s is not a directory"
 	   org-publish-timestamp-directory))
 
+  (unless org-publish-transient-cache
+(setq org-publish-transient-cache (make-hash-table :test #'equal)))
+
   (unless (and org-publish-cache
 	   (string= (org-publish-cache-get ":project:") project-name))
 (let* ((cache-file
@@ -1274,6 +1282,8 @@ (defun org-publish-reset-cache ()
   (message "%s" "Resetting org-publish-cache")
   (when (hash-table-p org-publish-cache)
 (clrhash org-publish-cache))
+  (when (hash-table-p org-publish-transient-cache)
+(clrhash org-publish-transient-cache))
   (setq org-publish-cache nil))
 
 (defun org-publish-cache-file-needs-publishing
@@ -1319,16 +1329,22 @@ (defun org-publish-cache-file-needs-publishing
 		   included-files-mtime))
 
 (defun org-publish-cache-set-file-property
-(filename property value  project-name)
+(filename property value  project-name transient)
   "Set the VALUE for a PROPERTY of file FILENAME in publishing cache to VALUE.
 Use cache file of PROJECT-NAME.  If the entry does not exist, it
-will be created.  Return VALUE."
+will be created.  Return VALUE.
+
+When TRANSIENT is non-nil, store value in transient cache that is only
+maintained during the current publish process."
   ;; Evtl. load the requested cache file:
   (when project-name (org-publish-initialize-cache project-name))
-  (let ((pl (org-publish-cache-get filename)))
-(if pl (progn (plist-put pl property value) value)
-  (org-publish-cache-get-file-property
-   filename property value nil project-name
+  (if transient
+  (puthash (cons filename property) value
+   org-publish-transient-cache)
+(let ((pl (org-publish-cache-get filename)))
+  (if pl (progn (plist-put pl property value) value)
+(org-publish-cache-get-file-property
+ filename property value nil