Re: Replace org link with footnote

2023-11-10 Thread Max Nikulin

On 11/11/2023 03:23, Matt wrote:

Here's a quick hack to replace an Org link with a footnote.

[...]

   (if (org-in-regexp org-link-bracket-re 1)


During the following discussion I thought on 
`org-export-filter-parse-tree-functions' as a means to transform links 
into footnotes for ox-ascii (it is a bit different from current way to 
put link URLs at the end of the current heading. It should be better 
than regexp-based parsing.


Max Nikulin. [RFC][PATCH] Allow to export to ascii custom link types as 
notes. Sat, 21 Oct 2023 00:21:47 +0700.

https://list.orgmode.org/ugucve$12l4$1...@ciao.gmane.io





Slowdown with large headings in view

2023-11-10 Thread Sebastian Wålinder
Hello!

I have massive org-mode file with thousands of SRC blocks.

As the file grew, I started to get very poor performance, but setting 
`org-fold-core--ignore-modifications` to `t` solved it.

However, I still get very poor performance when a lot of folded headings are in 
view. It gets slower as headings with more text hidden inside its fold come 
into view.

I have tried running the profiler to find out what the issue is, but no matter 
how laggy Emacs gets, the profiler records practically no CPU samples or memory 
usage.

When the massive org buffer is in view and showing large folded headlines, any 
command run is very slow, even if the action is performed in another buffer 
entirely. It returns to normal when no window is showing the headings, as well 
as when I bring the folded headings out of view or unfold them.

I tried disabling font-lock, but it didn't do anything.

How can I profile this, or does anyone have a guess of what could be causing it?

Thank you!
Sebastian



Replace org link with footnote

2023-11-10 Thread Matt
Here's a quick hack to replace an Org link with a footnote.  Maybe a fun first 
commit for someone would be to update `org-footnote-new` to accept optional 
LABEL and DEFINITION arguments that allow a footnote to be created 
programmatically?

(defun my-replace-link-with-footnote ()
  "Replace an org link with a footnote.

Place the link target in the footnote and the description in the
location of the original Org link."
  (interactive)
  (if (org-in-regexp org-link-bracket-re 1)
  (save-excursion
(let ((remove (list (match-beginning 0) (match-end 0)))
  (link (org-match-string-no-properties 1))
  (description  ; link is description
   (if (match-end 2)
   (org-match-string-no-properties 2)
 (org-match-string-no-properties 1
  (apply 'delete-region remove)
  ;; replaces link with footnote and jumps to footnote
  (call-interactively 'org-footnote-new nil)
  (insert " " link)
  (beginning-of-line)
  ;; follow link back to original point
  (org-open-at-point)
  (insert description)




Re: [BUG] tmp [9.7-pre (release_9.6.10-881-g595a32 @ /home/ps/.emacs.d/org-mode-git/lisp/)]

2023-11-10 Thread Samuel Wales
not a real ans but maybe related history.  iirc outline.el made the
decision to consider an entry not to include its final newline.  org
derives from that and did not comprehensively change that.  there have
been bugs.


On 11/10/23, Paul Stansell  wrote:
> Hello,
>
> When using Org Mode version 9.7-pre (release_9.6.10-881-g595a32) the
> following happens that doesn't happen when using Org Mode version 9.5.5
> (release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)]:
>
> When the cursor is at the end of a folded section, that is, immediately
> after the ellipses, and return is pressed the folded section is made
> visible (i.e., it is unfolded).
>
>
> This is particularly problematic when adding a new section after the last
> section in an org file.  If the last section is folded it seems impossible
> to get the cursor beyond the final ellipses so when adding a new section
> below this one (using return or Alt-return) the previous section is
> always opened.  For sections that aren't the last one can put the cursor at
> the start of the next section and press Alt-return to insert a new section
> above it without unfolding any sections.
>
> Kind regards,
>
> Paul
>
> # ==
>
> Emacs  : GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
> 3.24.37, cairo version 1.16.0)
>  of 2023-03-16, modified by Debian
> Package: Org mode version 9.7-pre (release_9.6.10-881-g595a32 @
> /home/ps/.emacs.d_Kubuntu-23.04/org-mode-git/lisp/)
>
> current state:
> ==
> (setq
>  org-link-elisp-confirm-function 'yes-or-no-p
>  org-bibtex-headline-format-function 'org-bibtex-headline-format-default
>  org-log-done 'time
>  org-fontify-done-headline nil
>  org-log-into-drawer t
>  org-startup-folded 'content
>  org-persist-after-read-hook '(org-element--cache-persist-after-read)
>  org-format-latex-options '(:foreground "Yellow" :background default :scale
> 1.2
> :html-foreground "Black" :html-background
> "Transparent"
> :html-scale 1.07 :matchers ("begin" "$1" "$"
> "$$" "\\(" "\\["))
>  org-export-before-parsing-hook '(org-attach-expand-links)
>  org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe
> org-babel-header-arg-expand)
>  org-archive-hook '(org-attach-archive-delete-maybe)
>  org-file-apps '((auto-mode . emacs) ("\\.odt\\'" . "libreoffice %s")
>  ("\\.docx\\'" . "libreoffice %s") ("\\.xlsx\\'" .
> "libreoffice %s")
>  ("\\.png\\'" . "xv %s") ("\\.jpg\\'" . "xv %s")
> ("\\.jpeg\\'" . "xv %s")
>  ("\\.webp\\'" . "xv %s") ("\\.pdf\\'" . "okular \"%s\"")
>  ("\\.xoj" . "xournal %s") ("\\.xopp" . "xournalpp %s"))
>  org-odt-format-inlinetask-function
> 'org-odt-format-inlinetask-default-function
>  org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
> WIDTH)"]
>  org-cycle-hook '(org-cycle-hide-archived-subtrees
> org-cycle-show-empty-lines
>   org-cycle-optimize-window-after-visibility-change
>   org-cycle-display-inline-images)
>  org-persist-before-read-hook '(org-element--cache-persist-before-read)
>  org-mode-hook '(#[0 "\301\211 \207" [imenu-create-index-function
> org-imenu-get-tree] 2]
>  #[0 "\300\301\302\303\304$\207"
>[add-hook change-major-mode-hook org-fold-show-all
> append local] 5]
>  #[0 "\300\301\302\303\304$\207"
>[add-hook change-major-mode-hook
> org-babel-show-result-all append local]
>5]
>  org-babel-result-hide-spec org-babel-hide-all-hashes)
>  org-babel-load-languages '((R . t) (emacs-lisp . t) (gnuplot . t) (octave
> . t) (python . t)
> (fortran . t) (sql . t) (ditaa . t) (dot . t)
> (shell . t))
>  org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
>  org-latex-format-headline-function
> 'org-latex-format-headline-default-function
>  org-confirm-shell-link-function 'yes-or-no-p
>  org-adapt-indentation t
>  org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME
> CONTENTS)"]
>  outline-isearch-open-invisible-function 'outline-isearch-open-invisible
>  org-highlight-latex-and-related '(latex)
>  org-odt-format-headline-function 'org-odt-format-headline-default-function
>  org-agenda-before-write-hook '(org-agenda-add-entry-text)
>  org-babel-tangle-lang-exts '(("fortran" . "F90") ("python" . "py")
> ("emacs-lisp" . "el")
>   ("elisp" . "el"))
>  org-src-mode-hook '(org-src-babel-configure-edit-buffer
> org-src-mode-configure-edit-buffer)
>  org-confirm-elisp-link-function 'yes-or-no-p
>  org-clock-out-remove-zero-time-clocks t
>  org-hide-leading-stars t
>  org-todo-keywords '((sequence "TODO(t!)" "MAYBE(m!)" "STARTED(s!)"
> "WAITING(w@/!)" "|"
>   "DONE(d)" "INFO(i!)" "CANCELLED(c@)" "UNFINISHED(u@)"
> "ABANDONED(a@)")
>  

[BUG] tmp [9.7-pre (release_9.6.10-881-g595a32 @ /home/ps/.emacs.d/org-mode-git/lisp/)]

2023-11-10 Thread Paul Stansell
Hello,

When using Org Mode version 9.7-pre (release_9.6.10-881-g595a32) the
following happens that doesn't happen when using Org Mode version 9.5.5
(release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)]:

When the cursor is at the end of a folded section, that is, immediately
after the ellipses, and return is pressed the folded section is made
visible (i.e., it is unfolded).


This is particularly problematic when adding a new section after the last
section in an org file.  If the last section is folded it seems impossible
to get the cursor beyond the final ellipses so when adding a new section
below this one (using return or Alt-return) the previous section is
always opened.  For sections that aren't the last one can put the cursor at
the start of the next section and press Alt-return to insert a new section
above it without unfolding any sections.

Kind regards,

Paul

# ==

Emacs  : GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.16.0)
 of 2023-03-16, modified by Debian
Package: Org mode version 9.7-pre (release_9.6.10-881-g595a32 @
/home/ps/.emacs.d_Kubuntu-23.04/org-mode-git/lisp/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-bibtex-headline-format-function 'org-bibtex-headline-format-default
 org-log-done 'time
 org-fontify-done-headline nil
 org-log-into-drawer t
 org-startup-folded 'content
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-format-latex-options '(:foreground "Yellow" :background default :scale
1.2
:html-foreground "Black" :html-background
"Transparent"
:html-scale 1.07 :matchers ("begin" "$1" "$"
"$$" "\\(" "\\["))
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-file-apps '((auto-mode . emacs) ("\\.odt\\'" . "libreoffice %s")
 ("\\.docx\\'" . "libreoffice %s") ("\\.xlsx\\'" .
"libreoffice %s")
 ("\\.png\\'" . "xv %s") ("\\.jpg\\'" . "xv %s")
("\\.jpeg\\'" . "xv %s")
 ("\\.webp\\'" . "xv %s") ("\\.pdf\\'" . "okular \"%s\"")
 ("\\.xoj" . "xournal %s") ("\\.xopp" . "xournalpp %s"))
 org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
 org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-show-empty-lines
  org-cycle-optimize-window-after-visibility-change
  org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-mode-hook '(#[0 "\301\211 \207" [imenu-create-index-function
org-imenu-get-tree] 2]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-fold-show-all
append local] 5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook
org-babel-show-result-all append local]
   5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-babel-load-languages '((R . t) (emacs-lisp . t) (gnuplot . t) (octave
. t) (python . t)
(fortran . t) (sql . t) (ditaa . t) (dot . t)
(shell . t))
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-latex-format-headline-function
'org-latex-format-headline-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-adapt-indentation t
 org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 outline-isearch-open-invisible-function 'outline-isearch-open-invisible
 org-highlight-latex-and-related '(latex)
 org-odt-format-headline-function 'org-odt-format-headline-default-function
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-tangle-lang-exts '(("fortran" . "F90") ("python" . "py")
("emacs-lisp" . "el")
  ("elisp" . "el"))
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-clock-out-remove-zero-time-clocks t
 org-hide-leading-stars t
 org-todo-keywords '((sequence "TODO(t!)" "MAYBE(m!)" "STARTED(s!)"
"WAITING(w@/!)" "|"
  "DONE(d)" "INFO(i!)" "CANCELLED(c@)" "UNFINISHED(u@)"
"ABANDONED(a@)")
 )
 org-id-link-to-org-use-id t
 org-speed-command-hook '(org-speed-command-activate
org-babel-speed-command-activate)
 org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"]
 org-confirm-babel-evaluate nil
 org-fold-core-isearch-open-function 'org-fold--isearch-reveal
 

Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-10 Thread Leo Butler
On Fri, Nov 10 2023, Max Nikulin  wrote:

> On 10/11/2023 10:19, Leo Butler wrote:
>> On Thu, Nov 09 2023, Max Nikulin wrote:
>> 
>>> diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el
> [...]
>>> should allow to set :java to
>>>
>>>  flatpak-spawn --host toolbox run /usr/bin/ditaa
>>>
>>> without abusing of org-ditaa-jar-path. Untested.
>> 
>> Doesn't this abuse the `java' header argument, which is intended to pass
>> arguments to the java runtime?
>
> or `org-babel-ditaa-java-cmd'. My point is that requirement of non-empty 
> `org-ditaa-jar-path' confused Florin to the degree when workarounds 
> looked impossible. Notice that setting
>
>  org-ditaa-jar-path "/usr/bin/ditaa"
>
> still requires spreading of "flatpack-spawn ..." over 
> `org-babel-ditaa-java-cmd', :java, and `org-ditaa-jar-option'. 
> fortunately some of these options may be sent empty and other will not 
> quote spaces, etc. Whole "flatpack-spawn ... ditaa" command can not be 
> put to `org-ditaa-jar-path'

Hi Max,

Let me back up for a second: I wrote in the documentation patch

"Users may need to use a script to run ditaa."

That is a very circumspect statement. That is not saying that we can
throw any command at ob-ditaa and it will work.

>
>> I think that it would be best to implement the change to mirror that
>> done in ob-plantuml, as Ihor suggested earlier.
>
> Agree. I appreciate consistency in treatment of similar cases.

I am glad we agree. Now let me tell you my dilemma: a while ago, I
suggested a patch to implement similar functionality for ob-maxima. The
patch used customization variables, much like ob-plantuml does. Ihor's
feedback was that this was not a good approach (too much room for
accidental breakage, etc.). Eventually, the patch was amended to acheive
the same goals using new header arguments.

So, now, in my opinion, consistency would dictate that we re-visit the
changes made to ob-plantuml, re-fashion them and do something similar
with ob-ditaa. Except, users have likely become accustomed to using
ob-plantuml as it is...

Thoughts?

>
> I am not sure in the following idea. Perhaps a concept of "launcher" (or 
> "runner") may be introduced. Launchers may be stacked. So for a jar file 
> launcher is "java @:java -jar" that may be combined with "toolbox run" 
> and "flatpak-spawn --host" launchers.
>
>> My reading of the documentation and ob-plantuml.el is that it is not
>> possible to use the `java' header argument in the way you propose for
>> ob-ditaa.el.
>
> Since nobody has proposed a patch for ob-ditaa, I decided that making a 
> workaround easier is an improvement.

I am not in favour of a band-aid, it will hand-cuff us in the future.

I explained above why I haven't proposed a patch to ob-ditaa, yet.

Best,
Leo



Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-10 Thread Leo Butler
On Fri, Nov 10 2023, Ihor Radchenko  wrote:

> Leo Butler  writes:
>
>> While I was reviewing the documentation, ob-doc-ditaa.org, and the
>> source, ob-ditaa.el, I realized that there is a simple way to run a
>> script file instead of a jar file. The documentation patch includes such
>> an example.
>
> Org cannot support every possible feature.

Agreed.

> And even if we do want to add certain features in future (like
> supporting ditaa executable herein), it does not mean that we have to
> rush them by any cost.

Ihor, I don't understand that sentence.

The *documentation* patch was intended to show that ob-ditaa did not
need to be changed. A user can already run ditaa from a script file by
setting the customization variables appropriately (or, inappropriately,
as Max said ;-) ).

Leo


Re: fancy TODO lists setup (emacs 29.1)

2023-11-10 Thread Martin Steffen




> I am unable to reproduce using both stable and main branches.

>> PS: My org version is Org mode version 9.5.2
>> (release_9.5.2-286-gd01235)

> This is not the latest version of Org. You can try to upgrade.



Thanks a lot. Seems like updating the org-setting did the trick already.

I got now

   Org mode version 9.7 pre (release_9.6.11-917)

and the todo's works basically unchange and as I am used to.



Re: Issue with org-persist and Tramp

2023-11-10 Thread Fabio Natali
On 2023-11-10, 11:13 +, Fabio Natali  wrote:
> Brilliant. I think the second branch should read `(not (file-remote-p
> file))', i.e. `file' instead of `associated'? It seems to work with that
> micro amendment.

Hm, I stand corrected, I retested it end-to-end and no, it doesn't seem
to work. I'll post more details later. Cheers, Fabio.



Re: Issue with org-persist and Tramp

2023-11-10 Thread Fabio Natali
On 2023-11-10, 09:26 +, Ihor Radchenko  wrote:
> What about the attached patch?

Hi Ihor,

Brilliant. I think the second branch should read `(not (file-remote-p
file))', i.e. `file' instead of `associated'? It seems to work with that
micro amendment.

Anything else I should be testing or does this look reasonable enough to
be pushed to the repo at some point?

Thank you very much for this!



Cheers, Fabio.



Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-10 Thread Max Nikulin

On 10/11/2023 10:19, Leo Butler wrote:

On Thu, Nov 09 2023, Max Nikulin wrote:


diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el

[...]

should allow to set :java to

 flatpak-spawn --host toolbox run /usr/bin/ditaa

without abusing of org-ditaa-jar-path. Untested.


Doesn't this abuse the `java' header argument, which is intended to pass
arguments to the java runtime?


or `org-babel-ditaa-java-cmd'. My point is that requirement of non-empty 
`org-ditaa-jar-path' confused Florin to the degree when workarounds 
looked impossible. Notice that setting


org-ditaa-jar-path "/usr/bin/ditaa"

still requires spreading of "flatpack-spawn ..." over 
`org-babel-ditaa-java-cmd', :java, and `org-ditaa-jar-option'. 
fortunately some of these options may be sent empty and other will not 
quote spaces, etc. Whole "flatpack-spawn ... ditaa" command can not be 
put to `org-ditaa-jar-path'



I think that it would be best to implement the change to mirror that
done in ob-plantuml, as Ihor suggested earlier.


Agree. I appreciate consistency in treatment of similar cases.

I am not sure in the following idea. Perhaps a concept of "launcher" (or 
"runner") may be introduced. Launchers may be stacked. So for a jar file 
launcher is "java @:java -jar" that may be combined with "toolbox run" 
and "flatpak-spawn --host" launchers.



My reading of the documentation and ob-plantuml.el is that it is not
possible to use the `java' header argument in the way you propose for
ob-ditaa.el.


Since nobody has proposed a patch for ob-ditaa, I decided that making a 
workaround easier is an improvement.


 #+property: header-args:ditaa :java ...

would not affect ob-plantuml.

P.S. I am unsure what is proper balance between flexibility/convenience 
and security. A file downloaded from net should not be able to change 
executables and their options without consent from the user. 
Unfortunately attempts to suppress at least shell expansion will lead to 
more verbose configuration.






Re: Colons in :var header arguments

2023-11-10 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Stefano Ghirlanda  writes:
>
>> I have run into an inconvenience in that colons in :var header
>> arguments to source blocks are invariably interpreted as referring to
>> another file. However, I use cleveref in LaTeX export (via org-ref) to
>> automatically format references using labels like tab:data, and in
>> these cases :var data=tab:data gives a reference not found because tab
>> is interpreted as a filename.
>
> I agree that it is a problem.
> Attaching tentative patch that will make Org babel fall back to
> searching in current file when FILE in FILE:REF does not exist.
>
> It is technically a breaking change. If this is affecting someone's
> workflow, please chime in.

No objections have been raised after one month.
Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=b5cfc311d

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



Re: [PATCH] Highlight ANSI sequences in the whole buffer (was [PATCH] ANSI color on example blocks and fixed width elements)

2023-11-10 Thread Ihor Radchenko
Nathaniel Nicandro  writes:

>> A few months have passed since the last activity in this thread.
>> May I know if you are still interested in the idea?
>
> I apologize for being unresponsive all these months. Yes I'm still
> interested in this idea, although I have not had time to work on it
> recently.  Life events caused me to have to stop working on it
> completely a few months back, I'm hoping to be able to put in more time
> now.

No problem.
There is no real rush. Just a gentle, infrequent, ping to keep things
progressing :)

> Where I'm having some trouble is processing the contents of greater
> elements.  My approach for them is basically to define an ansi-context
> (see `ansi-color-context-region`) for each greater element and process
> the inner elements using that context.  This seems to work except for
> plain-list elements which can have other plain-list elements within
> them, e.g.
>
> #+RESULTS:
> - List item 1
>   - Sub-list item 1
> - List item 2
> - List item 3
>
> Should the sub-list's sequence affect the rest of list elements in the
> parent list?  If that's the case, then I think I can keep with my
> approach and define an ansi-context for the outermost plain-list which
> is used by all the other plain-list elements contained within
> it. Otherwise I think I would have to do something like copy the
> ansi-context for each inner plain-list and use the copy to process the
> sequences in the inner-list so that the context of the outer-list is
> unaffected. WDYT?

Just go with whatever is simpler implementation-wise. It is a good idea
to get things working first, and only then go ahead with tweaking small
details as necessary.

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



Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-10 Thread Ihor Radchenko
Leo Butler  writes:

> While I was reviewing the documentation, ob-doc-ditaa.org, and the
> source, ob-ditaa.el, I realized that there is a simple way to run a
> script file instead of a jar file. The documentation patch includes such
> an example.

Org cannot support every possible feature. And even if we do want to add
certain features in future (like supporting ditaa executable herein), it
does not mean that we have to rush them by any cost.

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



Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-10 Thread Ihor Radchenko
Leo Butler  writes:

> [fn:1] (Aside: `org-plantuml-executable-args' should be `org-plantuml-args';
> Ihor missed it when he made the change in commit b5f0efc049).

Now fixed.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5c82e1e1d

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



Re: [PATCH] org-id: allow using parent's existing id in links to headlines

2023-11-10 Thread Ihor Radchenko
"Rick Lupton"  writes:

> On Tue, 25 Jul 2023, at 8:43 AM, Ihor Radchenko wrote:
>> Ideally, we should have all the necessary logic to store the link within
>> `org-id-store-link' and then use `org-link-set-parameters' to configure
>> id links.
>
> I agree this would be neater, but looking at how this would work, I have a 
> question:
>
> Behaviour in `org-store-link` currently depends on the `interactive?` 
> argument, e.g. in this logic
>
> (and interactive?
>  (or (eq org-id-link-to-org-use-id 'create-if-interactive)
>  (and (eq org-id-link-to-org-use-id
>   'create-if-interactive-and-no-custom-id)
>   (not custom-id
>
> To move this logic to `org-id-store-link`, is there a way that 
> `org-id-store-link` can tell whether `org-store-link` was called (a) 
> interactively, or (b) with the `interactive?` argument true?

I think that we need to make a change in the rules for :store functions.
`interactive?' may be passed as the argument to these functions.

In order to not cause breakage, we need something like

(condition-case nil
 (funcall protocol path desc backend info)
   ;; XXX: The function used (< Org 9.4) to accept only
   ;; three mandatory arguments.  Type-specific `:export'
   ;; functions in the wild may not handle current
   ;; signature.  Provide backward compatibility support
   ;; for them.
   (wrong-number-of-arguments
(funcall protocol path desc backend)))

to keep the old :store functions that accept 0 arguments working.

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



Re: [ANN] lisp/ob-tangle-sync.el

2023-11-10 Thread Mehmet Tekman
Ihor Radchenko  writes:

> Mehmet Tekman  writes:
>
>> Okay, I will definitely need to refactor my patches then, but I'm
>> quite happy with the state of my current patch branch, so it will
>> be an additional patch instead of a brand new set of patches
>> I think.
>
> It has been a while since the most recent message in this thread.
> May I know if you need any further help with the patch?
>

Hey, thanks for reaching out.

No, I know what to do -- it's just finding the time to do it that is
proving difficult.

I made some small edits a few months ago, to reform the header arguments
so that tangle actions would be encoded in the `:tangle-params' header
and would largely leave the `:tangle' header alone… but when I tested
it, it was failing all tests for reasons I wasn't to sure about.

Here is the current state of my header-reform branch:

>From 9ba64d149aac6c807e233e34474ffe022488efe6 Mon Sep 17 00:00:00 2001
From: Mehmet Tekman 
Date: Wed, 20 Sep 2023 11:35:00 +0200
Subject: [PATCH] header refs

---
 lisp/ob-core.el | 48 ++--
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index a7c4f2cab..0b0d1c18c 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1753,6 +1753,42 @@ HEADER-ARGUMENTS is alist of all the arguments."
 	  header-arguments)
 (nreverse results)))
 
+
+(defun org-babel--split-str-quoted (str)
+  "Splits a string that may or may not contain quotes."
+  (let (result pos)
+(while (string-match (rx (or (seq "\"" (group (* (not "\""))) "\"")
+ (group (+ (not space)
+ str pos)
+  (let ((match-str1 (match-string 1 str))
+(match-str2 (match-string 2 str)))
+(if match-str1
+(progn
+  (push match-str1 result)
+  (setq pos (1+ (match-end 1
+  (push match-str2 result)
+  (setq pos (match-end 2)
+(nreverse result)))
+
+(defun org-babel--tangle-split (raw-tangle)
+  "Split a :tangle headerby filename and sync action."
+  (let* ((valid-sync-actions '("import" "export" "sync"))
+ (file-action (org-babel--split-str-quoted raw-tangle))
+ (file (car file-action))
+ (action (nth (1- (length file-action)) file-action)))
+(if (member action valid-sync-actions)
+;; If last word matches, assume the previous are all part of
+;; the filename
+(setq file (mapconcat #'identity (nreverse (cdr (nreverse file-action))) " "))
+  ;; Otherwise set the default action and assume that the full
+  ;; string has no action
+  (if (or file action)
+  (setq action "export"
+file (read-char raw-tangle
+(if (or file action)
+(list file action)
+  (list nil
+
 (defun org-babel-process-params (params)
   "Expand variables in PARAMS and add summary parameters."
   (let* ((processed-vars (mapcar (lambda (el)
@@ -1775,7 +1811,13 @@ HEADER-ARGUMENTS is alist of all the arguments."
 	raw-result
   ;; FIXME: Arbitrary code evaluation.
 	  (eval raw-result t)))
-			  (cdr (assq :result-params params))
+			  (cdr (assq :result-params params)
+ (raw-tangle (or (cdr (assq :tangle params)) ""))
+ (tangle-params (delete-dups
+		 (append
+		  (org-babel--tangle-split raw-tangle)
+		  (cdr (assq :tangle-params params)
+ )
 (append
  (mapcar (lambda (var) (cons :var var)) (car vars-and-names))
  (list
@@ -1786,7 +1828,9 @@ HEADER-ARGUMENTS is alist of all the arguments."
   (cons :result-params result-params)
   (cons :result-type  (cond ((member "output" result-params) 'output)
 ((member "value" result-params) 'value)
-(t 'value
+(t 'value)))
+  (cons :tangle-params tangle-params)
+  )
  (cl-remove-if
   (lambda (x) (memq (car x) '(:colname-names :rowname-names :result-params
 	 :result-type :var)))
-- 
2.42.1


If you have any insight into why the tests are failing, I'd greatly
appreciate it.

Best,
Mehmet


Re: [ANN] lisp/ob-tangle-sync.el

2023-11-10 Thread Ihor Radchenko
Mehmet Tekman  writes:

> Okay, I will definitely need to refactor my patches then, but I'm
> quite happy with the state of my current patch branch, so it will
> be an additional patch instead of a brand new set of patches
> I think.

It has been a while since the most recent message in this thread.
May I know if you need any further help with the patch?

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



Re: fancy TODO lists setup (emacs 29.1)

2023-11-10 Thread Ihor Radchenko
Martin Steffen  writes:

> I have been using the todo functionality for quite a while. I also
> adapted it to my needs, for instance using multiple keywords, not just
> the simple cycle TODO -> DONE -> "nothing" additionally I use my
> personal "coloring" and other adaptations.
>
> When I upgraded my OS (from fedora 38 to 39) a few days ago, also emacs
> was upgraded (to 29.1, before it was some 28.x version). At any rate,
> the handling of the TODO-items no longer follows my choices. My settings
> for instance include
>
> ...
> but the cycle is the vanilla TODO->DONE->"nothing" cycle. The other
> status keywords, the ones I chose as extra, are not recognised and
> treated as todo-markings, and thus for instance also not specifically
> colored.

I am unable to reproduce using both stable and main branches.

> PS: My org version is Org mode version 9.5.2 (release_9.5.2-286-gd01235)

This is not the latest version of Org. You can try to upgrade.

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



Re: [BUG] org-resolve-clocks use of read-char-exclusive without telling EXWM to change the focus back to Emacs results in deadlock

2023-11-10 Thread Ihor Radchenko
SyedZuhair  writes:

> The deadlock happens if org-resolve-clocks is called automatically (for
> resolving idle time) while focus is in a EXWM-mode buffer. The
> result is that the focus is stuck with the EXWM-mode buffer away from
> Emacs and the user can not tell EXWM to change the focus to the
> mini-buffer to interact with org because org is grabbing all the input
> away from EXWM.
>
> The only way out for the user is to kill the application in EXWM buffer
> from another ttyn terminal to be able to interact with
> org-resolve-clocks.
>
> See the issue discussion here as well: 
> https://github.com/ch11ng/exwm/issues/921

There is a reason why we switched to `read-char-exclusive'. See
https://orgmode.org/list/87o82yaeie@gmail.com

I also do not see any reason why Org should not use
`read-char-exclusive' - the fact that EXWM does not support certain
Emacs primitives is not Org's problem, but a shortcoming of EXWM.

I would not mind changing `read-char-exclusive' to another equivalent if
that solves EXWM problem, but I am not aware about anything equivalent.
As you see in the above link, using `read-char' is not an option.

Not an Org bug.
Canceled.

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



Re: Issue with org-persist and Tramp

2023-11-10 Thread Ihor Radchenko
Fabio Natali  writes:

> On 2023-11-09, 12:17 +, Ihor Radchenko  wrote:
>> May I know what
>>(file-remote-p "/ssh::/home/user/test.org")
>> (with appropriate ) returns on your side?
>
> Hi Ihor,
>
> Sure, no particular reason to obfuscate the remote address, it's
> actually a LAN IP. The above function returns "/ssh:192.168.1.100:". Is
> that the kind of output one should be expecting? Anything wrong about
> it?

Nothing wrong. Just me missing one code branch.
What about the attached patch?

>From 73e2fc687b966f3c12b87dd40c90cdc6b9f440fc Mon Sep 17 00:00:00 2001
Message-ID: <73e2fc687b966f3c12b87dd40c90cdc6b9f440fc.1699608346.git.yanta...@posteo.net>
From: Ihor Radchenko 
Date: Wed, 8 Nov 2023 19:58:42 +0200
Subject: [PATCH v2] org-persist--normalize-associated: Avoid TRAMP connection
 for remote files

* lisp/org-persist.el (org-persist--normalize-associated): Never try
to store inode association for remote TRAMP files.

Reported-by: Fabio Natali 
Link: https://orgmode.org/list/87jzqthdge@fabionatali.com
---
 lisp/org-persist.el | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 81edcf6f2..bdc6006b6 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -614,9 +614,14 @@ (defun org-persist--normalize-associated (associated)
  (unless (stringp associated)
(setq associated (cadr associated)))
  (let* ((rtn `(:file ,associated))
-(inode (and (fboundp 'file-attribute-inode-number)
-(file-attribute-inode-number
- (file-attributes associated)
+(inode (and
+;; Do not store :inode for remote files - it may
+;; be time-consuming on slow connections or even
+;; fail completely when ssh connection is closed.
+(not (file-remote-p associated))
+(fboundp 'file-attribute-inode-number)
+(file-attribute-inode-number
+ (file-attributes associated)
(when inode (plist-put rtn :inode inode))
rtn))
 ((or (pred bufferp) `(:buffer ,_))
@@ -634,6 +639,10 @@ (defun org-persist--normalize-associated (associated)
  (or (buffer-base-buffer associated)
  associated)))
  (setq inode (when (and file
+;; Do not store :inode for remote files - it may
+;; be time-consuming on slow connections or even
+;; fail completely when ssh connection is closed.
+(not (file-remote-p associated))
 (fboundp 'file-attribute-inode-number))
(file-attribute-inode-number
 (file-attributes file
-- 
2.42.0


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