Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread gerard . vermeulen




On 12.10.2022 18:21, Max Nikulin wrote:
[...]

Stewart Thomas. [BUG] Tables with square brackets do not compile in
PDF (latex) export. Wed, 10 Nov 2021 11:16:10 -0500.
https://list.orgmode.org/cao12v+wb18nan0fudpaen94ghdt_2nbdjtc4u7n4w3hazba...@mail.gmail.com

I can not figure out an easy way to separate \\ from [b] text but to
prevent the problem you have discovered. I am unsure if

    \\[0pt]

has no negative consequences and safe enough. I expect that LaTeX
sources are not easy to read when fragile sequences of tokens are
involved.

I just have realized that some users might take advantage of earlier
behavior as a feature:

- item \\
  [1cm]
- item

I think that [1cm] should be treated as text, however I have no idea
how to allow users to specify amount of vertical space and to not
limit line break to LaTeX only. @@latex:\\[1cm]@@ is not suitable 
when

the same text should be exported to ascii, html, etc.

[...]

Adding \relax is my fault, I did not expect that it may break \hline.
Such behavior should be stable over decades. The question is how to
allow users to have square brackets in the beginning of the line
following \\ and not break some use case.


2. On my systems ws-butler removes the trailing whitespace.
3. I edited your example with nano to add the trailing space after 
\relax, but it still does not compile.


Sorry, I did not get your point with trailing space. LaTeX ignores
spaces after commands (e.g. "a\relax b" becomes "ab") and in the
beginning of the line. What I am afraid of is unintentionally
introduce white space at the beginning of the line, e.g. if
| a |
| b |
|---|
is exported as
{} a \\
{} b \\
\hline
then cell contents will be " a" and " b", not "a" and "b".
\relax a \\
\relax b \\
\hline
has no such problem.


Sorry, I have misread or misunderstood what \relax does with spaces.
Thank you for your patient explanation -- Gerard



Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread Max Nikulin

On 13/10/2022 09:44, Ihor Radchenko wrote:

Max Nikulin writes:


I am considering \noalign{} instead of \relax. I was never aware of its
effect, but accordingly to The TeXbook it should keep TeX in vertical
mode without any action due to empty argument. (Actually I surprised
that \relax causes any change of internal state besides parser.)


If \noalign has less side effects compared to \relax, I'd prefer
\noalign. Can you confirm this?


My understanding of TeX is not solid enough to confirm this. From The 
TeXbook I have an impression that \noalign is added specially for 
table-like blocks to be used immediately after \cr (low level command 
similar to \\). So I would not use it outside of tables however it may 
be safe. I am not aware of problems with \\\noalign{} in tables. The 
exact effect of \relax is not clear to me yet. I do not have an example 
of negative effect of \relax similar to \hline but outside of tables.


I can try to ask for a better suggestion at stackexchange, but I am 
unsure if the question will be noticed by some person from a TeX engine 
or core LaTeX developers or at least with better understanding of TeX 
internals.



Unfortunately \noalign{} just as \relax will not allow @@latex:[1cm]@@
on the next line, perhaps @@latex:\noalign{\vskip 1cm}@@ is a workaround
to introduce additional vertical space.


What you are talking about appears to be abusing our exporter. We give
no guarantees about how \\ is going to be exported internally into
LaTeX. We should have no obligation to keep use-cases like this.


On the other hand LaTeX backend was transparent to such hacks, so the 
change might be breaking to some users. That is why conditionally adding 
\noalign{} or \relax if \\ is not followed by an export snippet may be a 
better solution.



I never used \\* or \\*[10pt] variants of the command. Current stable
release should has problems when the line next to \\ starts from * that
is not bold marker, besides square brackets.


I feel like I am missing what you are talking about here.


The rabbit hole is deeper than I thought. The \\ command has its star 
counterpart \\* to prevent page break at this point, and both of them 
allow optional [] argument. In vanilla LaTeX2e space is allowed 
between \\ and *. However \usepackage{amsmath} redefines \\ command. It 
still can recognize following *, but only on the same line. Unsure if it 
is a bug or feature. So before your commit the following is not a 
problem in *default* Org configuration:


Star\\
@@ignore:@@* on the next line.

Star and brackets\\
*[1em] on the next line.

| Star |
| * in the next row. |
|-|
| Star and brackets |
| *[1em] in the next row. |

However it might be if someone changes list of default packages. Adding 
\noalign{} and \relax should fix the issue just for square brackets.


So at least as a temporary fix \noalign{} should be used for tables 
instead of \relax to mitigate negative effect of the recent patch.


P.S. Packages like longtable might bring more surprises.\documentclass{article}
%\usepackage{amsmath}
\begin{document}
\section{Regular usage}

Just\\
line break.

Brackets\\[1em]
on the same line.

Star\\*
on the same line.

Star and brackets\\*[1em]
on the same line.

\begin{tabular}{l}
tabular\\
\hline
Two\\
rows\\
\hline
Brackets \\[1em]
in the same row\\[1pt]
\hline
Star \\*
in the same row\\*
\hline
Start and brackets\\*[1em]
in the same row\\*[1pt]
\hline
\end{tabular}

\section{Problems}
Brackets and starts disappear in the beginning of
lines and table rows.

Brackets\\
[1em] on the next line.

\begin{tabular}{l}
tabular\\
\hline
Brackets \\
[1em] in the next row\\
[1pt]
\hline
\end{tabular}

\section{Problems when usepackage\{amsmath\} absent}

Star\\
* on the next line.

Star and brackets\\
*[1em] on the next line.

\begin{tabular}{l}
tabular\\
\hline
Star\\
* in the next row. \\
\hline
Star and brackets\\
*[1em] in the next row. \\
\hline
\end{tabular}
\end{document}


Re: idea for capture anywhere in x

2022-10-12 Thread Jean Louis
I understand that by changing habits one can do many things. Just as
user may use Emacs Window Manager, and everything is solved.

> I do not mind, but nobody has created a more generic solution that Org can
> use as a base to implement its features. That is why I wrote

Capturing information is just matter of connecting dots. Win those who
have best integration. Org is far from having best
integration. Running Emacs server is not easy. Last Emacs survey has
shown that just few users use it.

Look here the count of users:
https://addons.mozilla.org/en-US/firefox/search/?q=notes

Org Capture is 603 users, versus Firefox standard notes. Integration
is what matters.

I use this extension:
https://github.com/vifon/org-protocol-for-firefox
https://addons.mozilla.org/en-US/firefox/addon/org-protocol/

It has 45 users. It works for me without problem.

Of course I do not enter information in Org, but into PostgreSQL
database, as not to waste time and efforts later.

> > I don't know which quoted text you mean and how to add page URL to
> > quoted text.
> 
> I mean a note consisting of page title, page URL, and a quote with text
> selected on the page. Firefox exposes URL to selection, but I consider a
> browser extension as a better variant. You mentioned one extension, another
> one is https://github.com/sprig/org-capture-extension/
> 
> > > Plain text files stored in a version control system allows to review
> > > changes done at specific time interval.
> > 
> > To use version control system is non-trivial. To use Emacs is
> > non-trivial. Org, anything. What is trivial is to use simple
> > applications how they are designed on mobile devices.
> 
> Backups, history of changes, and compatibility over decades may be serious
> issues with "simple applications".

Emacs Lisp is just glue to PostgreSQL, so I never had problem with
compatibility of SQL to some newer versions, that is why there are
standards involved.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



Re: [PATCH] Org Habit fix + new feature

2022-10-12 Thread Ihor Radchenko
Morgan Smith  writes:

> ...  The current logic simply looks at the previous '(+
> org-habit-preceding-days org-habit-following-days)' log records which by
> default would be 28.  First of all, why are we looking into the future
> at all?  I don't think the habits graph currently supports looking at it
> from the perspective of a different day and I think marking things as
> complete in the future is pretty odd.

Well. Ideally, the habit graph should use current agenda day. Not the
actual current date.

> Second of all, if we use org
> wrong, then we will start loosing days at the beginning of the graph if
> we have more then 28 log records in our period.

Agree.

> Now my patch calculates the first day of the graph and simply looks at
> all log records before that date.  This is more robust if we want to use
> org wrong. Also it's more intuitive I think.  In many cases I think it
> will also be a performance boost since then we likely won't loop the
> full 28 times.  Furthermore, this method would support looking at the
> habits graph from the perspective of a different day (which blindly
> looping 28 times does not).
> This patch does not do a good job at adding support for repetitions.
> The graph and logic still works in days, not repetitions.  It simply
> makes the current code more robust.

Agree.

>> This logic will fail for non-default combinations of org-log-into-drawer
>> + org-clock-into-drawer + org-log-states-order-reversed.
>
> Well shoot.  That's a bummer.  So why are we using a regex here anyways?
> It feels not super robust.  Don't we have an AST we could use instead?
> Also even if we do want to use regex, pulling out log records and clock
> records seems like a pretty common thing to do that should be in a
> core library function right?

Because the last serious change in org-habit was 8 years ago (de51e1aef)
and the main implementation dates back to 13 years ago. org-element has
been introduced 10 years ago. It was simply not a thing when the
original org-habit had been developed.

Similar history goes over clock and log parsing. Nobody bothered to
update them for the new element API.

And notes format is only regexp-based. There is no fixed AST element for
notes. Just hard-coded conventions.

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



Re: BUG: (org-up-element) does not work from inlinetask

2022-10-12 Thread Ihor Radchenko
Michael Dauer  writes:

> (org-up-element) does not jump up when cursor is on inlinetask.
>  From within the inlinetask it jumps to the inlinetask heading, but from
> there not higher in the hierarchy.

Thanks for reporting!
Fixed on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0e4874f17c80f5bcf0a02674d57257a458b85e8f

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



Re: [PATCH] (v2) Fix void variable error `cider-buffer-ns` when specifying :backend header argument

2022-10-12 Thread Ihor Radchenko
"Christopher M. Miles"  writes:

> From 1ecdcc596c8447fcf96ff400f544c0adc680c8fc Mon Sep 17 00:00:00 2001
> From: stardiviner 
> Date: Wed, 12 Oct 2022 17:27:58 +0800
> Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with
>  `org-babel-clojure-backend'

Thanks!
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=601ce688d5a51db7f1a5262063512f13b581bdc4

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



Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread Ihor Radchenko
Max Nikulin  writes:

> On 12/10/2022 14:26, Ihor Radchenko wrote:
>> Max Nikulin writes:
>>>
>>> I can not figure out an easy way to separate \\ from [b] text but to
>>> prevent the problem you have discovered. I am unsure if
>>>
>>>   \\[0pt]
>>>
>>> has no negative consequences and safe enough. I expect that LaTeX
>>> sources are not easy to read when fragile sequences of tokens are involved.
>> 
>> What about adding \relax in front of table rows instead of at the end?
>> The hlines are transcoded separately.
>> 
>> All other instances of \\\relax may remain.
>
> If you see a way to implement it, you may try. Do not forget a space 
> after it. Spaces at the beginning of line are insignificant, so 
> insertion of \relax should not cause more ignored spaces than it was 
> before. I would consider skipping "\relax " in the beginning of rows 
> where first cell starts from an export snippet.
>
> I am considering \noalign{} instead of \relax. I was never aware of its 
> effect, but accordingly to The TeXbook it should keep TeX in vertical 
> mode without any action due to empty argument. (Actually I surprised 
> that \relax causes any change of internal state besides parser.) 

If \noalign has less side effects compared to \relax, I'd prefer
\noalign. Can you confirm this?

I was also surprised that \relax does anything except escaping.

> Unfortunately \noalign{} just as \relax will not allow @@latex:[1cm]@@ 
> on the next line, perhaps @@latex:\noalign{\vskip 1cm}@@ is a workaround 
> to introduce additional vertical space.
>
>  \\[0pt]

What you are talking about appears to be abusing our exporter. We give
no guarantees about how \\ is going to be exported internally into
LaTeX. We should have no obligation to keep use-cases like this.

> causes insertion of some code for negative vertical skip (of zero height 
> this case). It should not be really harmful, but I would avoid this hack.
>
> I never used \\* or \\*[10pt] variants of the command. Current stable 
> release should has problems when the line next to \\ starts from * that 
> is not bold marker, besides square brackets.

I feel like I am missing what you are talking about here.

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



Re: [BUG] org-beamer :BEAMER_ACT: ignored on columns

2022-10-12 Thread Ihor Radchenko
"Fraga, Eric"  writes:

> On Wednesday, 12 Oct 2022 at 14:00, Ihor Radchenko wrote:
>> Your patch adds for columns
>
> All I did was copy the code that was there for options and adapted for
> actions.  I really do not understand what the rest of the code does and
> really do not have the time (due to teaching obligations) to investigate
> in more detail.  Sorry.  The patch solved the OP's problem...
>
> I will try to have a better look in a few weeks when my teaching duties
> subside a bit.

Take your time. What I do not want here is introducing new bugs. I am
not familiar with ox-beamer and do not want to miss anything subtle.

>>  ;; also process actions
>>  (raw-actions (org-element-property :BEAMER_ACT headline))
>>  (actions (if raw-actions
>>   (org-beamer--normalize-argument raw-actions 'action)
>> ""))
>
> [...]
>
>> I do not know if [xxx] vs xxx makes any difference for columns, but it
>
> The org-beamer--normalize-argument function ensures that the action is
> enclosed in [<...>] and [...] for options.

Or <...>. In particular,
(org-beamer--normalize-argument raw-actions 'action)
, will return  (possibly stripping duplicate <>)
Looking at 12.7 Splitting a Frame into Multiple Columns section of the
beamer manual, it should be safe to use .

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



Re: idea for capture anywhere in x

2022-10-12 Thread Ihor Radchenko
Jean Louis  writes:

> Emacs has in any case the capability to accept information in various
> ways and then run we could say really arbitrary Emacs lisp, as the
> command line options allow it. How data is sent from external programs
> may be decided, coded, prepared by such programs.
>
> The freedom shall not be forgotten. How I see it, people may think
> that Org Protocol is the only way to add information to Emacs. 
>
> Neither it is not the only way to add Org information or notes to Org
> or any other type of the file.

This is implied. Indeed, you can put information into Emacs by many other
means, including keyword input or command line invocation.

Protocol is particularly useful when used via bookmarklets in browsers
or when you want to limit information transfer between browser and Emacs
- protocols are a subject of security policy and users might only allow
the protocol types that are known to process date in a safe way, without
danger of running arbitrary Elisp.

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



Re: [HELP] Fwd: Org format as a new standard source format for GNU manuals

2022-10-12 Thread Richard Stallman
[[[ To any NSA and FBI agents reading my email: please consider]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I would just like to point out that anyone familiar with writing a
  > Texinfo-format manual who wants to combine this with Org mode
  > would likely just want to embed Org constructs, like Org tables in
  > the manual; not to use Org as a formatter that exports individual
  > source blocks to form a Texinfo manual (literate programming
  > style).

The proposal I thought I was responding to is different from both of
those.  It was to make Org format an option for the source format for
a whole GNU manual.  One that could generate the same output formats
that we now generate from Texinfo, and would be able to produce a
well-formatted printed manual via TeX.

This does not inherently require imply generating Texinfo format from
Org format.  Texinfo format is a source format, not an output format.

However, generating Texinfo format as an intermediate format might be
advantageous as a way to feed the Org-format manual through TeX to
get a well-formatted printed manual.


-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





Re: [FR] [Revived] Human readable / customizable link anchors during export

2022-10-12 Thread Kévin Le Gouguec
Ihor Radchenko  writes:

> Kévin Le Gouguec  writes:
>
>>> 3. Instead of trying to find a silver bullet for human-readable anchor
>>>generator, we allow users to customize it. The default will be
>>>constant "org" yielding "org-Ajjq"-type anchors, just like we have
>>>now. But we can also provide other generators, like the one Timothy
>>>proposed, or better versions contributed in future if there is
>>>demand.
>>
>> Personally, I'd be wholly satisfied with a customization option; the
>> grail for me would be [pandoc's algorithm], which doesn't look too hard
>> to reimplement in one's config.
>>
>> (Although the collision-handling logic could be tricky: since it
>> revolves around appending a counter to the ID, it needs to keep track of
>> how many times the same ID has been generated for the whole document.
>> If the generator API is just {heading ↦ ID}, i.e. there is no extra
>> "context" argument, one will need to do some bookkeeping "on the
>> side"…)
>
> The collision-handling should not concern the anchor generator code. If
> an anchor generator returns a duplicate ID, we can just append some
> symbols to make it unique. All the bookkeeping has to be made in
> centralized way on ox.el side.

Well, it depends on what "some symbols" are.  Pandoc's counter-based
suffixes, for example, are reproducible & stable for a given document
outline.

That's why I'd personally like to have those.  Other suffix-generation
schemes (e.g.  hashing the section content) might produce something
reproducible as well, but not necessarily so stable wrt the outline
(e.g. hashing the section content will produce different results
everytime I add or remove a comma).



Re: idea for capture anywhere in x

2022-10-12 Thread Max Nikulin

On 11/10/2022 05:06, Jean Louis wrote:

Jean, make a pause and think ones more. It does not mean extra click
and implies nothing different from you recipe.


Instead of thinking, I am doing it.


I consider it as a problem. It is better to think at first.


Did you try to invoke Emacs without having Emacs in front of you?


Just because actually selected text in browser may be quite different 
from expectations (due to various tricks on web pages, not to mention 
that JS may completely overwrite clipboard content) I prefer to see 
capture result. That is why I decided to ensure that an emacs frame is 
created (if no one exists yet) when I invoke capture. (Without 
additional efforts from my side the frame is marked as required 
attention even if it is on another virtual desktop, so I can switch to 
it using a DE shortcut.) Perhaps requirement of a frame is the reason 
why I avoided a kind of pitfall you have in mind.


If there is no running Emacs daemon yet, it may be started on demand 
either through systemd socket activation or by

emacsclient -a "" ...
I do not see any problem here.

If you mean that Emacs can not access X selection if no frames created 
yet then I agree, behavior is strange. On the other hand I do not 
understand why Emacs must be in front of me. A frame may be hidden.


emacsclient -a "" --eval "(server-select-display (getenv \"DISPLAY\"))"
emacsclient --eval "(require 'org-compat)" --eval "(org-get-x-clipboard 
'CLIPBOARD)"


Emacs is not "in front of me", but selection is accessible. Such kind of 
action may be assigned to DE or WM shortcut so I do not see any reason 
why mouse must be involved to get selection (in a way quite similar to C-y).



Here is updated bash file,

..


#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP


Such way to work with temporary files is unsafe.


Capturing notes shall not IMHO be limited to Org mode as that limits
users to specific lightweight markup language (Org).


I do not mind, but nobody has created a more generic solution that Org 
can use as a base to implement its features. That is why I wrote



If Emacs had generic enough functions to create captures then Org would
reuse it as it extends outline mode. Maybe such tools should be added to
Emacs, but they should be designed at first.




A browser extension is a straightforward way to add page URL to the
quoted text.


I don't know which quoted text you mean and how to add page URL to
quoted text.


I mean a note consisting of page title, page URL, and a quote with text 
selected on the page. Firefox exposes URL to selection, but I consider a 
browser extension as a better variant. You mentioned one extension, 
another one is https://github.com/sprig/org-capture-extension/



Plain text files stored in a version control system allows to review
changes done at specific time interval.


To use version control system is non-trivial. To use Emacs is
non-trivial. Org, anything. What is trivial is to use simple
applications how they are designed on mobile devices.


Backups, history of changes, and compatibility over decades may be 
serious issues with "simple applications".



Computer thinks for me.







Re: idea for capture anywhere in x

2022-10-12 Thread Jean Louis
* Ihor Radchenko  [2022-10-12 14:37]:
> I was mostly answering about X website to eww website part. org-protocol
> is a way to run arbitrary Elisp when Emacs is called with an arbitrary
> data (not necessarily file).

Sounds sensational, while it is not. According to (info "(org)
Protocols") it says that data has to conform to specific URL
specification. It is a way to standardize input to Org, rather then to
general Emacs and it was meant to be used from browsers. Then the
Emacs Lisp is run according to settings in Emacs which have to match
the Org Protocol URLs, right?

Even though it was made rather for browser, it may be used in many
ways with or without browser.

Though:

Emacs has in any case the capability to accept information in various
ways and then run we could say really arbitrary Emacs lisp, as the
command line options allow it. How data is sent from external programs
may be decided, coded, prepared by such programs.

The freedom shall not be forgotten. How I see it, people may think
that Org Protocol is the only way to add information to Emacs. 

Neither it is not the only way to add Org information or notes to Org
or any other type of the file.

As Org headings begin with stars, one can easily concatenate various
information from various sources and convert it to Org file.

Let us say from places.sqlite where Firefox and derivate browsers'
bookmarks are held, with one liner it may be converted to Org
headings. It is not as sophisticated. 

sqlite3 places.sqlite "select '** ' || title || char(10) || char(10) || title 
|| ': ' || url || char(10) || char(10) FROM 'moz_places';"

It will give the output like:

** Libervia

Libervia: https://salut-a-toi.org/presentation#demo


** Libervia

Libervia: https://www.libervia.org/


** Libervia register new account

Libervia register new account: 
https://www.libervia.org/register?redirect_url=%2F


** flatpak invalid compressed data at DuckDuckGo

flatpak invalid compressed data at DuckDuckGo: 
https://html.duckduckgo.com/html/?q=flatpak+invalid+compressed+data


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread Max Nikulin

On 12/10/2022 16:17, gerard.vermeu...@posteo.net wrote:



On 12.10.2022 07:55, Max Nikulin wrote:

On 12/10/2022 12:15, gerard.vermeulen wrote:

On 12.10.2022 06:45, Max Nikulin wrote:


LuaLaTeX is irrelevant. It seems \hline is allowed only immediately
after \\. Minimal LaTeX example:

\begin{tabular}{l}
b\\\relax
\hline
\end{tabular}


Your example fails on my Mac texlive-2020 with:

! Misplaced \noalign.
\hline ->\noalign
   {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth 
\futurelet...


l.40 \hline

It compiles when I remove \hline


Gerard, we forgot to post the reason why \relax has been added after
\\. The intention was to  prevent errors in the case of

| a   |
| [b] |

or

- item \\
  [2022-10-12]

Stewart Thomas. [BUG] Tables with square brackets do not compile in
PDF (latex) export. Wed, 10 Nov 2021 11:16:10 -0500.
https://list.orgmode.org/cao12v+wb18nan0fudpaen94ghdt_2nbdjtc4u7n4w3hazba...@mail.gmail.com

I can not figure out an easy way to separate \\ from [b] text but to
prevent the problem you have discovered. I am unsure if

    \\[0pt]

has no negative consequences and safe enough. I expect that LaTeX
sources are not easy to read when fragile sequences of tokens are
involved.

I just have realized that some users might take advantage of earlier
behavior as a feature:

- item \\
  [1cm]
- item

I think that [1cm] should be treated as text, however I have no idea
how to allow users to specify amount of vertical space and to not
limit line break to LaTeX only. @@latex:\\[1cm]@@ is not suitable when
the same text should be exported to ascii, html, etc.


Max, thanks for the background information.

For your info:
1. I also need to remove \relax in the LaTeX export using Gentoo 
texlive-2022 to compile.


Adding \relax is my fault, I did not expect that it may break \hline. 
Such behavior should be stable over decades. The question is how to 
allow users to have square brackets in the beginning of the line 
following \\ and not break some use case.



2. On my systems ws-butler removes the trailing whitespace.
3. I edited your example with nano to add the trailing space after 
\relax, but it still does not compile.


Sorry, I did not get your point with trailing space. LaTeX ignores 
spaces after commands (e.g. "a\relax b" becomes "ab") and in the 
beginning of the line. What I am afraid of is unintentionally introduce 
white space at the beginning of the line, e.g. if

| a |
| b |
|---|
is exported as
{} a \\
{} b \\
\hline
then cell contents will be " a" and " b", not "a" and "b".
\relax a \\
\relax b \\
\hline
has no such problem.






Re: test-org-table/sort-lines: Failing test on macOS

2022-10-12 Thread Max Nikulin

On 11/10/2022 05:25, Rudolf Adamkovič wrote:

(string-collate-lessp "a" "b" "C" t) ; t

..

(string-collate-lessp "a" "b" "C" nil) ; t

..

So basic sanity tests passed.


(string-collate-lessp "a" "B" "C" nil)  ; => nil
(string-collate-lessp "a" "B" "POSIX" nil) ; nil


is expected behavior as well. What I do not like is

> (string-collate-lessp "a" "B" "C" t)  ; => nil
Actually you wrote

[FYI: If I replace nil with t, the procedure returns nil too.]

From my point of view it is a reason to file an Emacs bug because I get

(string-collate-lessp "a" "B" "C" t) ; => t

It seems case folding works strange for comparison because when case is 
the same "a" < "b" as expected:



(string-collate-lessp "a" "b" "C" t) ; t
(string-collate-lessp "A" "B" "C" t) ; t
(string-collate-lessp "a" "b" "C" nil) ; t
(string-collate-lessp "A" "B" "C" nil) ; t


May it happen that IGNORE-CASE argument is ignored in your case? I 
believe, it is improbable that C locale is not generated, so case fold 
rules are undefined


locale -a | grep C

Another your strange result is


$ locale -a | grep en_US
en_US.US-ASCII
en_US.UTF-8

..
so en_US locale is defined but collation rules are different from glibc

printf 'a\nB\n' | LC_COLLATE=en_US.UTF-8 sort
B
a


I have no idea if sort and Emacs use the same libc and the same locale 
definitions. I am unaware which way it is organized in MacOS.






Re: bug: wrong-type-argument when trying export to pdf.

2022-10-12 Thread Justin Silverman
Well, rm -rf .emacs.d/straight/ followed by repulling and rebuilding seemed to 
fix things.

I am surprised that I still saw the same problem with emacs -Q but my 
simple-config.el did use straight. Perhaps straight in simple-config.el just 
ended up using the same build files that were corrupted...

Anyways I guess mark this one frustrating but solved.

Justin 

Ihor Radchenko  writes:

> Justin Silverman  writes:
>
>> I am having a problem and getting a wrong-type-argument error when
>> trying to run `org-beamer-export-to-pdf' on the attached file
>> `debug.org' (see backtrace below). The problem also occurs when
>> running `org-latex-export-to-pdf'.
>> ...
>> Backtrace:
>>
>> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>>   jit-lock--run-functions(1218 1284)
>>   jit-lock-fontify-now(1218 #>)
>>   #(1218 #>)
>>   polymode-inhibit-during-initialization(# 1218 
>> #>)
>
> The backtrace shows that you are using polymode. Does the problem
> persist without polymode?


Re: idea for capture anywhere in x

2022-10-12 Thread Juan Manuel Macías
Ypo writes:

> The first workflow would consist in emphasizing the web page
> permanently:

I think what you are looking for is something similar to what certain
extensions for firefox or chrome do, like highlighter. It's useful, but
I'd say only for static pages.

> 1. Open in ~eww~ the web page.

As long as the webpage doesn't (unfortunately) use javascript.

> 2. Emphasize with org-mode: highlight the text of the web page.

> 3. In the future, when opening again the web page, the highlights
> should appear.

It wouldn't be too hard (I think) to implement something for shr or eww,
so that overlays would be applied to highlight the text in eww-mode, and
the position info would be saved somewhere, so that eww would retrieve
it on page reload. As Ihor has recommended to you, org-remark could have
a (possible) use there. I would investigate on that side; also with
org-remark you could associate notes in org-mode.

> I don't know what would be the best way to do it. The only way I know
> similar to that, is using "org-web-tools-insert-web-page-as-entry". 

It seems safer to me to save the content of a page in one way or
another, because that page may one day cease to be online. org-web-tools
is a great tool. The only drawback I find is that pandoc conversions
from html to org are not always very clean (depends on the page you want
to save). To the above could be added the possibility of highlighting
the content of the page and saving everything locally, to later read the
page offline in eww-mode.

Best regards,

Juan Manuel 



Re: bug: wrong-type-argument when trying export to pdf.

2022-10-12 Thread Justin Silverman
Sorry that was my bad, the backtrace was from my own config not the 
simple-config.el that I provided. Here is the backtrace from the 
simple-config.el that shows that the problem persists even without polymode.

(still, thanks for pointing out that I had polymode activated, that was a 
mistake that I will fix in my personal config)

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  jit-lock--run-functions(1157 1223)
  jit-lock-fontify-now(1157 #>)
  font-lock-ensure(1157 #>)
  org-table-align()
  org-babel-insert-result(((0.333) (0.333) 
(0.333)) ("value" "replace") ("R" "w1 <- c(1, 1, 1) \nw2 <- c(1, 1, 
5) \n\nx1 <- w1/sum(..." ((:colname-names) (:rowname-names) (:result-params 
"value" "replace") (:result-type . value) (:results . "value replace") 
(:exports . "both") (:cache . "no") (:hlines . "no") (:noweb . "no") (:session 
. "*R*") (:tangle . "no")) "" nil 1011 "(ref:%s)") nil "R" (0 0 258514 765000))
  org-babel-execute-src-block(nil ("R" "w1 <- c(1, 1, 1) \nw2 <- c(1, 1, 5) 
\n\nx1 <- w1/sum(..." ((:colname-names) (:rowname-names) (:result-params 
"replace" "value") (:result-type . value) (:results . "replace value") 
(:exports . "both") (:tangle . "no") (:session . "*R*") (:noweb . "no") 
(:hlines . "no") (:cache . "no")) "" nil 1011 "(ref:%s)"))
  org-babel-exp-results(("R" "w1 <- c(1, 1, 1) \nw2 <- c(1, 1, 5) \n\nx1 <- 
w1/sum(..." ((:cache . "no") (:colname-names) (:exports . "both") (:hlines . 
"no") (:noweb . "no") (:result-params "replace" "value") (:result-type . value) 
(:results . "replace value") (:rowname-names) (:session . "*R*") (:tangle . 
"no")) "" nil 1011 "(ref:%s)") block nil 
"2da1507400b1866895fab4840062db146ee4de1e")
  org-babel-exp-do-export(("R" "w1 <- c(1, 1, 1) \nw2 <- c(1, 1, 5) \n\nx1 <- 
w1/sum(..." ((:cache . "no") (:colname-names) (:exports . "both") (:hlines . 
"no") (:noweb . "no") (:result-params "replace" "value") (:result-type . value) 
(:results . "replace value") (:rowname-names) (:session . "*R*") (:tangle . 
"no")) "" nil 1011 "(ref:%s)") block "2da1507400b1866895fab4840062db146ee4de1e")
  org-babel-exp-src-block((src-block (:language "R" :switches nil :parameters 
":exports both :results value :session \"*R*\"" :begin 1011 :end 1146 
:number-lines nil :preserve-indent nil :retain-labels t :use-labels t 
:label-fmt nil :value "  w1 <- c(1, 1, 1) \n  w2 <- c(1, 1, 5) \n\n  x1 <- 
w..." :post-blank 1 :post-affiliated 1011 :mode planning :granularity element 
:cached nil :parent (section (:begin 1011 :end 1223 :contents-begin 1011 
:contents-end 1223 :robust-begin 1011 :robust-end 1221 :post-blank 0 
:post-affiliated 1011 :mode section :granularity element :cached nil :parent 
(headline (:raw-value "Spurious Conclusions" :begin 986 :end 1223 :pre-blank 1 
:contents-begin 1011 :contents-end 1223 :robust-begin 1013 :robust-end 1221 
:level 2 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 
:footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 986 
:title (...) :parent (org-data ...) :cached t :org-element--cache-sync-key (0 . 
986))) :org-element--cache-sync-key (0 . 1010))) :org-element--cache-sync-key 
(0 . 1011
  org-babel-exp-process-buffer()
  org-export-as(beamer nil nil nil nil)
  org-export-to-buffer(beamer "*Org BEAMER Export*" nil nil nil nil nil #)
  org-beamer-export-as-latex()
  funcall-interactively(org-beamer-export-as-latex)
  command-execute(org-beamer-export-as-latex record)
  execute-extended-command(nil "org-beamer-export-as-latex" nil)
  funcall-interactively(execute-extended-command nil 
"org-beamer-export-as-latex" nil)
  command-execute(execute-extended-command)



Ihor Radchenko  writes:

> Justin Silverman  writes:
>
>> I am having a problem and getting a wrong-type-argument error when
>> trying to run `org-beamer-export-to-pdf' on the attached file
>> `debug.org' (see backtrace below). The problem also occurs when
>> running `org-latex-export-to-pdf'.
>> ...
>> Backtrace:
>>
>> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>>   jit-lock--run-functions(1218 1284)
>>   jit-lock-fontify-now(1218 #>)
>>   #(1218 #>)
>>   polymode-inhibit-during-initialization(# 1218 
>> #>)
>
> The backtrace shows that you are using polymode. Does the problem
> persist without polymode?


Org 9.5 broke the rendering of my SVG images

2022-10-12 Thread Alexandre Duret-Lutz
Hi,

In Org 9.5, SVG images started being exported by the HTML exporter as
 rather than .

The patch causing that was
  https://list.orgmode.org/87k0pemj6d@gmail.com/T/
with two arguments:
1)  do not have an alt attribute
2)  will not render some SVG file correctly if it has no viewBox
   (I'm assuming that the issue shown in that message is a missing viewBox).

The reason I've noticed this change is that it broke my web pages.  On
my pages, I use SVG to display many automata, and they all share a
common stylesheet.  That stylesheet is not inlined into the SVG, rather,
it is a separate file included in the SVG files with
  
so that the browser only need to download it once.

Infortunately,  does not allow external stylesheets to be
processed, so my stylesheets are now ignored.  Note that one can also
build SVG images that include other SVG images, or SVG images that have
animations that start when you hover on some elements.  All those
usages would break with .

I've seen that very issue was discussed back in 2016
https://list.orgmode.org/871t2iq353@iki.fi/T/
where Christian Moe pointed out exactly this:

> (2) You can also do other things with  that you cannot with
> , like manipulating the SVG with Javascript and styling it with
> an external stylesheet (linked from the SVG, not the web page).

So in the interest of allowing users to build documents where SVG
files are not static, self-contained images, it seems to me that Org
probably needs some way to specify whether SVG images should be
exported as  or  (or maybe even inlined).


Also regarding the alt attribute, maybe the code exporting
Your browser does not support SVG
could be taught to use
alt text when such an alt= attribute is given.
(I have no clue if that's "accessible" enough.)



In the meantime, I'm advicing org-html--format-image as follows to get
the original behavior in my project. (I also need to support different
Org-mode versions, hence the fboundp check.)

;;; Org-mode 9.5 is now using  to render SVG images.
;;; Unfortunately, this breaks SVG images that use external style
;;; sheets as  are expected to be self-contained.
;;;
;;; Since we do use such external style-sheets and never had
;;; any issue with , we revert
;;; to the previous behavior.
;;;
;;; The following function is based on org-html--svg-image from
;;; Org-mode 9.4.5, with the addition of the SVG extension test.
(defun spot-svg-output-as-object (source attributes info)
  "If source is an SVG file, return an \"object\" embedding svg file
SOURCE with given ATTRIBUTES.
INFO is a plist used as a communication channel.  Otherwise return nil.

The special attribute \"fallback\" can be used to specify a
fallback image file to use if the object embedding is not
supported.  CSS class \"org-svg\" is assigned as the class of the
object unless a different class is specified with an attribute."
  (when (string= "svg" (file-name-extension source))
(let ((fallback (plist-get attributes :fallback))
  (attrs (org-html--make-attribute-string
  (org-combine-plists
   ;; Remove fallback attribute, which is not meant to
   ;; appear directly in the attributes string, and
   ;; provide a default class if none is set.
   '(:class "org-svg") attributes '(:fallback nil)
  (format "\n%s"
  source
  attrs
  (if fallback
  (org-html-close-tag
   "img" (format "src=\"%s\" %s" fallback attrs) info)
"Sorry, your browser does not support SVG.")
;;; Hack org-html--format-image to call the above first.
;;; (The org-html--svg-image function was removed when the formater code
;;; switched to  for SVG.)
(unless (fboundp 'org-html--svg-image)
  (advice-add 'org-html--format-image :before-until 'spot-svg-output-as-object))

-- 
Alexandre



Re: Get the "closest" property value

2022-10-12 Thread George Mauer
Thanks a lot Ihor, while that doesn't seem to "cascade" upwards, it was
enough of a clue to get me there. What i'm looking for is (org-entry-get
(point) "workspace-directory" 't) with the third "inherit" parameter set

Thanks again! That's going to open up a few new workflows for me.

On Wed, Oct 12, 2022 at 4:29 AM Ihor Radchenko  wrote:

> George Mauer  writes:
>
> > If I have a document what looks like the following. What code could I run
> > for the ??? to get the property value for "workspace-directory" that is
> > closest in the outline to the location running the code?
> >
> > * Top Level
> >   :PROPERTIES:
> >   :workspace-directory: /tmp
> >   :END:
> >
> >#+begin_src emacs-lisp
> >  (???) ; /tmp
> >#+end_src
>
> #+begin_src emacs-lisp :var prop-value=(org-entry-get (point)
> "workspace-directory")
> prop-value
> #+end_src
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


BUG: (org-up-element) does not work from inlinetask

2022-10-12 Thread Michael Dauer
(org-up-element) does not jump up when cursor is on inlinetask.
 From within the inlinetask it jumps to the inlinetask heading, but from
there not higher in the hierarchy.

Org mode version 9.5.5 (9.5.5-geeae6e


Re: [PATCH] Org Habit fix + new feature

2022-10-12 Thread Morgan Smith
Ihor Radchenko  writes:
>
> I am not against such feature. However, using clocking will break an
> assumption that a single log record corresponds to a single habit
> completion. This assumption is implied across org-habit code.  
>
Oh that's a good point.  I'll have to go back through the code and see
if that's an issue.



As for your comments on the first patch, let me explain where the
current logic falls short.  Imagine you complete a habit multiple times
in a day because you're using org wrong (yep this also violates that
previous thing that I gotta look into but let's not worry about that for
now).  The current logic simply looks at the previous '(+
org-habit-preceding-days org-habit-following-days)' log records which by
default would be 28.  First of all, why are we looking into the future
at all?  I don't think the habits graph currently supports looking at it
from the perspective of a different day and I think marking things as
complete in the future is pretty odd.  Second of all, if we use org
wrong, then we will start loosing days at the beginning of the graph if
we have more then 28 log records in our period.

Now my patch calculates the first day of the graph and simply looks at
all log records before that date.  This is more robust if we want to use
org wrong. Also it's more intuitive I think.  In many cases I think it
will also be a performance boost since then we likely won't loop the
full 28 times.  Furthermore, this method would support looking at the
habits graph from the perspective of a different day (which blindly
looping 28 times does not).

This patch does not do a good job at adding support for repetitions.
The graph and logic still works in days, not repetitions.  It simply
makes the current code more robust.

> Also, (org-today) does not consider org-extend-today-until. (see
> org-habit-insert-consistency-graphs).

Thanks for catching that!

>
> This logic will fail for non-default combinations of org-log-into-drawer
> + org-clock-into-drawer + org-log-states-order-reversed.

Well shoot.  That's a bummer.  So why are we using a regex here anyways?
It feels not super robust.  Don't we have an AST we could use instead?
Also even if we do want to use regex, pulling out log records and clock
records seems like a pretty common thing to do that should be in a
core library function right?


Thanks for the review!
I appreciate your feedback


Morgan



Re: prevent underscores to be translates in subscript when exporting to latex

2022-10-12 Thread Luca Ferrari
On Sat, Oct 8, 2022 at 4:43 PM Mark Barton  wrote:
> The last part forces the export to recognize just the LaTeX form of 
> specifying subscripts.
>

Great! Thanks, this is what I was looking for.

Luca



Re: watch YT videos through in Emacs [Was: Interest in an Org video meetup?]

2022-10-12 Thread Ihor Radchenko
Max Nikulin  writes:

> On 12/10/2022 16:26, Ihor Radchenko wrote:
>> 
>> if echo "$URL" | grep "ted.com/talks"; then
>>  mpv $URL && exit;
>> fi
>> 
>> # if echo "$URL" | grep "reddit.com"; then
>> # URL="$(echo "$URL" | sed -rE 's/www\.reddit\.com/libredd.it/')"
>> # fi
>> 
>> if echo "$URL" | grep "bilibili.com"; then
>>  mpv $URL && exit;
>> fi
>
> case "$URL" in
> *ted.com/talks*|*bilibili.com*)
>  mpv "$URL" && exit
>  ;;
> esac

Thanks! I keep forgetting how to use case :)

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



Re: [BUG] org-babel-script-escape mishandled empty python list

2022-10-12 Thread Ihor Radchenko
Jonas Bernoulli  writes:

> `org-babel-script-escape' doesn't handle an empty python list
> correctly; ['a'] => ("a") but [] => [].
>
> #+name: addheader
> #+header: :var rows=""
> #+begin_src python
>   return []
> #+end_src
>
> #+header: :post addheader(*this*)
> #+begin_src emacs-lisp :results table
>   nil
> #+end_src
> #+RESULTS:
> : []
>
> An empty python list is turned into an empty lisp vector instead of
> an empty lisp list.  At least for python, (> (length str) 2) should
> probably be changed to use >=.

Thanks a lot! A reproducer helps a ton.
Fixed on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4c0641837c8570dd8ad7f18c2482411bdc0cda16

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



Re: idea for capture anywhere in x

2022-10-12 Thread Ihor Radchenko
Ypo  writes:

> Thanks, Ihor.
>
> But I was referring to 2 possible workflows (not sure if org-protocol 
> would be the answer).

I was mostly answering about X website to eww website part. org-protocol
is a way to run arbitrary Elisp when Emacs is called with an arbitrary
data (not necessarily file).

> The first workflow would consist in emphasizing the web page permanently:
>
>
> 1. Open in ~eww~ the web page.
>
> 2. Emphasize with org-mode: highlight the text of the web page.
>
> 3. In the future, when opening again the web page, the highlights should 
> appear.
>
>
> I don't know what would be the best way to do it. The only way I know 
> similar to that, is using "org-web-tools-insert-web-page-as-entry".

https://github.com/nobiot/org-remark might help here. However, AFAIK, it
only supports file buffers. But I do not see why they couldn't add eww
support if you ask them.

Also, I recall 25.14 Enriched Text (Emacs manual). Not sure if it is
suitable though.

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



Re: Do not show a TODO item in the global TODO list until certain date?

2022-10-12 Thread Ihor Radchenko
Angel de Vicente  writes:

> I copied your code from
> https://github.com/yantar92/emacs-config/blob/master/config.org#properties
> into my .emacs and eval-ed it.
> ...
> But the "test" still shows in the TODO list. Am I missing something
> basic here?

Not really. I just use a different system for skip functions.

Try the following adjusted version:

(defun org-agenda-skip-before-SHOWFROMDATE-property ()
  "Skip agenda item if :SHOWFROMDATE: property is set and the day is before it"
  (when-let* ((showfromdate (if (bound-and-true-p org-ql--current-element)
(org-element-property :SHOWFROMDATE 
(org-element-lineage org-ql--current-element '(headline) t))
  (org-entry-get (point) "SHOWFROMDATE")))
  (showfromdate (unless (seq-empty-p showfromdate) (ts-parse-org 
showfromdate)))
  (currenttime (ts-now)))
(when (ts< currenttime showfromdate)
  (or (outline-next-heading) (point-max)

(Note that the code requires ts library installed).

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



Re: watch YT videos through in Emacs [Was: Interest in an Org video meetup?]

2022-10-12 Thread Robert Weiner
>  More info on my blog in Spanish (if anyone is interested, I can
translate it)

Yes, please translate it to English.

-- rsw


On Wed, Oct 12, 2022 at 6:24 AM Juan Manuel Macías 
wrote:

> Ihor Radchenko writes:
>
> > Quiliro Ordóñez  writes:
> >
> >> Hola Juan Manuel.
> >>
> >>> There is the YouTube option, which I imagine no one would like (me
> >>> neither). The only thing in its favor is that Invidious can be used to
> >>> watch the videos. BTW, I watch YT videos through Invidious in Emacs,
> >>> with the Ytel package and EMMS/MPV.
> >>
> >> Nice.  Is there a guide to do this specificly?
> >
> > I simply use
> >
> > #+begin_src bash :tangle ~/.local/bin/qutebrowser-call.sh :shebang
> #!/bin/bash
> > URL="$1"
> >
> > if echo "$URL" | grep "youtube.com"; then
> > # URL="$(echo "$URL" | sed -r 's/\\(www\\)?youtube\.com/
> invidious.namazso.eu/')"
> > if [[ ! -z $(echo "$URL" | grep "/watch") ]]; then
> >   mpv $URL && exit;
> > fi
> > fi
> >
> > if echo "$URL" | grep "ted.com/talks"; then
> >   mpv $URL && exit;
> > fi
> >
> > # if echo "$URL" | grep "reddit.com"; then
> > # URL="$(echo "$URL" | sed -rE 's/www\.reddit\.com/libredd.it/')"
> > # fi
> >
> > if echo "$URL" | grep "bilibili.com"; then
> > mpv $URL && exit;
> > fi
> >
> > grep "$URL" ~/.data/web-mirror/sources/* >/dev/null 2>&1 &&\
> > ARCHIVE_DIR="$(echo "$URL" | archivebox-cmd list 2>/dev/null | tail
> -n1 | cut -d' ' -f1  | sed -r 's|/data|~/.data/web-mirror|')"
> >
> > if [[ ! -z "$ARCHIVE_DIR" ]]; then
> > [[ -f "${ARCHIVE_DIR}/singlefile.html" ]] &&
> URL="${ARCHIVE_DIR}/singlefile.html";
> > fi
> >
> > #from
> https://github.com/qutebrowser/qutebrowser/blob/master/scripts/open_url_in_instance.sh
> > _url="$URL"
> > _command=":later 4000 :jump-mark last-position"
> >
> > qutebrowser "${_command}" ":spawn -u untrack-url -r -O ${_url}"
> >
> > #+end_src
> >
> > and my mpv is configured to use youtube-dl.
>
> In this short video I show an example of my procedure to watch youtube
> videos without leaving Emacs:
>
> https://cloud.disroot.org/s/X3cfi2orT38CPyM
>
> I use:
>
> 1. Helm-google-suggest (set to use duckduckgo)
>
> 2. Ytel (based on elfeed). With a few hacks that I have added, in order
> to:
>
>   - Display thumbnails in the searches.
>
>   - Watch the video at point (via invidious) with EMMS/MPV,
> configured with yt-dlp, which is a fork of youtube-dl that works
> much better.
>
>   - Download the video at point with yt-dlp (full video or only audio)
>
>   - Create a bookmark of the video with org-capture
>
> More info on my blog in Spanish (if anyone is interested, I can translate
> it):
>
> https://gnutas.juanmanuelmacias.com/ytel_invidious.html
>
> Best regards,
>
> Juan Manuel
>
>


[BUG] org-babel-script-escape mishandled empty python list

2022-10-12 Thread Jonas Bernoulli


`org-babel-script-escape' doesn't handle an empty python list
correctly; ['a'] => ("a") but [] => [].

#+name: addheader
#+header: :var rows=""
#+begin_src python
  return []
#+end_src

#+header: :post addheader(*this*)
#+begin_src emacs-lisp :results table
  nil
#+end_src
#+RESULTS:
: []

An empty python list is turned into an empty lisp vector instead of
an empty lisp list.  At least for python, (> (length str) 2) should
probably be changed to use >=.



Re: idea for capture anywhere in x

2022-10-12 Thread Ypo

Thanks, Ihor.

But I was referring to 2 possible workflows (not sure if org-protocol 
would be the answer).


The first workflow would consist in emphasizing the web page permanently:


1. Open in ~eww~ the web page.

2. Emphasize with org-mode: highlight the text of the web page.

3. In the future, when opening again the web page, the highlights should 
appear.



I don't know what would be the best way to do it. The only way I know 
similar to that, is using "org-web-tools-insert-web-page-as-entry".


Best regards



El 12/10/2022 a las 11:34, Ihor Radchenko escribió:

Ypo  writes:


What if:
1. It were easy and immediate to open in ~eww~ any web page that we are
reading in "x".

Check out org-protocol.el commentary.


Re: watch YT videos through in Emacs [Was: Interest in an Org video meetup?]

2022-10-12 Thread Max Nikulin

On 12/10/2022 16:26, Ihor Radchenko wrote:


if echo "$URL" | grep "ted.com/talks"; then
mpv $URL && exit;
fi

# if echo "$URL" | grep "reddit.com"; then
# URL="$(echo "$URL" | sed -rE 's/www\.reddit\.com/libredd.it/')"
# fi

if echo "$URL" | grep "bilibili.com"; then
 mpv $URL && exit;
fi


case "$URL" in
*ted.com/talks*|*bilibili.com*)
mpv "$URL" && exit
;;
esac






Re: watch YT videos through in Emacs [Was: Interest in an Org video meetup?]

2022-10-12 Thread Juan Manuel Macías
Ihor Radchenko writes:

> Quiliro Ordóñez  writes:
>
>> Hola Juan Manuel.
>>
>>> There is the YouTube option, which I imagine no one would like (me
>>> neither). The only thing in its favor is that Invidious can be used to
>>> watch the videos. BTW, I watch YT videos through Invidious in Emacs,
>>> with the Ytel package and EMMS/MPV.
>>
>> Nice.  Is there a guide to do this specificly?
>
> I simply use
>
> #+begin_src bash :tangle ~/.local/bin/qutebrowser-call.sh :shebang #!/bin/bash
> URL="$1"
>
> if echo "$URL" | grep "youtube.com"; then
> # URL="$(echo "$URL" | sed -r 
> 's/\\(www\\)?youtube\.com/invidious.namazso.eu/')"
> if [[ ! -z $(echo "$URL" | grep "/watch") ]]; then 
>   mpv $URL && exit;
> fi
> fi
>
> if echo "$URL" | grep "ted.com/talks"; then
>   mpv $URL && exit;
> fi
>
> # if echo "$URL" | grep "reddit.com"; then
> # URL="$(echo "$URL" | sed -rE 's/www\.reddit\.com/libredd.it/')"
> # fi
>
> if echo "$URL" | grep "bilibili.com"; then
> mpv $URL && exit;
> fi
>
> grep "$URL" ~/.data/web-mirror/sources/* >/dev/null 2>&1 &&\
> ARCHIVE_DIR="$(echo "$URL" | archivebox-cmd list 2>/dev/null | tail -n1 | 
> cut -d' ' -f1  | sed -r 's|/data|~/.data/web-mirror|')"
>
> if [[ ! -z "$ARCHIVE_DIR" ]]; then
> [[ -f "${ARCHIVE_DIR}/singlefile.html" ]] && 
> URL="${ARCHIVE_DIR}/singlefile.html";
> fi
>
> #from 
> https://github.com/qutebrowser/qutebrowser/blob/master/scripts/open_url_in_instance.sh
> _url="$URL"
> _command=":later 4000 :jump-mark last-position"
>
> qutebrowser "${_command}" ":spawn -u untrack-url -r -O ${_url}"
>
> #+end_src
>
> and my mpv is configured to use youtube-dl.

In this short video I show an example of my procedure to watch youtube
videos without leaving Emacs:

https://cloud.disroot.org/s/X3cfi2orT38CPyM

I use:

1. Helm-google-suggest (set to use duckduckgo)

2. Ytel (based on elfeed). With a few hacks that I have added, in order
to:

  - Display thumbnails in the searches.

  - Watch the video at point (via invidious) with EMMS/MPV,
configured with yt-dlp, which is a fork of youtube-dl that works
much better.

  - Download the video at point with yt-dlp (full video or only audio)

  - Create a bookmark of the video with org-capture

More info on my blog in Spanish (if anyone is interested, I can translate it):

https://gnutas.juanmanuelmacias.com/ytel_invidious.html

Best regards,

Juan Manuel 



Re: Some question on How to handle date, recursive events

2022-10-12 Thread Ihor Radchenko
Renato Pontefice  writes:

> Hi,
> I’m building my own calendar. I try to check:
> 1 - retry a thing until it is not done
> 2 - recursive events (each week, every first Friday of month…)
>
>
> i.e.
> 1)
> ** TODO call Paul < 2022 10 05 10:30  +1d>
> In this example I’ve created an Agenda view that remember me to call Paul 
> every day, at 10:30 each day until Paul answer me. Then I would set it as 
> DONE.Today Paul has answers me, but if I try to set it as DONE (Shift - right 
> arrow) it does not cycle to DONE state. I’ve  thought that is the + 1d that 
> block me to set as DONE. I’ve removed it and now it goes as DONE. But the 
> entry still appear on next days as DONE. Why it does not erase it self from 
> Agenda view? Is it possible? Or not?

1. You can run C-u -1 C-c C-t to inhibit the repeater (see org-todo
docstring; C-h f org-todo )
2. Check out org-agenda-skip-timestamp-if-done

> 2)
> Is the a way to set recursive events like “the firs Friday of the month” or 
> each Tuesday of the month, not date-related (I mean: with +1 w I add the 
> event the days x +7 days. Isn’t it?

See diary-style timestamps in https://orgmode.org/manual/Timestamps.html

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



Re: idea for capture anywhere in x

2022-10-12 Thread Ihor Radchenko
Ypo  writes:

> What if:
> 1. It were easy and immediate to open in ~eww~ any web page that we are 
> reading in "x".

Check out org-protocol.el commentary.

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



Re: Get the "closest" property value

2022-10-12 Thread Ihor Radchenko
George Mauer  writes:

> If I have a document what looks like the following. What code could I run
> for the ??? to get the property value for "workspace-directory" that is
> closest in the outline to the location running the code?
>
> * Top Level
>   :PROPERTIES:
>   :workspace-directory: /tmp
>   :END:
>
>#+begin_src emacs-lisp
>  (???) ; /tmp
>#+end_src

#+begin_src emacs-lisp :var prop-value=(org-entry-get (point) 
"workspace-directory")
prop-value
#+end_src

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



Re: [PATCH] (v2) Fix void variable error `cider-buffer-ns` when specifying :backend header argument

2022-10-12 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> After updated to latest commit, I found error,
>>
>> Reproduce:
>>
>> When I specified the `:backend` header argument:
>>
>> #+begin_src clojure :backend babashka
>> (+ 2 4)
>> #+end_src
>>
>> I got error:
>>
>> #+begin_example
>> void variable: cider-buffer-ns
>> #+end_example
>
> Thanks for reporting!
>
>> Here is the patch fix upper issue.
>>
>>(let* ((vars (org-babel--get-vars params))
>> + (backend-override (cdr (assq :backend params)))
>>   (ns (or (cdr (assq :ns params))
>> - (if (eq org-babel-clojure-backend 'cider)
>> + (if (and (not backend-override)
>> +  (eq org-babel-clojure-backend 'cider))
>>   (or cider-buffer-ns
>>   (let ((repl-buf (cider-current-connection)))
>> (and repl-buf (buffer-local-value
>
> What if backend-override is 'cider?
> I suggest to let-bind
> (org-babel-clojure-backend
>   (cond
>(backend-override (intern backend-override))
>(org-babel-clojure-backend org-babel-clojure-backend)
>(t (user-error "You need to customize `org-babel-clojure-backend'
> or set the `:backend' header argument"
>
> Just like in `org-babel-execute:clojure'.

You're right, updated now.

From 1ecdcc596c8447fcf96ff400f544c0adc680c8fc Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Wed, 12 Oct 2022 17:27:58 +0800
Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with
 `org-babel-clojure-backend'

* lisp/ob-clojure.el (org-babel-expand-body:clojure): When The source
block specified header argument :backend, the global option
`org-babel-clojure-backend' value is default 'cider, the
`cider-buffer-ns` is not void error.
---
 lisp/ob-clojure.el | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index d6f860e98..0649469b3 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -104,6 +104,13 @@
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let* ((vars (org-babel--get-vars params))
+ (backend-override (cdr (assq :backend params)))
+ (org-babel-clojure-backend
+  (cond
+   (backend-override (intern backend-override))
+   (org-babel-clojure-backend org-babel-clojure-backend)
+   (t (user-error "You need to customize `org-babel-clojure-backend'
+or set the `:backend' header argument"
 	 (ns (or (cdr (assq :ns params))
 		 (if (eq org-babel-clojure-backend 'cider)
 		 (or cider-buffer-ns
-- 
2.37.2


-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


signature.asc
Description: PGP signature


Re: watch YT videos through in Emacs [Was: Interest in an Org video meetup?]

2022-10-12 Thread Ihor Radchenko
Quiliro Ordóñez  writes:

> Hola Juan Manuel.
>
>> There is the YouTube option, which I imagine no one would like (me
>> neither). The only thing in its favor is that Invidious can be used to
>> watch the videos. BTW, I watch YT videos through Invidious in Emacs,
>> with the Ytel package and EMMS/MPV.
>
> Nice.  Is there a guide to do this specificly?

I simply use

#+begin_src bash :tangle ~/.local/bin/qutebrowser-call.sh :shebang #!/bin/bash
URL="$1"

if echo "$URL" | grep "youtube.com"; then
# URL="$(echo "$URL" | sed -r 
's/\\(www\\)?youtube\.com/invidious.namazso.eu/')"
if [[ ! -z $(echo "$URL" | grep "/watch") ]]; then 
mpv $URL && exit;
fi
fi

if echo "$URL" | grep "ted.com/talks"; then
mpv $URL && exit;
fi

# if echo "$URL" | grep "reddit.com"; then
# URL="$(echo "$URL" | sed -rE 's/www\.reddit\.com/libredd.it/')"
# fi

if echo "$URL" | grep "bilibili.com"; then
mpv $URL && exit;
fi

grep "$URL" ~/.data/web-mirror/sources/* >/dev/null 2>&1 &&\
ARCHIVE_DIR="$(echo "$URL" | archivebox-cmd list 2>/dev/null | tail -n1 | 
cut -d' ' -f1  | sed -r 's|/data|~/.data/web-mirror|')"

if [[ ! -z "$ARCHIVE_DIR" ]]; then
[[ -f "${ARCHIVE_DIR}/singlefile.html" ]] && 
URL="${ARCHIVE_DIR}/singlefile.html";
fi

#from 
https://github.com/qutebrowser/qutebrowser/blob/master/scripts/open_url_in_instance.sh
_url="$URL"
_command=":later 4000 :jump-mark last-position"

qutebrowser "${_command}" ":spawn -u untrack-url -r -O ${_url}"

#+end_src

and my mpv is configured to use youtube-dl.

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



Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread gerard . vermeulen




On 12.10.2022 07:55, Max Nikulin wrote:

On 12/10/2022 12:15, gerard.vermeulen wrote:

On 12.10.2022 06:45, Max Nikulin wrote:


LuaLaTeX is irrelevant. It seems \hline is allowed only immediately
after \\. Minimal LaTeX example:

\begin{tabular}{l}
b\\\relax
\hline
\end{tabular}


Your example fails on my Mac texlive-2020 with:

! Misplaced \noalign.
\hline ->\noalign
   {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth 
\futurelet...


l.40 \hline

It compiles when I remove \hline


Gerard, we forgot to post the reason why \relax has been added after
\\. The intention was to  prevent errors in the case of

| a   |
| [b] |

or

- item \\
  [2022-10-12]

Stewart Thomas. [BUG] Tables with square brackets do not compile in
PDF (latex) export. Wed, 10 Nov 2021 11:16:10 -0500.
https://list.orgmode.org/cao12v+wb18nan0fudpaen94ghdt_2nbdjtc4u7n4w3hazba...@mail.gmail.com

I can not figure out an easy way to separate \\ from [b] text but to
prevent the problem you have discovered. I am unsure if

\\[0pt]

has no negative consequences and safe enough. I expect that LaTeX
sources are not easy to read when fragile sequences of tokens are
involved.

I just have realized that some users might take advantage of earlier
behavior as a feature:

- item \\
  [1cm]
- item

I think that [1cm] should be treated as text, however I have no idea
how to allow users to specify amount of vertical space and to not
limit line break to LaTeX only. @@latex:\\[1cm]@@ is not suitable when
the same text should be exported to ascii, html, etc.


Max, thanks for the background information.

For your info:
1. I also need to remove \relax in the LaTeX export using Gentoo 
texlive-2022 to compile.

2. On my systems ws-butler removes the trailing whitespace.
3. I edited your example with nano to add the trailing space after 
\relax, but it still does not compile.





Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread Max Nikulin

On 12/10/2022 14:26, Ihor Radchenko wrote:

Max Nikulin writes:


I can not figure out an easy way to separate \\ from [b] text but to
prevent the problem you have discovered. I am unsure if

  \\[0pt]

has no negative consequences and safe enough. I expect that LaTeX
sources are not easy to read when fragile sequences of tokens are involved.


What about adding \relax in front of table rows instead of at the end?
The hlines are transcoded separately.

All other instances of \\\relax may remain.


If you see a way to implement it, you may try. Do not forget a space 
after it. Spaces at the beginning of line are insignificant, so 
insertion of \relax should not cause more ignored spaces than it was 
before. I would consider skipping "\relax " in the beginning of rows 
where first cell starts from an export snippet.


I am considering \noalign{} instead of \relax. I was never aware of its 
effect, but accordingly to The TeXbook it should keep TeX in vertical 
mode without any action due to empty argument. (Actually I surprised 
that \relax causes any change of internal state besides parser.) 
Unfortunately \noalign{} just as \relax will not allow @@latex:[1cm]@@ 
on the next line, perhaps @@latex:\noalign{\vskip 1cm}@@ is a workaround 
to introduce additional vertical space.


\\[0pt]

causes insertion of some code for negative vertical skip (of zero height 
this case). It should not be really harmful, but I would avoid this hack.


I never used \\* or \\*[10pt] variants of the command. Current stable 
release should has problems when the line next to \\ starts from * that 
is not bold marker, besides square brackets.






Re: [BUG] org-beamer :BEAMER_ACT: ignored on columns

2022-10-12 Thread Fraga, Eric
Hi Ihor,

On Wednesday, 12 Oct 2022 at 14:00, Ihor Radchenko wrote:
> Your patch adds for columns

All I did was copy the code that was there for options and adapted for
actions.  I really do not understand what the rest of the code does and
really do not have the time (due to teaching obligations) to investigate
in more detail.  Sorry.  The patch solved the OP's problem...

I will try to have a better look in a few weeks when my teaching duties
subside a bit.

>  ;; also process actions
>  (raw-actions (org-element-property :BEAMER_ACT headline))
>  (actions (if raw-actions
>   (org-beamer--normalize-argument raw-actions 'action)
> ""))

[...]

> I do not know if [xxx] vs xxx makes any difference for columns, but it

The org-beamer--normalize-argument function ensures that the action is
enclosed in [<...>] and [...] for options.

-- 
: Eric S Fraga, with org release_9.5.5-966-g88c85d in Emacs 29.0.50


Re: [PATCH] Re: [BUG] org-agenda-remove-restriction-lock does not remove file lock [9.5.2 (release_9.5.2-17-gea6b74 @ /nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-20220225.0/share/emacs/29.0.

2022-10-12 Thread Ihor Radchenko
Liu Hui  writes:

> I have added docstrings for related variables except
> `org-agenda-last-dispatch-buffer', which is actually not used by any
> other org-mode code. Please see the patch below.
>
> From 907499f16769e5a5353170c13f09595584530139 Mon Sep 17 00:00:00 2001
> From: Liu Hui 
> Date: Wed, 12 Oct 2022 14:02:05 +0800
> Subject: [PATCH] org-agenda: Make sure file restriction can be removed

Thanks!
Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c57b03032380de519bafcf903ca9236668038d4e

I also removed the unused variable
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=416c839c59a6186ca4f6cdd179c628ef49cd6c99

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



Re: Export of this table fails LuaLaTeX compilation

2022-10-12 Thread Ihor Radchenko
Max Nikulin  writes:

> Gerard, we forgot to post the reason why \relax has been added after \\. 
> The intention was to  prevent errors in the case of
>
> | a   |
> | [b] |
>
> or
>
> - item \\
>[2022-10-12]
>
> Stewart Thomas. [BUG] Tables with square brackets do not compile in PDF 
> (latex) export. Wed, 10 Nov 2021 11:16:10 -0500. 
> https://list.orgmode.org/cao12v+wb18nan0fudpaen94ghdt_2nbdjtc4u7n4w3hazba...@mail.gmail.com
>
> I can not figure out an easy way to separate \\ from [b] text but to 
> prevent the problem you have discovered. I am unsure if
>
>  \\[0pt]
>
> has no negative consequences and safe enough. I expect that LaTeX 
> sources are not easy to read when fragile sequences of tokens are involved.

What about adding \relax in front of table rows instead of at the end?
The hlines are transcoded separately.

All other instances of \\\relax may remain.

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



Re: problem with the on-line manual

2022-10-12 Thread Ihor Radchenko
Giuseppe Lipari  writes:

> I would like to point out that the following link in the org-mode on-line
> manual is broken :
>
>   https://orgmode.org/manual/Images-in-LaTeX-export.html
>
> can someone please fix/restore it ?

Fixed. At least for now.
We are currently adjusting server rewrite rules.
See https://list.orgmode.org/ti5ifn$7g1$1...@ciao.gmane.io/T/#t

Let us know if you notice any other broken links.

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



Re: [PATCH] LSP support in org-src buffers

2022-10-12 Thread Ihor Radchenko
Karthik Chikmagalur  writes:

>> You already implemented a way to associate the org-edit-src buffer with
>> the fully tangled code. Then, why not make it simple and do the real
>> tangling first and then make org-edit-src work directly with a real
>> file buffer associated with the tangled file?
>
> This will drastically simplify the patch, true.  I was working on the 
> assumption that since tangling overwrites the file on disk, it should not be 
> an implicit operation invoked as a side-effect of another action.  It causes 
> other changes that the user might not have intended, like updating timestamps 
> on the tangled file, etc.  What do you suggest?
>
> Moreover, for Eglot to function correctly it is sufficient to (i) associate 
> the buffer with a file -- any file, and (ii) Set the default-directory 
> variable to the correct value.   "Tangling" to a file in /tmp (as I do in the 
> patch) will not work with all the non-Eglot use-cases you describe above.

Then, I suggest to not actually write things on the disk. Instead, we
can augment `org-edit-src-save' to write on disk depending on some
customization (with values t, nil, and 'ask). That customization will,
by default, make `org-edit-src-save' query user if it is desired to
write files on disk.

Also, note that once you associate buffer with a file, various
auto-saving mechanisms may write the file to disk without user consent.
We may also need to look into write-contents-functions to prevent such
scenarios when undesired.

>> The only tricky problem I am seeing with your approach is dealing with
>> noweb references. Care should be taken about editing code blocks
>> containing noweb.
>
> If I reuse the actual tangling machinery in ob-tangle instead of writing my 
> own version reusing only some of the primitives in this library, this should 
> be handled automatically for me.  Is this correct?

No.

`org-edit-special' will _not_ expand noweb.
`org-babel-expand-src-block' will.

In the first case, <> syntax may drive native syntax checkers
crazy. In the second case, care should be taken to prevent editing the
noweb-replaced text. This distinction is something we would not want to
break.

Also, be aware that some <> references may involve code execution,
possibly on remote machines. Remote execution might be undesired during
normal editing. I am not 100% sure how to approach this problem in a
reliable way that will fit all the uses.

> Also: org-src-context-mode works by advising some org-edit-src-* functions.  
> Is it preferable to edit these functions directly instead and add a check for 
> whether org-src-context-mode is enabled?

I am not even sure if a separate org-src-context-mode is needed. It
could be simply a customization for org-edit-special rather than a minor
mode.

So, I am all for editing the functions directly and more complete
integration.

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



Re: [FR] [Revived] Human readable / customizable link anchors during export

2022-10-12 Thread Ihor Radchenko
Kévin Le Gouguec  writes:

>> 3. Instead of trying to find a silver bullet for human-readable anchor
>>generator, we allow users to customize it. The default will be
>>constant "org" yielding "org-Ajjq"-type anchors, just like we have
>>now. But we can also provide other generators, like the one Timothy
>>proposed, or better versions contributed in future if there is
>>demand.
>
> Personally, I'd be wholly satisfied with a customization option; the
> grail for me would be [pandoc's algorithm], which doesn't look too hard
> to reimplement in one's config.
>
> (Although the collision-handling logic could be tricky: since it
> revolves around appending a counter to the ID, it needs to keep track of
> how many times the same ID has been generated for the whole document.
> If the generator API is just {heading ↦ ID}, i.e. there is no extra
> "context" argument, one will need to do some bookkeeping "on the
> side"…)

The collision-handling should not concern the anchor generator code. If
an anchor generator returns a duplicate ID, we can just append some
symbols to make it unique. All the bookkeeping has to be made in
centralized way on ox.el side.

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



Re: [PATCH] Org Habit fix + new feature

2022-10-12 Thread Ihor Radchenko
Morgan Smith  writes:

> The second patch allows a habit to be considered done if time was logged
> to it.  Imagine you have an org habit like shaving.  Chances are, if you
> spend time doing it, it's done.  I like to set LOGGING to nil for these
> kinds of habits since it's redundant to have all those state changes
> that tell me exactly what the logbook already tells me.

I am not against such feature. However, using clocking will break an
assumption that a single log record corresponds to a single habit
completion. This assumption is implied across org-habit code.  

> From cc16dd6a8c59312a75b8e25669a7e4eb3d9f9ef4 Mon Sep 17 00:00:00 2001
> From: Morgan Smith 
> Date: Tue, 11 Oct 2022 11:44:26 -0400
> Subject: [PATCH 1/2] lisp/org-habit.el: Use time as a history cutoff point
>
> * lisp/org-habit.el (org-habit-parse-todo): Use time as a cutoff point
> instead of using a count.
>
> This allows viewing the full history of habits that are completed
> multiple times a day.  Previously we would miss some days and show an
> incorrect history

There is currently nothing in the manual or function docstring that
suggest supporting habits that are repeated multiple times a day.

5.3.3 Tracking your habits section of the manual says:

   What’s really useful about habits is that they are displayed along
with a consistency graph, to show how consistent you’ve been at getting
that task done in the past.  This graph shows every day that the task
was done over the past three weeks, with colors for each day.  The
colors used are:

Explicitly saying that each symbol in the graph corresponds to a single
day.

Further, org-habit-preceding-days and org-habit-following-days are
explicitly talking about days, not repetitions.

> -  (let* ((maxdays (+ org-habit-preceding-days org-habit-following-days))
> +  (let* ((firstday (- (org-today) org-habit-preceding-days))

What about org-habit-following-days? Why did you throw it away?
Also, (org-today) does not consider org-extend-today-until. (see
org-habit-insert-consistency-graphs).

>(re (format
> -   "^[ \t]*-[ \t]+\\(?:State \"%s\".*%s%s\\)"
> +   "^[ \t]*-[ \t]+\\(?:State \"%s\".*%s%s\\)%s"
> (regexp-opt org-done-keywords)
> org-ts-regexp-inactive
> (let ((value (cdr (assq 'done org-log-note-headings
> @@ -233,15 +238,20 @@ This list represents a \"habit\" for the rest of this 
> module."
>("%t" . ,org-ts-regexp-inactive)
>("%T" . ,org-ts-regexp)
>("%u" . ".*?")
> -  ("%U" . ".*?")
> +  ("%U" . ".*?"))
> +  (if org-habit-clock-completes-habit
> +  (concat
> +   "\\|^" org-clock-string ".*\\]--\\(\\[[^]]+\\]\\)")
> +""

This logic will fail for non-default combinations of org-log-into-drawer
+ org-clock-into-drawer + org-log-states-order-reversed.

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



Re: [PATCH] Re: [BUG] org-agenda-remove-restriction-lock does not remove file lock [9.5.2 (release_9.5.2-17-gea6b74 @ /nix/store/iqqk7iqfwmfc6r78xg2knyq7hww2mhs4-emacs-git-20220225.0/share/emacs/29.0.

2022-10-12 Thread Liu Hui

Hi Ihor,

Ihor Radchenko  writes:

> Could you please add docstrings and possibly code comments for
> `org-agenda-restrict', `org-agenda-restrict-begin',
> `org-agenda-restrict-end', `org-agenda-last-dispatch-buffer', and
> possibly other elated variables?

I have added docstrings for related variables except
`org-agenda-last-dispatch-buffer', which is actually not used by any
other org-mode code. Please see the patch below.

>From 907499f16769e5a5353170c13f09595584530139 Mon Sep 17 00:00:00 2001
From: Liu Hui 
Date: Wed, 12 Oct 2022 14:02:05 +0800
Subject: [PATCH] org-agenda: Make sure file restriction can be removed

* lisp/org-agenda.el: (org-agenda-restrict):
(org-agenda-restrict-begin):
(org-agenda-restrict-end):
(org-agenda-overriding-restriction): add docstrings.
(org-agenda):
(org-agenda-set-restriction-lock): Set `org-agenda-restrict' non-nil
during both temporary and extended file restriction.
(org-agenda-remove-restriction-lock): Revert commit df0e96ba4.
* testing/lisp/test-org-agenda.el (test-org-agenda/file-restriction):
Add a test.
---
 lisp/org-agenda.el  | 43 +
 testing/lisp/test-org-agenda.el | 28 +
 2 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 86ed6a5f5..82ca2913a 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2202,7 +2202,17 @@ string that it returns."
 (org-remap org-agenda-mode-map 'move-end-of-line 'org-agenda-end-of-line)
 
 (defvar org-agenda-menu) ; defined later in this file.
-(defvar org-agenda-restrict nil)
+(defvar org-agenda-restrict nil
+  "Non-nil means agenda restriction is active.
+This is an internal flag indicating either temporary or extended
+agenda restriction.  Specifically, it is set to t if the agenda
+is restricted to an entire file, and is set to the corresponding
+buffer if the agenda is restricted to a part of a file, e.g. a
+region or a substree.  In the latter case,
+`org-agenda-restrict-begin' and `org-agenda-restrict-end' are set
+to the beginning and the end of the part.
+
+See also `org-agenda-set-restriction-lock'.")
 (defvar org-agenda-follow-mode nil)
 (defvar org-agenda-entry-text-mode nil)
 (defvar org-agenda-clockreport-mode nil)
@@ -2734,10 +2744,16 @@ that have been changed along."
 
 ;;; Agenda dispatch
 
-(defvar org-agenda-restrict-begin (make-marker))
-(defvar org-agenda-restrict-end (make-marker))
+(defvar org-agenda-restrict-begin (make-marker)
+  "Internal variable used to mark the restriction beginning.
+It is only relevant when `org-agenda-restrict' is a buffer.")
+(defvar org-agenda-restrict-end (make-marker)
+  "Internal variable used to mark the restriction end.
+It is only relevant when `org-agenda-restrict' is a buffer.")
 (defvar org-agenda-last-dispatch-buffer nil)
-(defvar org-agenda-overriding-restriction nil)
+(defvar org-agenda-overriding-restriction nil
+  "Non-nil means extended agenda restriction is active.
+This is an internal flag set by `org-agenda-set-restriction-lock'.")
 
 (defcustom org-agenda-custom-commands-contexts nil
   "Alist of custom agenda keys and contextual rules.
@@ -2962,12 +2978,12 @@ Pressing `<' twice means to restrict to the current subtree or region
 	(move-marker org-agenda-restrict-begin (point))
 	(move-marker org-agenda-restrict-end
 			 (progn (org-end-of-subtree t)
-	 ((and (eq restriction 'buffer)
-	   (or (< 1 (point-min))
-		   (< (point-max) (1+ (buffer-size)
-	  (setq org-agenda-restrict (current-buffer))
-	  (move-marker org-agenda-restrict-begin (point-min))
-	  (move-marker org-agenda-restrict-end (point-max)
+	 ((eq restriction 'buffer)
+  (if (not (buffer-narrowed-p))
+  (setq org-agenda-restrict t)
+(setq org-agenda-restrict (current-buffer))
+	(move-marker org-agenda-restrict-begin (point-min))
+	(move-marker org-agenda-restrict-end (point-max))
 
   ;; For example the todo list should not need it (but does...)
   (cond
@@ -7958,7 +7974,7 @@ subtree."
 	  (message "Locking agenda restriction to subtree"))
   (put 'org-agenda-files 'org-restrict
 	   (list (buffer-file-name (buffer-base-buffer
-  (setq org-agenda-restrict nil)
+  (setq org-agenda-restrict t)
   (setq org-agenda-overriding-restriction 'file)
   (move-marker org-agenda-restrict-begin nil)
   (move-marker org-agenda-restrict-end nil)
@@ -7969,14 +7985,11 @@ subtree."
 (defun org-agenda-remove-restriction-lock ( noupdate)
   "Remove agenda restriction lock."
   (interactive "P")
-  (if (not (or org-agenda-restrict org-agenda-overriding-restriction))
+  (if (not org-agenda-restrict)
   (message "No agenda restriction to remove.")
 (delete-overlay org-agenda-restriction-lock-overlay)
 (delete-overlay org-speedbar-restriction-lock-overlay)
 (setq org-agenda-overriding-restriction nil)
-(unless org-agenda-keep-restricted-file-list
-  ;; There is a request 

Re: [PATCH] Org Habit fix + new feature

2022-10-12 Thread Colin Baxter
> Morgan Smith  writes:

> Hello,

> Colin Baxter  writes:

>> Please do not alter the default behaviour. When writing a paper
>> or a book I use and need both logging and state changes, and I
>> would prefer not to have to spend time changing my setup.

> Don't worry, this shouldn't change the default behavior in the
> slightest.

> Morgan

Thank you.



Re: [PATCH] Fix void variable error `cider-buffer-ns` when specifying :backend header argument

2022-10-12 Thread Ihor Radchenko
"Christopher M. Miles"  writes:

> After updated to latest commit, I found error,
>
> Reproduce:
>
> When I specified the `:backend` header argument:
>
> #+begin_src clojure :backend babashka
> (+ 2 4)
> #+end_src
>
> I got error:
>
> #+begin_example
> void variable: cider-buffer-ns
> #+end_example

Thanks for reporting!

> Here is the patch fix upper issue.
>
>(let* ((vars (org-babel--get-vars params))
> + (backend-override (cdr (assq :backend params)))
>(ns (or (cdr (assq :ns params))
> -  (if (eq org-babel-clojure-backend 'cider)
> +  (if (and (not backend-override)
> +  (eq org-babel-clojure-backend 'cider))
>(or cider-buffer-ns
>(let ((repl-buf (cider-current-connection)))
>  (and repl-buf (buffer-local-value

What if backend-override is 'cider?
I suggest to let-bind
(org-babel-clojure-backend
  (cond
   (backend-override (intern backend-override))
   (org-babel-clojure-backend org-babel-clojure-backend)
   (t (user-error "You need to customize `org-babel-clojure-backend'
or set the `:backend' header argument"

Just like in `org-babel-execute:clojure'.

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



Re: [BUG] org-beamer :BEAMER_ACT: ignored on columns

2022-10-12 Thread Ihor Radchenko
"Fraga, Eric"  writes:

> On Saturday,  8 Oct 2022 at 14:10, Ihor Radchenko wrote:
>> This patch certainly adds code duplication and might also miss some
>> scenarios considered in the environments from
>> org-beamer-environments-default.
>
> I'm not sure what code duplication you are referring to unless it's the
> two lines that now address actions and are similar to those for options.
> The comments you referenced are from the original code.

Let me elaborate.

Your patch adds for columns

 ;; also process actions
 (raw-actions (org-element-property :BEAMER_ACT headline))
 (actions (if raw-actions
  (org-beamer--normalize-argument raw-actions 'action)
""))

but the existing code also have

  (let ((action (org-element-property :BEAMER_ACT headline)))

at least :BEAMER_ACT is acquired redundantly.

Further, the old code has

 ((and (string-prefix-p "[" action)
   (string-suffix-p "]" action))
  (list
   (cons "A" (org-beamer--normalize-argument action 'defaction))
   (cons "a" "")
   (cons "R" action)))
 (t
  (list (cons "a" (org-beamer--normalize-argument action 'action))

So, depending on the :BEAMER_ACT value (if it is enclosed into [xxx]),
it is parsed differently.

---

I do not know if [xxx] vs xxx makes any difference for columns, but it
is generally not very clear why there is a distinction in one case but
not another. If using (org-beamer--normalize-argument raw-actions
'action) unconditionally (rather than 'defaction or 'action) is ok, at
least it deserves a comment in the code.

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