Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
On 7/3/23, Max Nikulin  wrote:
> On 04/07/2023 07:28, Samuel Wales wrote:
>> again i normally work with 1 window so i can have enough text.
>> sometimes i have a minuibffer.  the end.
>
>  8< 
> File Edit Options Buffers Tools Minibuf Help
>
> * title
> :PROPERTIES:
> :ID:   e69336ca-ca50-4535-9bad-63a31e030f31
> -UU-:F1  test.org2% L2 (Org) ---

for my purposes this window should remain, and be larger.

> Insert a link.
> Use TAB to complete link prefixes, then RET for type-specific compl$
>
> -UUU:**--F1  *Org Links*Top L1 (Fundamental)

this buffer contains nothing useful and shortens the above buffer.

---
> http:  https:
> id:id:e69336ca-ca50-4535-9bad-63a31e030f31
> info:  irc:
> mailto:mhe:
> news:  rmail:
> shell: title
> w3m:

these prefixes like http: i do not understand thier use.  i want
descriptions of headings.  the id link is not one.

>
>
>
>
> -UUU:%*--F1  *Completions*   Bot L10(Completion List)

i do not see the need for a buffer here.  it reduces the size of hte
buffer that matters.

-
> Link:
>  >8 
>
> Notice that "title" is present among the completion options.

title does not show in my case and nots ure the signiricance.  i use
large fonts.  that might or might nto be relevant.

> You may be
> upset, but org-insert-link works correctly. I have no idea why you

emotions are not germane and can carry unintended implications in a
laudably usually polite ml.  i am not upset.

i cannot do this kind of back and forth.  i am limited in computer use.

you used the word correct.  i would say that it is not correct for me.
i believe you if you say it is correct for you.

> customization throws away this completion variant.

you asked me to do -q.  i did -q.  are you saying i am customizeing
-q?  i am unaware of it if so.

everythign here has nothign t9o do with my .emacs.

>
>
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Max Nikulin

On 04/07/2023 07:28, Samuel Wales wrote:

again i normally work with 1 window so i can have enough text.
sometimes i have a minuibffer.  the end.


 8< 
File Edit Options Buffers Tools Minibuf Help 


* title
:PROPERTIES:
:ID:   e69336ca-ca50-4535-9bad-63a31e030f31
-UU-:F1  test.org2% L2 (Org) ---
Insert a link.
Use TAB to complete link prefixes, then RET for type-specific compl$

-UUU:**--F1  *Org Links*Top L1 (Fundamental) ---
http:  https:
id:id:e69336ca-ca50-4535-9bad-63a31e030f31
info:  irc:
mailto:mhe:
news:  rmail:
shell: title
w3m:




-UUU:%*--F1  *Completions*   Bot L10(Completion List) -
Link:
 >8 

Notice that "title" is present among the completion options. You may be 
upset, but org-insert-link works correctly. I have no idea why you 
customization throws away this completion variant.






Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
again i normally work with 1 window so i can have enough text.
sometimes i have a minuibffer.  the end.

On 7/3/23, Samuel Wales  wrote:
> the copletions window dos notc ontain the link dscription or a
> default.  there is no tdeafult listed in minibuffer or any tlink
> description.  so it is 1 orig buffer, which is saller and therefoere
> lss useful, 1 links buffer, which is useless beause does not show what
> i need, 1 copletions buffer which is useollss befause all it shows is
> url prefixes, and a minibuffer which shows nothing.
>
> On 7/3/23, Samuel Wales  wrote:
>> maybe most folk are ok with 3 windows + minibuffer.  this is not useful
>> to
>> me.
>>
>> On 7/3/23, Samuel Wales  wrote:
>>> please feel free to give up if that doesn't get it across.  i can't
>>> continue a bac and forth for unrelated reasons.
>>>
>>> On 7/3/23, Samuel Wales  wrote:
 scratch the expanded thing.

 it ends up showing orig smaller less useful, links uselessly
 boilerplate, completions -- 3 windows!  and a terse minibuffer i
 wouldn't be able to use.  -q.  i cannot use such a ui.

 in contrast, what i expected is orig, and then expanded minibuffer
 with, instead of doi: and so on, has useful links as descriotions.
 only 1 window, if you don't count minibuffer.

 On 7/3/23, Samuel Wales  wrote:
> defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
> completion imnibuffer.  not useful for me.
>
> On 7/3/23, Max Nikulin  wrote:
>> On 02/07/2023 13:03, Samuel Wales wrote:
>>> there is not supposed to be any connection between org refile or org
>>> goto with the code in org insert link.
>>>
>>> completion works to select ol paths for org refile and also for org
>>> refile when it is doing goto.  i just want the same for links.
>>
>> I am giving up my attempts to clarify a possible issue with
>> completion
>> by description in `org-insert-link'. It works for me.
>>
>>> On 7/1/23, Max Nikulin wrote:
 On 02/07/2023 12:02, Samuel Wales wrote:
> another window would not work for me but using completion as i do
> with
> e.g. refile goto would.

 Samuel, you claimed that completion by description does not work
 for
 `org-insert-link'. I expect that it is fixed in Org-9.6 since I do
 not
 see the issue with the default completion. It is the reason why I
 asked
 you to confirm that *default completion* works for you as well. I
 suspect that the cause of your problem is either ido or your
 customization.

 I see no connection of `org-refile' and `org-goto' with the code in
 `org-insert-link'.
>>
>>
>>
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


 --
 The Kafka Pandemic

 A blog about science, health, human rights, and misopathy:
 https://thekafkapandemic.blogspot.com

>>>
>>>
>>> --
>>> The Kafka Pandemic
>>>
>>> A blog about science, health, human rights, and misopathy:
>>> https://thekafkapandemic.blogspot.com
>>>
>>
>>
>> --
>> The Kafka Pandemic
>>
>> A blog about science, health, human rights, and misopathy:
>> https://thekafkapandemic.blogspot.com
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
the copletions window dos notc ontain the link dscription or a
default.  there is no tdeafult listed in minibuffer or any tlink
description.  so it is 1 orig buffer, which is saller and therefoere
lss useful, 1 links buffer, which is useless beause does not show what
i need, 1 copletions buffer which is useollss befause all it shows is
url prefixes, and a minibuffer which shows nothing.

On 7/3/23, Samuel Wales  wrote:
> maybe most folk are ok with 3 windows + minibuffer.  this is not useful to
> me.
>
> On 7/3/23, Samuel Wales  wrote:
>> please feel free to give up if that doesn't get it across.  i can't
>> continue a bac and forth for unrelated reasons.
>>
>> On 7/3/23, Samuel Wales  wrote:
>>> scratch the expanded thing.
>>>
>>> it ends up showing orig smaller less useful, links uselessly
>>> boilerplate, completions -- 3 windows!  and a terse minibuffer i
>>> wouldn't be able to use.  -q.  i cannot use such a ui.
>>>
>>> in contrast, what i expected is orig, and then expanded minibuffer
>>> with, instead of doi: and so on, has useful links as descriotions.
>>> only 1 window, if you don't count minibuffer.
>>>
>>> On 7/3/23, Samuel Wales  wrote:
 defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
 completion imnibuffer.  not useful for me.

 On 7/3/23, Max Nikulin  wrote:
> On 02/07/2023 13:03, Samuel Wales wrote:
>> there is not supposed to be any connection between org refile or org
>> goto with the code in org insert link.
>>
>> completion works to select ol paths for org refile and also for org
>> refile when it is doing goto.  i just want the same for links.
>
> I am giving up my attempts to clarify a possible issue with completion
> by description in `org-insert-link'. It works for me.
>
>> On 7/1/23, Max Nikulin wrote:
>>> On 02/07/2023 12:02, Samuel Wales wrote:
 another window would not work for me but using completion as i do
 with
 e.g. refile goto would.
>>>
>>> Samuel, you claimed that completion by description does not work for
>>> `org-insert-link'. I expect that it is fixed in Org-9.6 since I do
>>> not
>>> see the issue with the default completion. It is the reason why I
>>> asked
>>> you to confirm that *default completion* works for you as well. I
>>> suspect that the cause of your problem is either ido or your
>>> customization.
>>>
>>> I see no connection of `org-refile' and `org-goto' with the code in
>>> `org-insert-link'.
>
>
>
>


 --
 The Kafka Pandemic

 A blog about science, health, human rights, and misopathy:
 https://thekafkapandemic.blogspot.com

>>>
>>>
>>> --
>>> The Kafka Pandemic
>>>
>>> A blog about science, health, human rights, and misopathy:
>>> https://thekafkapandemic.blogspot.com
>>>
>>
>>
>> --
>> The Kafka Pandemic
>>
>> A blog about science, health, human rights, and misopathy:
>> https://thekafkapandemic.blogspot.com
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
maybe most folk are ok with 3 windows + minibuffer.  this is not useful to me.

On 7/3/23, Samuel Wales  wrote:
> please feel free to give up if that doesn't get it across.  i can't
> continue a bac and forth for unrelated reasons.
>
> On 7/3/23, Samuel Wales  wrote:
>> scratch the expanded thing.
>>
>> it ends up showing orig smaller less useful, links uselessly
>> boilerplate, completions -- 3 windows!  and a terse minibuffer i
>> wouldn't be able to use.  -q.  i cannot use such a ui.
>>
>> in contrast, what i expected is orig, and then expanded minibuffer
>> with, instead of doi: and so on, has useful links as descriotions.
>> only 1 window, if you don't count minibuffer.
>>
>> On 7/3/23, Samuel Wales  wrote:
>>> defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
>>> completion imnibuffer.  not useful for me.
>>>
>>> On 7/3/23, Max Nikulin  wrote:
 On 02/07/2023 13:03, Samuel Wales wrote:
> there is not supposed to be any connection between org refile or org
> goto with the code in org insert link.
>
> completion works to select ol paths for org refile and also for org
> refile when it is doing goto.  i just want the same for links.

 I am giving up my attempts to clarify a possible issue with completion
 by description in `org-insert-link'. It works for me.

> On 7/1/23, Max Nikulin wrote:
>> On 02/07/2023 12:02, Samuel Wales wrote:
>>> another window would not work for me but using completion as i do
>>> with
>>> e.g. refile goto would.
>>
>> Samuel, you claimed that completion by description does not work for
>> `org-insert-link'. I expect that it is fixed in Org-9.6 since I do
>> not
>> see the issue with the default completion. It is the reason why I
>> asked
>> you to confirm that *default completion* works for you as well. I
>> suspect that the cause of your problem is either ido or your
>> customization.
>>
>> I see no connection of `org-refile' and `org-goto' with the code in
>> `org-insert-link'.




>>>
>>>
>>> --
>>> The Kafka Pandemic
>>>
>>> A blog about science, health, human rights, and misopathy:
>>> https://thekafkapandemic.blogspot.com
>>>
>>
>>
>> --
>> The Kafka Pandemic
>>
>> A blog about science, health, human rights, and misopathy:
>> https://thekafkapandemic.blogspot.com
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
please feel free to give up if that doesn't get it across.  i can't
continue a bac and forth for unrelated reasons.

On 7/3/23, Samuel Wales  wrote:
> scratch the expanded thing.
>
> it ends up showing orig smaller less useful, links uselessly
> boilerplate, completions -- 3 windows!  and a terse minibuffer i
> wouldn't be able to use.  -q.  i cannot use such a ui.
>
> in contrast, what i expected is orig, and then expanded minibuffer
> with, instead of doi: and so on, has useful links as descriotions.
> only 1 window, if you don't count minibuffer.
>
> On 7/3/23, Samuel Wales  wrote:
>> defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
>> completion imnibuffer.  not useful for me.
>>
>> On 7/3/23, Max Nikulin  wrote:
>>> On 02/07/2023 13:03, Samuel Wales wrote:
 there is not supposed to be any connection between org refile or org
 goto with the code in org insert link.

 completion works to select ol paths for org refile and also for org
 refile when it is doing goto.  i just want the same for links.
>>>
>>> I am giving up my attempts to clarify a possible issue with completion
>>> by description in `org-insert-link'. It works for me.
>>>
 On 7/1/23, Max Nikulin wrote:
> On 02/07/2023 12:02, Samuel Wales wrote:
>> another window would not work for me but using completion as i do
>> with
>> e.g. refile goto would.
>
> Samuel, you claimed that completion by description does not work for
> `org-insert-link'. I expect that it is fixed in Org-9.6 since I do not
> see the issue with the default completion. It is the reason why I
> asked
> you to confirm that *default completion* works for you as well. I
> suspect that the cause of your problem is either ido or your
> customization.
>
> I see no connection of `org-refile' and `org-goto' with the code in
> `org-insert-link'.
>>>
>>>
>>>
>>>
>>
>>
>> --
>> The Kafka Pandemic
>>
>> A blog about science, health, human rights, and misopathy:
>> https://thekafkapandemic.blogspot.com
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
scratch the expanded thing.

it ends up showing orig smaller less useful, links uselessly
boilerplate, completions -- 3 windows!  and a terse minibuffer i
wouldn't be able to use.  -q.  i cannot use such a ui.

in contrast, what i expected is orig, and then expanded minibuffer
with, instead of doi: and so on, has useful links as descriotions.
only 1 window, if you don't count minibuffer.

On 7/3/23, Samuel Wales  wrote:
> defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
> completion imnibuffer.  not useful for me.
>
> On 7/3/23, Max Nikulin  wrote:
>> On 02/07/2023 13:03, Samuel Wales wrote:
>>> there is not supposed to be any connection between org refile or org
>>> goto with the code in org insert link.
>>>
>>> completion works to select ol paths for org refile and also for org
>>> refile when it is doing goto.  i just want the same for links.
>>
>> I am giving up my attempts to clarify a possible issue with completion
>> by description in `org-insert-link'. It works for me.
>>
>>> On 7/1/23, Max Nikulin wrote:
 On 02/07/2023 12:02, Samuel Wales wrote:
> another window would not work for me but using completion as i do with
> e.g. refile goto would.

 Samuel, you claimed that completion by description does not work for
 `org-insert-link'. I expect that it is fixed in Org-9.6 since I do not
 see the issue with the default completion. It is the reason why I asked
 you to confirm that *default completion* works for you as well. I
 suspect that the cause of your problem is either ido or your
 customization.

 I see no connection of `org-refile' and `org-goto' with the code in
 `org-insert-link'.
>>
>>
>>
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: [PATCH v2] Keep the link if the command was cancelled

2023-07-03 Thread Evgenii Klimov

Ihor Radchenko  writes:

> Evgenii Klimov  writes:
>
[...]
>> -(when (funcall (if (equal complete-file '(64)) 'not 'identity)
>> -   (not org-link-keep-stored-after-insertion))
>> -  (setq org-stored-links (delq (assoc link org-stored-links)
>> -   org-stored-links)))
>> -
>>  (when (and (string-match org-link-plain-re link)
>> (not (string-match org-ts-regexp link)))
>>;; URL-like link, normalize the use of angular brackets.
>> @@ -1995,6 +1990,10 @@ Use TAB to complete link prefixes, then RET for 
>> type-specific completion support
>>   (read-string "Description: " initial-input)
>> initial-input)))
>
> The code below the removed form can modify `link' variable. If such
> modification does happen, your patch will fail to remove the link from
> `org-stored-links' - (assoc link org-stored-links) will no longer return
> non-nil.

I added `link-original' variable to keep it intact until we want to
remove the link from `org-stored-links'.

>From a5ff8d4fe27fd503a6ddb719a622a980a73789a7 Mon Sep 17 00:00:00 2001
From: Evgenii Klimov 
Date: Fri, 30 Jun 2023 22:56:39 +0100
Subject: [PATCH] Keep the link if it was not inserted

* lisp/ol.el (org-insert-link): Keep the link in `org-stored-links' if
the command was interrupted by the user during the reading of a
description from the minibuffer.
---
 lisp/ol.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index e2bf90acd..1490bde86 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1820,7 +1820,7 @@ non-interactively, don't allow to edit the default description."
 	 (all-prefixes (append (mapcar #'car abbrevs)
 			   (mapcar #'car org-link-abbrev-alist)
 			   (org-link-types)))
- entry)
+ entry link-original)
 (cond
  (link-location)		  ; specified by arg, just use it.
  ((org-in-regexp org-link-bracket-re 1)
@@ -1896,11 +1896,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
   (or entry (push link org-link--insert-history))
   (setq desc (or desc (nth 1 entry)
 
-(when (funcall (if (equal complete-file '(64)) 'not 'identity)
-		   (not org-link-keep-stored-after-insertion))
-  (setq org-stored-links (delq (assoc link org-stored-links)
-   org-stored-links)))
-
+(setq link-original link)
 (when (and (string-match org-link-plain-re link)
 	   (not (string-match org-ts-regexp link)))
   ;; URL-like link, normalize the use of angular brackets.
@@ -1995,6 +1991,10 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
  (read-string "Description: " initial-input)
initial-input)))
 
+(when (funcall (if (equal complete-file '(64)) 'not 'identity)
+   (not org-link-keep-stored-after-insertion))
+  (setq org-stored-links (delq (assoc link-original org-stored-links)
+   org-stored-links)))
 (unless (org-string-nw-p desc) (setq desc nil))
 (when remove (apply #'delete-region remove))
 (insert (org-link-make-string link desc))
-- 
2.34.1



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
my reading was:

s> another window would not work for me but using completion as i do
with e.g. refile goto would

m> try again

s> creates another window.  ergo not work for me.

in fact, it is worse than that for me.  with my fonts, the links
window shows nothing useful on screen.  it is boilerplate.  orig is
smaller.  completion window -- not minibuffer -- shows bbdb: doi: and
other useless things.  the link i want to dinsert does not show in
either.  i would have to remember the link description then enter
that.  and learn a ew compoetion mechanism just for this one case?
not sure what you mean here  minibuffer says link.  unfamiliar
interface no flex no vertical no default of most recent stored.

On 7/3/23, Samuel Wales  wrote:
> defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
> completion imnibuffer.  not useful for me.
>
> On 7/3/23, Max Nikulin  wrote:
>> On 02/07/2023 13:03, Samuel Wales wrote:
>>> there is not supposed to be any connection between org refile or org
>>> goto with the code in org insert link.
>>>
>>> completion works to select ol paths for org refile and also for org
>>> refile when it is doing goto.  i just want the same for links.
>>
>> I am giving up my attempts to clarify a possible issue with completion
>> by description in `org-insert-link'. It works for me.
>>
>>> On 7/1/23, Max Nikulin wrote:
 On 02/07/2023 12:02, Samuel Wales wrote:
> another window would not work for me but using completion as i do with
> e.g. refile goto would.

 Samuel, you claimed that completion by description does not work for
 `org-insert-link'. I expect that it is fixed in Org-9.6 since I do not
 see the issue with the default completion. It is the reason why I asked
 you to confirm that *default completion* works for you as well. I
 suspect that the cause of your problem is either ido or your
 customization.

 I see no connection of `org-refile' and `org-goto' with the code in
 `org-insert-link'.
>>
>>
>>
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Samuel Wales
defait cp[;etopm immediately makes 2 windows [orig+links] + expanded
completion imnibuffer.  not useful for me.

On 7/3/23, Max Nikulin  wrote:
> On 02/07/2023 13:03, Samuel Wales wrote:
>> there is not supposed to be any connection between org refile or org
>> goto with the code in org insert link.
>>
>> completion works to select ol paths for org refile and also for org
>> refile when it is doing goto.  i just want the same for links.
>
> I am giving up my attempts to clarify a possible issue with completion
> by description in `org-insert-link'. It works for me.
>
>> On 7/1/23, Max Nikulin wrote:
>>> On 02/07/2023 12:02, Samuel Wales wrote:
 another window would not work for me but using completion as i do with
 e.g. refile goto would.
>>>
>>> Samuel, you claimed that completion by description does not work for
>>> `org-insert-link'. I expect that it is fixed in Org-9.6 since I do not
>>> see the issue with the default completion. It is the reason why I asked
>>> you to confirm that *default completion* works for you as well. I
>>> suspect that the cause of your problem is either ido or your
>>> customization.
>>>
>>> I see no connection of `org-refile' and `org-goto' with the code in
>>> `org-insert-link'.
>
>
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: [PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands

2023-07-03 Thread Evgenii Klimov


Ihor Radchenko  writes:

[...]
>> +individual commands for more information.
>> +
>> +This function runs the hook `org-shiftmetaleft-hook' as a first
>> +step, `org-shiftmetaleft-final-hook' as the penultimate step, and
>> +returns at first non-nil value."
>
> Upon looking closer, I realized that you also defined return value of
> the function here.  Is there any particular reason for this? The return
> value is currently not defined and supposed to be discarded.

Maybe I got it wrong, but I tried to follow the docstring for
`org-metaleft'. And I don't see here the use of the return value either:

#+begin_example
  (defun org-metaleft ( _arg)
"...
This function runs the hook `org-metaleft-hook' as a first step,
and returns at first non-nil value."
...)
#+end_example

Should I keep it like this?
  This function runs the hook `org-shiftmetaleft-hook' as a first
  step, and `org-shiftmetaleft-final-hook' as the penultimate step.



Re: org babel output

2023-07-03 Thread Matt


  On Sat, 01 Jul 2023 05:52:42 +0200  Robert Synofzik  wrote --- 
 > Hello,
 > the exact same error occurs for me: 
 > https://emacs.stackexchange.com/questions/72243/macos-org-babel-python-with-session-output-give-python-el-eval
 >
 > do you possibly have any idea on how to fix this?
 
Just to check, because you didn't explicitly say it in your message, does the 
solution given in the StackExchange not work for you?  That is, do you get a 
different result when you name the session?  What happens when you run the 
following?

#+begin_src python :session my-named-session :results output
print("yes")
#+end_src



Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Ihor Radchenko
Evgenii Klimov  writes:

>> If necessary, removing stored links without inserting can be made as an
>> effect of negative prefix argument in `org-insert-link' or in
>> `org-insert-all-links'.
>
> I tried `org-insert-link' with the negative prefix argument, but the
> link was inserted though.
>
> And this behaviour is not mentioned in the docstring.

This behaviour is not there. I just said that we can add it to Org, if
necessary. What Max described should not stop this patch from being
merged.

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



Re: [FR] Enhancing footnote managment (via indirect buffer)?

2023-07-03 Thread Ihor Radchenko
Andrea Lazzarini  writes:

> I was busy with work and had less time to focus on this, sorry!

No problem. Just wanted to make sure that this thread did not fall
through the cracks.

> Well, sorry for the noob question but how do you suggest I fork the org.el 
> file to start tinkering with it?
> I would pass through the Org repository on Savannah, as specified here: 
> https://orgmode.org/worg/org-contribute.html 
> .

You can just use git version of Org:
https://orgmode.org/manual/Installation.html

Then, you can edit the files directly there.

> What do you suggest for testing the changes? Should I then send a diff?

Depends on your familiarity with git.
The easiest for us would be attaching a patch, but you can also send a
diff, if it is easier for you.
We have all the details in
https://orgmode.org/worg/org-contribute.html#org0d9c39b

You can also use Magit (https://www.youtube.com/watch?v=7ywEgcbaiys).

> I guess I can manage to have the code I already produced working in org.el. 
> In what section of it should the eldoc package be required?

The eldoc setup should be somewhere inside

  (define-derived-mode org-mode outline-mode "Org"


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



Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Evgenii Klimov


Ihor Radchenko  writes:

> Max Nikulin  writes:
[...]
>> I had it in mind when I was writing my message. I had even tried to find 
>> another command that allows to remove stored links.
>
> If necessary, removing stored links without inserting can be made as an
> effect of negative prefix argument in `org-insert-link' or in
> `org-insert-all-links'.

I tried `org-insert-link' with the negative prefix argument, but the
link was inserted though.

And this behaviour is not mentioned in the docstring.



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Ihor Radchenko
Fionn Stephens  writes:

> Thanks a million. I didn't know you could do that.

Good that src blocks are good enough for your usage.
Closed.

> And apologies all for the bad email formatting, I'll try to change it to 
> plain text.

I think your emails do have plain text parts as well, so they should be fine.

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



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Ihor Radchenko
Fionn Stephens  writes:

> And this is a LaTeX package that can create screenplays: 
> https://ctan.org/pkg/screenplay?lang=en. 
>
> The Fountain Mode in emacs can use different backends, but I use 
> Afterwriting: https://afterwriting.com/. 

These two appear to produce full document, not fragments.
Typesetting fragments might be more tricky.

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



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Ihor Radchenko
Christian Moe  writes:

> To my mind, Org should not support every kind of markup/markdown format
> there is, but to the extent Fountain is the best format for screenplays,
> and Org is good for organizing bits of screenplays, I think maybe using
> Org-babel src blocks is the way to go?

I mostly agree, but wouldn't it be nice to support something other than
just LaTeX fragments? That's why I was asking about more details.

> Even without a dedicated ob-fountain package to support it, it can be
> used today for tangling screenplays from blocks of Fountain format with
> noweb syntax, editing blocks in fountain-mode, some limited syntax
> highlighting etc.

Sure. It is not exactly same with what Fionn asked for though.

Also, syntax highlighting in fountain src blocks should work with
engrave-faces.

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



Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Evgenii Klimov


Ihor Radchenko  writes:
> Evgenii Klimov  writes:
>> ...
>
> This makes sense, but the patch may break removing stored link in
> certain scenarios.

Thanks for response, I'll look into this issue and try to avoid this
breakage.



Re: [FR] Enhancing footnote managment (via indirect buffer)?

2023-07-03 Thread Andrea Lazzarini

> Il giorno 2 lug 2023, alle ore 12:56, Ihor Radchenko  ha 
> scritto:
> 
> Hello,
> 
> It has been over one month since the last message in this thread.
> Are you still interested to work on this feature? Do you need any help?


Hi,

I was busy with work and had less time to focus on this, sorry!
Well, sorry for the noob question but how do you suggest I fork the org.el file 
to start tinkering with it?
I would pass through the Org repository on Savannah, as specified here: 
https://orgmode.org/worg/org-contribute.html 
.
What do you suggest for testing the changes? Should I then send a diff?

I guess I can manage to have the code I already produced working in org.el. In 
what section of it should the eldoc package be required?

Thank you so much.

Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Ihor Radchenko
Max Nikulin  writes:

>> This argument sounds like https://xkcd.com/1172/ to me.
>
> I had it in mind when I was writing my message. I had even tried to find 
> another command that allows to remove stored links.

If necessary, removing stored links without inserting can be made as an
effect of negative prefix argument in `org-insert-link' or in
`org-insert-all-links'.

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



Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Max Nikulin

On 03/07/2023 22:11, Ihor Radchenko wrote:

Max Nikulin writes:


Sometimes I am using it as a feature to remove a link stored by mistake
or due to ...


This argument sounds like https://xkcd.com/1172/ to me.


I had it in mind when I was writing my message. I had even tried to find 
another command that allows to remove stored links.





Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Ihor Radchenko
Max Nikulin  writes:

> Sometimes I am using it as a feature to remove a link stored by mistake 
> or due to ...

This argument sounds like https://xkcd.com/1172/ to me.
It is unexpected and undocumented that not inserting the link, but
stopping in the middle removes it from the store list.

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



Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Max Nikulin

On 03/07/2023 19:48, Ihor Radchenko wrote:

Evgenii Klimov writes:


* lisp/ol.el (org-insert-link): Keep the link in `org-stored-links' if
the command was interrupted by the user during the reading of a
description from the minibuffer.
---
Currently the link is lost if the user chooses the link but cancells
the comand while writing the description.


This makes sense


Sometimes I am using it as a feature to remove a link stored by mistake 
or due to


Max Nikulin. [Bug] org-insert-link removes on one link from 2 added by 
org-store-link. Sun, 2 Jul 2023 13:08:18 +0700.

https://list.orgmode.org/u7r48j$9oo$1...@ciao.gmane.io

On the other hand it is still possible to call undo after a link is 
inserted.




Re: org-insert-link completion by description (Re: what is the purpose of "This link has already been stored"?)

2023-07-03 Thread Max Nikulin

On 02/07/2023 13:03, Samuel Wales wrote:

there is not supposed to be any connection between org refile or org
goto with the code in org insert link.

completion works to select ol paths for org refile and also for org
refile when it is doing goto.  i just want the same for links.


I am giving up my attempts to clarify a possible issue with completion 
by description in `org-insert-link'. It works for me.



On 7/1/23, Max Nikulin wrote:

On 02/07/2023 12:02, Samuel Wales wrote:

another window would not work for me but using completion as i do with
e.g. refile goto would.


Samuel, you claimed that completion by description does not work for
`org-insert-link'. I expect that it is fixed in Org-9.6 since I do not
see the issue with the default completion. It is the reason why I asked
you to confirm that *default completion* works for you as well. I
suspect that the cause of your problem is either ido or your customization.

I see no connection of `org-refile' and `org-goto' with the code in
`org-insert-link'.






Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Fionn Stephens
Thanks a million. I didn't know you could do that.

And apologies all for the bad email formatting, I'll try to change it to plain 
text.

Fionn






--- Original Message ---
On Monday, July 3rd, 2023 at 2:53 PM, Bruno Cardoso  
wrote:


> On 2023-07-03, 13:00 +, Fionn Stephens fionnsteph...@protonmail.com wrote:
> 
> > Hi,
> > 
> > I think support for screenplay formatting would be a useful feature to add. 
> > Like to how comments or quotes are done, it could be in between the tags: 
> > #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown used by 
> > Fountain would make the most sense.
> > 
> > For example, a section could look like:
> > 
> > #+BEGIN_SCREENPLAY
> > INT./EXT. BLOOM HOUSE - (PRESENT) DAY
> > 
> > The front door opens to reveal Will and Josephine on the porch with their 
> > bags. REVERSE to Will's mother Sandra (53), surprised and a little annoyed.
> > 
> > SANDRA
> > How did you get here?
> > 
> > WILL
> > We swam. The Atlantic, it's not that big really.
> > #+END_SCREENPLAY
> > 
> > Thanks,Fionn Stephens
> 
> 
> Hi. You can use org-blocks like this with fountain-mode:
> 
> - https://github.com/rnkn/fountain-mode
> 
> #+begin_src fountain
> INT./EXT. BLOOM HOUSE - (PRESENT) DAY
> 
> The front door opens to reveal Will and Josephine on the porch with their 
> bags. REVERSE to
> Will's mother Sandra (53), surprised and a little annoyed.
> 
> SANDRA
> How did you get here?
> 
> WILL
> We swam. The Atlantic, it's not that big really.
> #+end_src
> 
> 
> Best,
> 
> Bruno.



Re: [PATCH] lisp/org-id.el: Add new relative timestamp feature for `ts' `org-id-method'

2023-07-03 Thread Kierin Bell
Ihor Radchenko  writes:

> It has been over one month since the last email in this thread.
> May I know if you had a chance to work on your patch any further?

Hello,
I have made some progress, and I should have some time soon to finalize
and submit version 2.

Thanks!

-- 
Kierin Bell
GPG Key: FCF2 5F08 EA4F 2E3D C7C3  0D41 D14A 8CD3 2D97 0B36



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Fionn Stephens
I just found a python package that can convert fountain markdown to LaTeX: 
https://pypi.org/project/fountain/. 

And this is a LaTeX package that can create screenplays: 
https://ctan.org/pkg/screenplay?lang=en. 

The Fountain Mode in emacs can use different backends, but I use Afterwriting: 
https://afterwriting.com/. 






--- Original Message ---
On Monday, July 3rd, 2023 at 2:51 PM, Ihor Radchenko  
wrote:


> [ Adding Org ML back to CC. Please use Reply All or wide reply to keep
> other mailing list members in the loop. ]
> 
> > The industry standard is to use Final Draft 
> > (https://en.wikipedia.org/wiki/Final_Draft_(software)), but I personally 
> > use Emacs Fountain Mode (https://www.emacswiki.org/emacs/FountainMode). 
> > Fountain is a plain text markup language (https://fountain.io/).
> > 
> > I'm interested in exporting to PDF and to odt format.
> 
> 
> How do you usually export to fountain PDF?
> Org mode relies on LaTeX to produce PDF output. Is it possible to have
> Fountain blocks in LaTeX?
> 
> Fionn Stephens fionnsteph...@protonmail.com writes:
> 
> > Hi,
> > 
> > Yes, of course. A screenplay is the document written to help produce a film 
> > or TV series. This is the Wikipedia page: 
> > https://en.wikipedia.org/wiki/Screenplay and here are some examples: 
> > https://www.scriptreaderpro.com/screenplay-example/.
> > 
> > The industry standard is to use Final Draft 
> > (https://en.wikipedia.org/wiki/Final_Draft_(software)), but I personally 
> > use Emacs Fountain Mode (https://www.emacswiki.org/emacs/FountainMode). 
> > Fountain is a plain text markup language (https://fountain.io/).
> > 
> > I'm interested in exporting to PDF and to odt format.
> > 
> > My own use case is a little experimental with some sections written like a 
> > screenplay and other sections written like a novel / short story.
> > 
> > I hope that helps.
> > Fionn
> > 
> > Sent with Proton Mail secure email.
> > 
> > --- Original Message ---
> > On Monday, July 3rd, 2023 at 2:07 PM, Ihor Radchenko yanta...@posteo.net 
> > wrote:
> > 
> > > Fionn Stephens fionnsteph...@protonmail.com writes:
> > > 
> > > > I think support for screenplay formatting would be a useful feature to 
> > > > add. Like to how comments or quotes are done, it could be in between 
> > > > the tags: #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the 
> > > > markdown used by Fountain would make the most sense.
> > > > 
> > > > For example, a section could look like:
> > > > 
> > > > #+BEGIN_SCREENPLAY
> > > > INT./EXT. BLOOM HOUSE - (PRESENT) DAY
> > > > ...
> > > 
> > > May you please elaborate? What is screenplay? Is it a markup format?
> > > What do you mean by support? Export? Font-lock? Something else?
> > > 
> > > --
> > > Ihor Radchenko // yantar92,
> > > Org mode contributor,
> > > Learn more about Org mode at https://orgmode.org/.
> > > 
> > > Support Org development at https://liberapay.com/org-mode,
> > > 
> > > or support my work at https://liberapay.com/yantar92
> 
> 
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at https://orgmode.org/.
> 
> Support Org development at https://liberapay.com/org-mode,
> 
> or support my work at https://liberapay.com/yantar92



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Christian Moe




Ihor Radchenko writes:

> Fionn Stephens  writes:
>
>> I think support for screenplay formatting would be a useful feature to add. 
>> Like to how comments or quotes are done, it could be in between the tags: 
>> #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown used by 
>> Fountain would make the most sense.
>>
>> For example, a section could look like:
>>
>> #+BEGIN_SCREENPLAY
>> INT./EXT. BLOOM HOUSE - (PRESENT) DAY
>> ...
>
> May you please elaborate? What is screenplay? Is it a markup format?
> What do you mean by support? Export? Font-lock? Something else?

Fountain is a Markdown-inspired plain text format for screenplays
(https://fountain.io/).

There exists a fountain-mode major mode for Emacs.

To my mind, Org should not support every kind of markup/markdown format
there is, but to the extent Fountain is the best format for screenplays,
and Org is good for organizing bits of screenplays, I think maybe using
Org-babel src blocks is the way to go?

Even without a dedicated ob-fountain package to support it, it can be
used today for tangling screenplays from blocks of Fountain format with
noweb syntax, editing blocks in fountain-mode, some limited syntax
highlighting etc.

Yours,
Christian



Re: Cache must be active error

2023-07-03 Thread Colin Baxter
> Ihor Radchenko  writes:

> Colin Baxter  writes:
>> 1. emacs -q  2. eval in scratch buffer (add-to-list
>> 'load-path (expand-file-name "~/path/to/git/org-mode/lisp"))
>> 3. M-x org-agenda  4. Enter m 5. "Cache must be active" now
>> appears in echo area
>> 
>> Am I seeing a new git/org-mode feature or a bug?

> A can reproduce.  Fixed, on main.

Confirmed. Thank you very much for this.

Colin Baxter.



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Bruno Cardoso


On 2023-07-03, 13:00 +, Fionn Stephens  wrote:

> Hi,
>
> I think support for screenplay formatting would be a useful feature to add. 
> Like to how comments or quotes are done, it could be in between the tags: 
> #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown used by 
> Fountain would make the most sense.
>
> For example, a section could look like:
>
> #+BEGIN_SCREENPLAY
> INT./EXT. BLOOM HOUSE - (PRESENT) DAY
>
> The front door opens to reveal Will and Josephine on the porch with their 
> bags. REVERSE to Will's mother Sandra (53), surprised and a little annoyed.
>
> SANDRA
> How did you get here?
>
> WILL
> We swam. The Atlantic, it's not that big really.
> #+END_SCREENPLAY
>
> Thanks,Fionn Stephens

Hi. You can use org-blocks like this with fountain-mode:

- https://github.com/rnkn/fountain-mode

#+begin_src fountain
INT./EXT. BLOOM HOUSE - (PRESENT) DAY

The front door opens to reveal Will and Josephine on the porch with their bags. 
REVERSE to
Will's mother Sandra (53), surprised and a little annoyed.

SANDRA
How did you get here?

WILL
We swam. The Atlantic, it's not that big really.
#+end_src


Best,

Bruno.



Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]

2023-07-03 Thread Sébastien Miquel


Ihor Radchenko writes:

For the second scenario, no special treatment of current line is needed.
For the first scenario, why do we need to do it all the way in
`org-src--contents-for-write-back'? Why not directly in
`org-indent-line'?


Ah, yes, that is much better.

--
Sébastien MiquelFrom 9d31a71bc0ab7cfd466ecad60037d00c62bdd9f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= 
Date: Tue, 27 Jun 2023 09:23:01 +0200
Subject: [PATCH] org-src.el: Use native value of `indent-tabs-mode' for
 indentation

* lisp/org.el (org-indent-line): Simplify native indentation inside
src block.  Ensure we add the org indentation if the line is empty.
* lisp/org-macs.el (org-do-remove-indentation): Preserve
indentation (spaces vs tabs) past the common indentation to remove.
Do not empty blank lines.
* lisp/org-src.el (org-src--contents-for-write-back): Preserve the
native indentation (spaces vs tabs).  If necessary, add a common org
indentation to the block according to org's `indent-tabs-mode'.
(org-src-font-lock-fontify-block): In case of mixed indentation,
display the tab characters with a fixed width, according to the native
tab width value.
* testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update
tests.  Indentation no longer obeys `indent-tabs-mode' from the org
buffer, but is separated in two parts.
---
 lisp/org-macs.el |  9 +++--
 lisp/org-src.el  | 52 ++---
 lisp/org.el  | 23 ---
 testing/lisp/test-org-src.el | 75 ++--
 4 files changed, 89 insertions(+), 70 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 51dbfe118..ea210dc60 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -483,9 +483,12 @@ line.  Return nil if it fails."
 (when skip-fl (forward-line))
 	(while (not (eobp))
 	  (let ((ind (progn (skip-chars-forward " \t") (current-column
-	(cond ((eolp) (delete-region (line-beginning-position) (point)))
-		  ((< ind n) (throw :exit nil))
-		  (t (indent-line-to (- ind n
+	(cond ((< ind n)
+   (if (eolp) (delete-region (line-beginning-position) (point))
+ (throw :exit nil)))
+		  (t (delete-region (line-beginning-position)
+(progn (move-to-column n t)
+   (point)
 	(forward-line)))
 	;; Signal success.
 	t
diff --git a/lisp/org-src.el b/lisp/org-src.el
index f15ba8e99..2beb49e63 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -318,9 +318,6 @@ is 0.")
   "File name associated to Org source buffer, or nil.")
 (put 'org-src-source-file-name 'permanent-local t)
 
-(defvar-local org-src--preserve-blank-line nil)
-(put 'org-src--preserve-blank-line 'permanent-local t)
-
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer.
 Format is \"*Org Src ORG-BUFFER-NAME[ LANG ]*\"."
@@ -473,12 +470,15 @@ Assume point is in the corresponding edit buffer."
  (list (buffer-substring (point-min) eol)
(buffer-substring eol (point-max))
 	(write-back org-src--allow-write-back)
-(preserve-blank-line org-src--preserve-blank-line)
-marker)
+marker indent-str)
+(setq indent-str
+  (with-temp-buffer
+;; Reproduce indentation parameters from org buffer.
+(setq indent-tabs-mode use-tabs?)
+(when (> source-tab-width 0) (setq tab-width source-tab-width))
+(indent-to indentation-offset)
+(buffer-string)))
 (with-current-buffer write-back-buf
-  ;; Reproduce indentation parameters from source buffer.
-  (setq indent-tabs-mode use-tabs?)
-  (when (> source-tab-width 0) (setq tab-width source-tab-width))
   ;; Apply WRITE-BACK function on edit buffer contents.
   (insert (org-no-properties (car contents)))
   (setq marker (point-marker))
@@ -488,15 +488,11 @@ Assume point is in the corresponding edit buffer."
   ;; Add INDENTATION-OFFSET to every line in buffer,
   ;; unless indentation is meant to be preserved.
   (when (> indentation-offset 0)
-	(when preserve-fl (forward-line))
+;; LaTeX-fragments are inline. Do not add indentation to their
+;; first line.
+(when preserve-fl (forward-line))
 (while (not (eobp))
-	  (skip-chars-forward " \t")
-  (when (or (not (eolp))   ; not a blank line
-(and (eq (point) (marker-position marker)) ; current line
- preserve-blank-line))
-	(let ((i (current-column)))
-	  (delete-region (line-beginning-position) (point))
-	  (indent-to (+ i indentation-offset
+  (when (not (eolp)) (insert indent-str)) ; not an empty line
 	  (forward-line)))
   (set-marker marker nil
 
@@ -549,11 +545,6 @@ Leave point in edit 

Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Ihor Radchenko
[ Adding Org ML back to CC. Please use Reply All or wide reply to keep
  other mailing list members in the loop. ]

> The industry standard is to use Final Draft 
> (https://en.wikipedia.org/wiki/Final_Draft_(software)), but I personally use 
> Emacs Fountain Mode (https://www.emacswiki.org/emacs/FountainMode). Fountain 
> is a plain text markup language (https://fountain.io/).
>
> I'm interested in exporting to PDF and to odt format. 

How do you usually export to fountain PDF?
Org mode relies on LaTeX to produce PDF output. Is it possible to have
Fountain blocks in LaTeX?

Fionn Stephens  writes:

> Hi,
>
> Yes, of course. A screenplay is the document written to help produce a film 
> or TV series. This is the Wikipedia page: 
> https://en.wikipedia.org/wiki/Screenplay and here are some examples: 
> https://www.scriptreaderpro.com/screenplay-example/.
>
> The industry standard is to use Final Draft 
> (https://en.wikipedia.org/wiki/Final_Draft_(software)), but I personally use 
> Emacs Fountain Mode (https://www.emacswiki.org/emacs/FountainMode). Fountain 
> is a plain text markup language (https://fountain.io/).
>
> I'm interested in exporting to PDF and to odt format. 
>
> My own use case is a little experimental with some sections written like a 
> screenplay and other sections written like a novel / short story.
>
> I hope that helps.
> Fionn
>
>
>
>
> Sent with Proton Mail secure email.
>
> --- Original Message ---
> On Monday, July 3rd, 2023 at 2:07 PM, Ihor Radchenko  
> wrote:
>
>
>> Fionn Stephens fionnsteph...@protonmail.com writes:
>> 
>> > I think support for screenplay formatting would be a useful feature to 
>> > add. Like to how comments or quotes are done, it could be in between the 
>> > tags: #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown 
>> > used by Fountain would make the most sense.
>> > 
>> > For example, a section could look like:
>> > 
>> > #+BEGIN_SCREENPLAY
>> > INT./EXT. BLOOM HOUSE - (PRESENT) DAY
>> > ...
>> 
>> 
>> May you please elaborate? What is screenplay? Is it a markup format?
>> What do you mean by support? Export? Font-lock? Something else?
>> 
>> --
>> Ihor Radchenko // yantar92,
>> Org mode contributor,
>> Learn more about Org mode at https://orgmode.org/.
>> 
>> Support Org development at https://liberapay.com/org-mode,
>> 
>> or support my work at https://liberapay.com/yantar92

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



Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Liu Hui
Ihor Radchenko  于2023年7月3日周一 19:41写道:

> This already works, even without the patch.

Yes. It means the patch doesn't break current usage.

> > In this case, `graphics' can be removed too.
>
> May you elaborate?
>
> #+begin_src python :results file
> implies that the result of execution is file _contents_.

It is consistent with current behavior, e.g. `:results file' is used
to produce graphics file
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html

> This is not acceptable. If src blocks worked in the past, they should
> continue working without adjustments in user' setup. We can only break
> backwards-compatibility when there is a strong reason to do so. Adding a
> new feature is not such a reason.

Any src blocks worked in the past still work with this patch, without
any adjustments. The patch only makes the following src block, which
cannot produce `test.png' in the past, can produce `test.png'.

#+begin_src python :file "test.png" :results graphics file
import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5])
#+end_src



Re: [FR] Please add support for screenplay formatting

2023-07-03 Thread Ihor Radchenko
Fionn Stephens  writes:

> I think support for screenplay formatting would be a useful feature to add. 
> Like to how comments or quotes are done, it could be in between the tags: 
> #+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown used by 
> Fountain would make the most sense.
>
> For example, a section could look like:
>
> #+BEGIN_SCREENPLAY
> INT./EXT. BLOOM HOUSE - (PRESENT) DAY
> ...

May you please elaborate? What is screenplay? Is it a markup format?
What do you mean by support? Export? Font-lock? Something else?

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



Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]

2023-07-03 Thread Ihor Radchenko
Sébastien Miquel  writes:

>> May you please provide an example when it is necessary?
>> `org-indent-line' will run `org-babel-do-key-sequence-in-edit-buffer', so
>> it should still use `org-src--contents-for-write-back' and will not
>> modify the org buffer text directly.
>
> You're at the end of a line, you press =org-return-and-indent=.
>   1. It adds a newline character.
>   2. =org-indent-line= adds the org indentation, _before_ calling
>  =org-babel-do-key-sequence-in-edit-buffer=

I missed this:

 ;; At the beginning of a blank line, do some preindentation.  This
 ;; signals org-src--edit-element to preserve the indentation on 
exit

>   3. The native edit call removes the common indentation, before
>  calling tab in the native buffer.
>   4. Calling tab in the native buffer possibly does nothing.
>   5. =org-src--contents-for-write-back= sees the current line is empty,
>  but it should indent it (with org indentation) nonetheless.

Ok. I understand better now (I think).

We are talking about

\t#+begin_src bash
\tcd foo
\t#+end_src

and user pressing 
Then, the expected result is

\t#+begin_src bash
\tcd foo
\t
\t#+end_src

with  being aligned with "cd foo" above.

Alternatively,

\t#+begin_src emacs-lisp
\t(when t
\t#+end_src

 should yield indentation in src block as well

\t#+begin_src emacs-lisp
\t(when t
\t  
\t#+end_src

-

For the second scenario, no special treatment of current line is needed.
For the first scenario, why do we need to do it all the way in
`org-src--contents-for-write-back'? Why not directly in
`org-indent-line'?

>> Before your change, all the blank non-empty lines were unconditionally
>> removed. After your change, the first such line is removed and the
>> function returns nil without continuing.
>
> I don't understand. With this change, the function only stops if it
> finds a non blank line with less than n indentation (same as before).
> When a blank line with less than n indentation is found, it is emptied
> (same as before), and execution continues.

Never mind this. I misread the code. Thought that `throw' is called on
blank lines.

>> Since not removing blank lines is intentional after the change, why
>> doing it on a single line that is indented less than N?
>
> Are you advocating for computing N using blank lines as well ?

No. It was a misunderstanding.

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



[FR] Please add support for screenplay formatting

2023-07-03 Thread Fionn Stephens
Hi,

I think support for screenplay formatting would be a useful feature to add. 
Like to how comments or quotes are done, it could be in between the tags: 
#+BEGIN_SCREENPLAY and #+END_SCREENPLAY. I think using the markdown used by 
Fountain would make the most sense.

For example, a section could look like:

#+BEGIN_SCREENPLAY
INT./EXT. BLOOM HOUSE - (PRESENT) DAY

The front door opens to reveal Will and Josephine on the porch with their bags. 
REVERSE to Will's mother Sandra (53), surprised and a little annoyed.

SANDRA
How did you get here?

WILL
We swam. The Atlantic, it's not that big really.
#+END_SCREENPLAY

Thanks,Fionn Stephens

Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]

2023-07-03 Thread Sébastien Miquel



Ihor Radchenko writes:

What happens is: in the org buffer, the line is not empty, because it
has the org indentation (which was possibly just added by
org-indent-line), but in the edit buffer, the line is empty, because
the common org indentation was removed. In that case, we want to add
back the org indentation.


May you please provide an example when it is necessary?
`org-indent-line' will run `org-babel-do-key-sequence-in-edit-buffer', so
it should still use `org-src--contents-for-write-back' and will not
modify the org buffer text directly.


You're at the end of a line, you press =org-return-and-indent=.
 1. It adds a newline character.
 2. =org-indent-line= adds the org indentation, _before_ calling
=org-babel-do-key-sequence-in-edit-buffer=
 3. The native edit call removes the common indentation, before
calling tab in the native buffer.
 4. Calling tab in the native buffer possibly does nothing.
 5. =org-src--contents-for-write-back= sees the current line is empty,
but it should indent it (with org indentation) nonetheless.



--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -483,9 +483,12 @@ line.  Return nil if it fails."
  (when skip-fl (forward-line))
(while (not (eobp))
  (let ((ind (progn (skip-chars-forward " \t") (current-column
-   (cond ((eolp) (delete-region (line-beginning-position) (point)))
- ((< ind n) (throw :exit nil))
- (t (indent-line-to (- ind n
+   (cond ((< ind n)
+   (if (eolp) (delete-region (line-beginning-position) (point))
+ (throw :exit nil)))


This function is actually confusing both before and after the change.
According to the docstring:

 When optional argument N is a positive integer, remove exactly
 that much characters from indentation, if possible.

But the function can actually remove less than N characters.

Before your change, all the blank non-empty lines were unconditionally
removed. After your change, the first such line is removed and the
function returns nil without continuing.


I don't understand. With this change, the function only stops if it
finds a non blank line with less than n indentation (same as before).
When a blank line with less than n indentation is found, it is emptied
(same as before), and execution continues.


* lisp/org-macs.el (org-do-remove-indentation): Preserve
indentation (spaces vs tabs) past the common indentation to remove.
Do not empty blank lines.


Since not removing blank lines is intentional after the change, why
doing it on a single line that is indented less than N?


Are you advocating for computing N using blank lines as well ?

 1. It isn't consistent with the previous behaviour.
 2. If I mistakenly add a space to an empty line in a src block, an
edit-special round trip will add indentation to every line.

Is there any benefit ?

--
Sébastien Miquel



Re: [PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Ihor Radchenko
Evgenii Klimov  writes:

> * lisp/ol.el (org-insert-link): Keep the link in `org-stored-links' if
> the command was interrupted by the user during the reading of a
> description from the minibuffer.
> ---
> Currently the link is lost if the user chooses the link but cancells
> the comand while writing the description.

Thanks!
This makes sense, but the patch may break removing stored link in
certain scenarios.

> -(when (funcall (if (equal complete-file '(64)) 'not 'identity)
> -(not org-link-keep-stored-after-insertion))
> -  (setq org-stored-links (delq (assoc link org-stored-links)
> -org-stored-links)))
> -
>  (when (and (string-match org-link-plain-re link)
>  (not (string-match org-ts-regexp link)))
>;; URL-like link, normalize the use of angular brackets.
> @@ -1995,6 +1990,10 @@ Use TAB to complete link prefixes, then RET for 
> type-specific completion support
>   (read-string "Description: " initial-input)
> initial-input)))

The code below the removed form can modify `link' variable. If such
modification does happen, your patch will fail to remove the link from
`org-stored-links' - (assoc link org-stored-links) will no longer return
non-nil.
 

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



Re: [PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands

2023-07-03 Thread Ihor Radchenko
Evgenii Klimov  writes:

> ...

Thanks for the update.

Few comments.

First, please add Changelog entry for etc/ORG-NEWS.

> +(defvar org-metaleft-final-hook nil
> +  "Hook for functions attaching themselves to `M-left'.
> +See `org-ctrl-c-ctrl-c-hook' for more information.")

Note that unlike the docstring your added, `org-shiftup-final-hook'
specifies when the hook is executed:

(defvar org-shiftup-final-hook nil
  "Hook for functions attaching themselves to `S-up'.
This one runs after all other options except shift-select have been excluded.
See `org-ctrl-c-ctrl-c-hook' for more information.")

It is better to follow the pattern and clarify the purpose of the hook
better instead of leaving docstrings for both the -final and other hook
same.

> +individual commands for more information.
> +
> +This function runs the hook `org-shiftmetaleft-hook' as a first
> +step, `org-shiftmetaleft-final-hook' as the penultimate step, and
> +returns at first non-nil value."

Upon looking closer, I realized that you also defined return value of
the function here.  Is there any particular reason for this? The return
value is currently not defined and supposed to be discarded.

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



Re: Cache must be active error

2023-07-03 Thread Ihor Radchenko
Colin Baxter  writes:

> 1. emacs -q 
> 2. eval in scratch buffer
>(add-to-list 'load-path (expand-file-name "~/path/to/git/org-mode/lisp"))
> 3. M-x org-agenda 
> 4. Enter m
> 5. "Cache must be active" now appears in echo area
>
> Am I seeing a new git/org-mode feature or a bug?

A can reproduce.
Fixed, on main.

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



Re: org babel output

2023-07-03 Thread Ihor Radchenko
Robert Synofzik  writes:

> the exact same error occurs for me:
> https://emacs.stackexchange.com/questions/72243/macos-org-babel-python-with-session-output-give-python-el-eval
>
> I use python 3.9 so guessing switching the version won't help.

May you share your Org version as well?
If it is not the latest, may you try reproducing with the latest ELPA
Org version and with the latest development version?

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



Re: Cache must be active error

2023-07-03 Thread Colin Baxter
> Max Nikulin  writes:

> On 03/07/2023 14:03, Colin Baxter wrote:
>> 2. If I remove all the org files from my emacs-30.50.0 and
>> thereby force emacs to use only org-mode from git then I see the
>> error.

> Have you tried to recompile Org from git or to load it uncompiled?

> Concerning mixed-version loading. M-x org-version when read with
> attention may contain a hint. Other tools are
> `list-load-path-shadows' and

> (ignore (pp (mapcar (lambda (x) (list (car x))) load-history)))

> and search for "org"

I now a recipe:

Either with emacs-28.2 or emacs-30.0.50 do:

1. emacs -q 
2. M-x org-agenda 
3. Enter m
4. "Match:" appears in echo area

However:

1. emacs -q 
2. eval in scratch buffer
   (add-to-list 'load-path (expand-file-name "~/path/to/git/org-mode/lisp"))
3. M-x org-agenda 
4. Enter m
5. "Cache must be active" now appears in echo area

Am I seeing a new git/org-mode feature or a bug? The lisp files in
git/org-mode/lisp were not byte-compiled.

Colin Baxter.




[PATCH v2] lisp/org.el: Add final hooks to S-/M-/S-M-cursor commands

2023-07-03 Thread Evgenii Klimov
* lisp/org.el (org-metaleft-final-hook, org-metaright-final-hook,
org-metaup-final-hook, org-metadown-final-hook): Define final hooks
for S-cursor commands.
(org-metaleft, org-metaright, org-metaup, org-metadown): Add final
hooks to M-commands and document them in the docstring.

* lisp/org.el (org-shiftup, org-shiftdown, org-shiftright,
org-shiftleft): Document hooks for S-cursor commands in the docstring.

* lisp/org.el (org-shiftmetaleft-final-hook,
org-shiftmetaright-final-hook, org-shiftmetaup-final-hook,
org-shiftmetadown-final-hook): Define final hooks for the S-M-cursor
commands.
(org-shiftmetaleft, org-shiftmetaright, org-shiftmetaup,
org-shiftmetadown): Add final hooks to the S-M-cursor commands and
document hooks in the docstring.

TINYCHANGE
---
Probably you are right and there's no need to add the final hook to
`org-meta-return'. Previously, I thought that the last condition fully
simulate C-RET, but the latter turned out to be
`org-insert-heading-respect-content'.

 etc/ORG-NEWS | 17 +
 lisp/org.el  | 98 +---
 2 files changed, 103 insertions(+), 12 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index cb4bc632b..f88e3df3d 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -249,6 +249,23 @@ Currently implemented options are:
   iCalendar programs support this usage.
 
 ** New features
+*** New final hooks for Modifier-Cursor keys
+
+Final hooks are added to the following commands:
+- ~org-metaleft-final-hook~ to ~org-metaleft~ (bound to =M-=).
+- ~org-metaright-final-hook~ to ~org-metaright~ (bound to
+  =M-=).
+- ~org-metaup-final-hook~ to ~org-metaup~ (bound to =M-=).
+- ~org-metadown-final-hook~ to ~org-metadown~ (bound to =M-=).
+- ~org-shiftmetaleft-final-hook~ to ~org-shiftmetaleft~ (bound to
+  =M-S-=).
+- ~org-shiftmetaright-final-hook~ to ~org-shiftmetaright~ (bound to
+  =M-S-=).
+- ~org-shiftmetaup-final-hook~ to ~org-shiftmetaup~ (bound to
+  =M-S-=).
+- ~org-shiftmetadown-final-hook~ to ~org-shiftmetadown~ (bound to
+  =M-S-=).
+
 *** ~org-insert-todo-heading-respect-content~ now accepts prefix arguments
 
 The prefix arguments are passed to ~org-insert-todo-heading~.
diff --git a/lisp/org.el b/lisp/org.el
index fdb920864..052c592ed 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16831,27 +16831,51 @@ before indentation and \t insertion takes place.")
 (defvar org-metaleft-hook nil
   "Hook for functions attaching themselves to `M-left'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metaleft-final-hook nil
+  "Hook for functions attaching themselves to `M-left'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metaright-hook nil
   "Hook for functions attaching themselves to `M-right'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metaright-final-hook nil
+  "Hook for functions attaching themselves to `M-right'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metaup-hook nil
   "Hook for functions attaching themselves to `M-up'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metaup-final-hook nil
+  "Hook for functions attaching themselves to `M-up'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metadown-hook nil
   "Hook for functions attaching themselves to `M-down'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-metadown-final-hook nil
+  "Hook for functions attaching themselves to `M-down'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetaleft-hook nil
   "Hook for functions attaching themselves to `M-S-left'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetaleft-final-hook nil
+  "Hook for functions attaching themselves to `M-S-left'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetaright-hook nil
   "Hook for functions attaching themselves to `M-S-right'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetaright-final-hook nil
+  "Hook for functions attaching themselves to `M-S-right'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetaup-hook nil
   "Hook for functions attaching themselves to `M-S-up'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetaup-final-hook nil
+  "Hook for functions attaching themselves to `M-S-up'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-shiftmetadown-hook nil
   "Hook for functions attaching themselves to `M-S-down'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
+(defvar org-shiftmetadown-final-hook nil
+  "Hook for functions attaching themselves to `M-S-down'.
+See `org-ctrl-c-ctrl-c-hook' for more information.")
 (defvar org-metareturn-hook nil
   "Hook for functions attaching themselves to `M-RET'.
 See `org-ctrl-c-ctrl-c-hook' for more information.")
@@ -16919,7 +16943,11 @@ When ARG is a numeric prefix, show contents of this 
level."
   "Promote subtree or 

org babel output

2023-07-03 Thread Robert Synofzik
Hello,

the exact same error occurs for me:
https://emacs.stackexchange.com/questions/72243/macos-org-babel-python-with-session-output-give-python-el-eval

I use python 3.9 so guessing switching the version won't help.

#+begin_src python :session :results output

print("yes")

#+End_src

#+Results:
: __PYTHON_EL_eval("try:\nwith
open('/var/folders/16/snlwm5z17zz1b1x09vvvrdg04v6pgk/T/babel-hWQZ8X/python-sPLVoL')
as __org_babel_python_tmpfile:\n
 exec(compile(__org_babel_python_tmpfile.read(), __
org_babel_python_tmpfile.name, 'exec'))\nexcept:\nraise\nfinally:\n
 print('


do you possibly have any idea on how to fix this?

Sorry to bother you and thanks for the attention!

Robert


Re: Add final hooks to S-/M-/S-M-cursor commands

2023-07-03 Thread Evgenii Klimov



On July 1, 2023 11:40:07 AM GMT+01:00, Ihor Radchenko  
wrote:
>Thanks for the patch!
>May you please squash it into one
>

Don't you mind if I also add the final hook to `org-meta-return'? I
didn't do it right away because it requires a little bit of refactoring:
everything after the initial hook is currently run with
`call-interactively'.



[PATCH] Keep the link if the command was cancelled

2023-07-03 Thread Evgenii Klimov
* lisp/ol.el (org-insert-link): Keep the link in `org-stored-links' if
the command was interrupted by the user during the reading of a
description from the minibuffer.
---
Currently the link is lost if the user chooses the link but cancells
the comand while writing the description.

 lisp/ol.el | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index e2bf90acd..e48138ef9 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1896,11 +1896,6 @@ Use TAB to complete link prefixes, then RET for 
type-specific completion support
   (or entry (push link org-link--insert-history))
   (setq desc (or desc (nth 1 entry)
 
-(when (funcall (if (equal complete-file '(64)) 'not 'identity)
-  (not org-link-keep-stored-after-insertion))
-  (setq org-stored-links (delq (assoc link org-stored-links)
-  org-stored-links)))
-
 (when (and (string-match org-link-plain-re link)
   (not (string-match org-ts-regexp link)))
   ;; URL-like link, normalize the use of angular brackets.
@@ -1995,6 +1990,10 @@ Use TAB to complete link prefixes, then RET for 
type-specific completion support
  (read-string "Description: " initial-input)
initial-input)))
 
+(when (funcall (if (equal complete-file '(64)) 'not 'identity)
+   (not org-link-keep-stored-after-insertion))
+  (setq org-stored-links (delq (assoc link org-stored-links)
+   org-stored-links)))
 (unless (org-string-nw-p desc) (setq desc nil))
 (when remove (apply #'delete-region remove))
 (insert (org-link-make-string link desc))
-- 
2.34.1




Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Ihor Radchenko
Liu Hui  writes:

> I have updated the patch and ‘:file’ header argument can be omitted
> now, e.g.
>
> #+begin_src python :results graphics file
> import matplotlib.pyplot as plt
> plt.plot([1,2,3,4,5])
> plt.savefig('test.png')
> return 'test.png'
> #+end_src

This already works, even without the patch.

> In this case, `graphics' can be removed too.

May you elaborate?

#+begin_src python :results file
implies that the result of execution is file _contents_.

>> What if the user wants to use, for example, pyplot instead of
>> matplotlib?
>
> pyplot is a module of matplotlib. If you mean users want to use other
> graphics libraries, they may advise `org-babel-python-save-graphics'
> if they want to use `graphics' in the header argument. If necessary,
> ob-python may support such libraries too.

This is not acceptable. If src blocks worked in the past, they should
continue working without adjustments in user' setup. We can only break
backwards-compatibility when there is a strong reason to do so. Adding a
new feature is not such a reason.

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



Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Liu Hui
Ihor Radchenko  于2023年7月3日周一 17:28写道:

> This might be a useful feature, but it will break the existing
> conventions, if used as in the patch. Currently, the above combination
> of :file and :results is treated as the following:
>
> ‘graphics’
>  When used along with ‘file’ type, the result is a link to the file
>  specified in ‘:file’ header argument.  However, unlike plain ‘file’
>  type, code block output is not written to the disk.  The block is
>  expected to generate the file by its side-effects only, as in the
>  following example:
>
>   #+begin_src shell :results file link :file "org-mode-unicorn.svg"
> wget -c "https://orgmode.org/resources/img/org-mode-unicorn.svg;
>   #+end_src
>
>   #+RESULTS:
>   [[file:org-mode-unicorn.svg]]
>
>  If ‘:file’ header argument is omitted, interpret source block
>  result as the file path.

I have updated the patch and ‘:file’ header argument can be omitted
now, e.g.

#+begin_src python :results graphics file
import matplotlib.pyplot as plt
plt.plot([1,2,3,4,5])
plt.savefig('test.png')
return 'test.png'
#+end_src

In this case, `graphics' can be removed too.

> What if the user wants to use, for example, pyplot instead of
> matplotlib?

pyplot is a module of matplotlib. If you mean users want to use other
graphics libraries, they may advise `org-babel-python-save-graphics'
if they want to use `graphics' in the header argument. If necessary,
ob-python may support such libraries too.
From 8ea69d66552ee0217b7f5c8089b91424b92c3b5a Mon Sep 17 00:00:00 2001
From: Liu Hui 
Date: Mon, 3 Jul 2023 11:13:58 +0800
Subject: [PATCH] ob-python: support header argument `:results file graphics'

* lisp/ob-python.el (org-babel-execute:python): Save current figure to
file when the result type is `file graphics'.
(org-babel-python-save-graphics): New helper function to generate code
to save graphics.
---
 lisp/ob-python.el | 20 
 1 file changed, 20 insertions(+)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 0e0539d7a..6ee52313c 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -72,6 +72,9 @@ (defun org-babel-execute:python (body params)
 		   (cdr (assq :session params
  (result-params (cdr (assq :result-params params)))
  (result-type (cdr (assq :result-type params)))
+ (graphics-file (and (member "graphics" result-params)
+ (ignore-errors
+   (org-babel-graphical-output-file params
 	 (return-val (when (eq result-type 'value)
 		   (cdr (assq :return params
 	 (preamble (cdr (assq :preamble params)))
@@ -81,6 +84,8 @@ (defun org-babel-execute:python (body params)
 	   (org-babel-expand-body:generic
 	body params
 	(org-babel-variable-assignments:python params))
+   (when graphics-file
+ (org-babel-python-save-graphics graphics-file params))
 	   (when return-val
 	 (format (if session "\n%s" "\nreturn %s") return-val
  (result (org-babel-python-evaluate
@@ -149,6 +154,21 @@ (defun org-babel-python-table-or-string (results)
 res)
   res)))
 
+(defun org-babel-python-save-graphics (out-file _)
+  "Return the code for saving graphics to `OUT-FILE'."
+  (format "
+try:
+import matplotlib.pyplot
+if len(matplotlib.pyplot.get_fignums()) > 0:
+matplotlib.pyplot.gcf().savefig('%s')
+else:
+raise RuntimeError('No figure is found. You need to use matplotlib\
+ functions, such as plot and imshow, to produce the graphics.')
+except ModuleNotFoundError:
+raise RuntimeError('ob-python depends on matplotlib for saving graphics')
+"
+  out-file))
+
 (defvar org-babel-python-buffers '((:default . "*Python*")))
 
 (defun org-babel-python-session-buffer (session)
-- 
2.25.1



Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]

2023-07-03 Thread Ihor Radchenko
Sébastien Miquel  writes:

> On second thought, I don't think moving the LaTeX fragment logic away
> from `org-src--contents-for-write-back` makes sense. This part of the
> function does the opposite of `org-do-remove-indentation`, and the
> latter has a boolean argument `skip-fl`, so it makes sense to keep it
> the same here. It is simple enough.
>
> If you're worried about consistency with inline src blocks, I find it
> weird for them to have newlines, let alone newlines mixed with org's
> indentation. But if we do want to treat them the same, then we also
> need to modify `org-do-remove-indentation` to skip the first line for
> them as well.
>
> I've taken this part off the patch for now.

Ok.

I am not that much worried about consistency with inline src blocks.
Rather do not like the mix of org-src buffer local variables and
checking the block type. But we can leave this refactoring to another
day. It is not just about preserve-fl. (also indentation-offset)

> What happens is: in the org buffer, the line is not empty, because it
> has the org indentation (which was possibly just added by
> org-indent-line), but in the edit buffer, the line is empty, because
> the common org indentation was removed. In that case, we want to add
> back the org indentation.

May you please provide an example when it is necessary?
`org-indent-line' will run `org-babel-do-key-sequence-in-edit-buffer', so
it should still use `org-src--contents-for-write-back' and will not
modify the org buffer text directly.

> --- a/lisp/org-macs.el
> +++ b/lisp/org-macs.el
> @@ -483,9 +483,12 @@ line.  Return nil if it fails."
>  (when skip-fl (forward-line))
>   (while (not (eobp))
> (let ((ind (progn (skip-chars-forward " \t") (current-column
> - (cond ((eolp) (delete-region (line-beginning-position) (point)))
> -   ((< ind n) (throw :exit nil))
> -   (t (indent-line-to (- ind n
> + (cond ((< ind n)
> +   (if (eolp) (delete-region (line-beginning-position) 
> (point))
> + (throw :exit nil)))

This function is actually confusing both before and after the change.
According to the docstring:

When optional argument N is a positive integer, remove exactly
that much characters from indentation, if possible.

But the function can actually remove less than N characters.

Before your change, all the blank non-empty lines were unconditionally
removed. After your change, the first such line is removed and the
function returns nil without continuing.

> * lisp/org-macs.el (org-do-remove-indentation): Preserve
> indentation (spaces vs tabs) past the common indentation to remove.
> Do not empty blank lines.

Since not removing blank lines is intentional after the change, why
doing it on a single line that is indented less than N?

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



Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Ihor Radchenko
Liu Hui  writes:

> This patch adds graphics output support for ob-python via matplotlib.
> Specifically, it allows to use header argument `:results file
> graphics' as follows:
>
> #+begin_src python :file "test.png" :results graphics file
> import matplotlib.pyplot as plt
> plt.plot([1,2,3,4,5])
> #+end_src

This might be a useful feature, but it will break the existing
conventions, if used as in the patch. Currently, the above combination
of :file and :results is treated as the following:

‘graphics’
 When used along with ‘file’ type, the result is a link to the file
 specified in ‘:file’ header argument.  However, unlike plain ‘file’
 type, code block output is not written to the disk.  The block is
 expected to generate the file by its side-effects only, as in the
 following example:

  #+begin_src shell :results file link :file "org-mode-unicorn.svg"
wget -c "https://orgmode.org/resources/img/org-mode-unicorn.svg;
  #+end_src

  #+RESULTS:
  [[file:org-mode-unicorn.svg]]

 If ‘:file’ header argument is omitted, interpret source block
 result as the file path.

> +try:
> +import matplotlib.pyplot
> +if len(matplotlib.pyplot.get_fignums()) > 0:
> +matplotlib.pyplot.gcf().savefig('%s')
> +else:
> +raise RuntimeError('No figure is found. You need to use matplotlib\
> + functions, such as plot and imshow, to produce the graphics.')
> +except ModuleNotFoundError:
> +raise RuntimeError('ob-python depends on matplotlib for saving graphics')

What if the user wants to use, for example, pyplot instead of
matplotlib?

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



Re: exporting to PDF multi-lingual document

2023-07-03 Thread Ihor Radchenko
Stefan Nobis  writes:

> The other problem: Not everyone does a full installation of TeX Live.
> So even if good fonts are available, they are not always installed on
> every system (but this part could be mitigated by documentation and/or
> error messages and hints).

Fair point.
I guess that a viable option could be (1) Having a list of fontsets that
will be tried on by one. (2) If none available, we can check the font
Emacs itself uses to render the buffer text and use them.

For (2), we have pretty good odds that the necessary fonts are already
installed and used by Emacs.

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



Re: Cache must be active error

2023-07-03 Thread Max Nikulin

On 03/07/2023 14:03, Colin Baxter wrote:

2. If I remove all the org files from my emacs-30.50.0 and thereby force
emacs to use only org-mode from git then I see the error.


Have you tried to recompile Org from git or to load it uncompiled?

Concerning mixed-version loading. M-x org-version when read with 
attention may contain a hint. Other tools are `list-load-path-shadows' and


(ignore (pp (mapcar (lambda (x) (list (car x))) load-history)))

and search for "org"




Re: exporting to PDF multi-lingual document

2023-07-03 Thread Thomas Dye
Google’s Noto font might have the best coverage and is open source. 

Tom

> On Jul 2, 2023, at 7:48 PM, Stefan Nobis  wrote:
> 
> Ihor Radchenko  writes:
> 
>> Though ideally all the necessary fonts should be provided by
>> TeXLive. I am not sure why they are not yet there in 2023.
> 
> First problem: Is there any free/libre font out there that has a
> really broad and comprehensive coverage of Unicode glyphs? I really
> don't know, but from time to time I hear about fonts that I assumed to
> have good Unicode coverage that this is not the case (e.g. TeX Gyre).
> I think, it is just an enormous amount of work to produce a complete
> Unicode font (even more so, if it should look nice).
> 
> The other problem: Not everyone does a full installation of TeX Live.
> So even if good fonts are available, they are not always installed on
> every system (but this part could be mitigated by documentation and/or
> error messages and hints).
> 
> But I'm no Unicode or font expert (I only need latin letters). I'm
> just impressed what is already possible and about all the work done by
> volunteers. And sometimes I'm astonished by how much work is still to
> do for a complete and smooth Unicode experience. :)
> 
> -- 
> Until the next mail...,
> Stefan.
> 




Re: Cache must be active error

2023-07-03 Thread Colin Baxter
> Max Nikulin  writes:

> On 03/07/2023 00:44, Colin Baxter wrote:
>>> Ihor Radchenko writes:
>> > Just for context, the new version `org-element-cache-map' uses
>> a > new macro `org-element-with-enabled-cache' that temporarily >
>> enabled cache for the duration of `org-element-cache-map'.

>> I add org-mode (from git) early to the load-path in order to
>> compile new org-mode versions on the fly without closes emacs.

> You may try to add

> (message "org? %S" (featurep 'org))

Thanks for this tip. It reports `nil'.


> before the line adding Org to load path. Check the *Messages*
> buffer that it reports "nil" to ensure that Org is not loaded
> through some dependencies.

> When pulled commits includes changes related to macros, .elc files
> affected by macro expansions must be removed before
> compilation. *Incremental* builds may result in inconsistent
> code. Emacs developers prefer fast, but sometimes incorrect builds
> and they are rather skeptical in relation to proper support of
> incremental builds.

> Without removing *.elc files functions like
> `byte-recompile-directory' and `batch-byte-compile' may produce
> files that uses old macro versions.

I've tried removing the .elc files but that doesn't seem to be the
issue.

1. Forcing emacs (emacs-30.50.0) to use only its built-in org-mode then
I see no error

2. If I remove all the org files from my emacs-30.50.0 and thereby force
emacs to use only org-mode from git then I see the error.

3. I suspect some other org-mode library I use is causing the
problem. So far, I've not found the culprit, even though it is only "m"
- search for TAGS/PROPS/KEYWORDS - that gives the error.

Thank you for your help.

Colin Baxter.