Re: [PATCH]: ox-latex: omit empty date

2022-08-05 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Daniel Fleischer  writes:
>
>> Daniel Fleischer [2022-07-31 Sun 18:25] wrote:
>>
>> In other words \date{} is what prevents from the date being printed. Or
>> put differently \date{\today} and not putting \date is equivalent. See
>> http://www.emerson.emory.edu/services/latex/latex_125.html.
>
> Would you mind adding a short comment to the code of
> `org-latex-template' explaining this pitfall?

For record, this comment has been added in 5a49cc5f4.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5a49cc5f4f09910fd03d5db590ae2b80f5981a66

Best,
Ihor



Re: [PATCH]: ox-latex: omit empty date

2022-08-01 Thread Max Nikulin

On 01/08/2022 17:55, emacs--- via General discussions about Org-mode. wrote:

*later in this mail)*
  ;; Date.
  (let ((date (and (plist-get info :with-date) (org-export-get-date 
info

    (if (string-match-p "^\{.*\}$" (org-export-data date info))
    (format "\\date%s\n" (org-export-data date info))
  (format "\\date{%s}\n" (org-export-data date info


I am against such code.


_Why mostly:_
At the moment the code escapes the provided brackets and the current 
behaviour is

#+date: {my}{fancy}{date} -> \date\{my\}\{fancy\}\{date\}


#+date: @@latex:{my}{fancy}{date}@@

Anyway such date is not suitable for other backends.

I think, custom command name and "#+latex_header:" with such command is 
proper solution.


It is possible to choose some combination of existing options like

#+options: date:t
#+date:

as instruction to not add the \date command, but I think it would be 
confusing for users and anyway a breaking change for some of them.


I suppose, reverting the patch was the proper step.



Re: [PATCH]: ox-latex: omit empty date

2022-08-01 Thread General discussions about Org-mode.



> emacs--- via "General discussions about Org-mode."
>  writes:
>
>> My use case is very niche and be solved by changing my custom latex date 
>> command by renaming it as for example \mydate.
>>
>> Adding extra options like with_date:nil seems overkill for this small issue.
>>
>
> I agree; I think we shouldn't change basic behavior for more advanced
> usages unless it's something many people are interested in and we keep a
> backward compatibility.
>
>> A second option would be is to analyze the data format in the org file.
>> If for example the date is specified as 
>> #+date: {day}{something}
>>
>
> The thing is \date is a macro with one parameter, a string. That's way
> \date{} doesn't do anything and \date{\today} prints today's date where
> \today return today's date as a string. Starting to introduce new kinds
> of inputs - e.g. {y}{m}{d} - to the \date macro would just confuse
> people, I think.
>

It is an optional use pattern and the old options wil still work. 
The following code would "mostly" does the trick (I come back at the mostly term
later in this mail) ;; Date.
 (let ((date (and (plist-get info :with-date) (org-export-get-date info
   (if (string-match-p "^\{.*\}$" (org-export-data date info))
   (format "\\date%s\n" (org-export-data date info))
 (format "\\date{%s}\n" (org-export-data date info

Dates can now de set as, and exported to: 
#+date: some date  -> \date{some date}
#+date: my {date} -> \date{my \{date\}}
#+date: {my}{fancy}{date} -> \date{my}{fancy}{date}
#+date: {} -> \date{}

Why mostly:
At the moment the code escapes the provided brackets and the current behaviour 
is 
#+date: {my}{fancy}{date} -> \date\{my\}\{fancy\}\{date\}
#+date: {} -> \date\{\}
which is not correct and I cant seem to find a good way to alter the format 
command to 
not escape the special characters. Tips are appreciated. 

A general Remark: I feel that passing latex options by their literal value i.e. 
including all 
latex formatting and brackets, would be a good general addition to the 
exporter. I can 
imagine use cases where the author command is also overwritten to format names 
differently
at different locations in the document. As in 
#+author: {title}{name}{sir name}
#+author: {name}{thanks}{special thanks}
It gives the end user way more control over the final document and does not 
break any
backward compatibility.

Kind regards 
Bob 








Re: [PATCH]: ox-latex: omit empty date

2022-08-01 Thread Daniel Fleischer
emacs--- via "General discussions about Org-mode."
 writes:

> My use case is very niche and be solved by changing my custom latex date 
> command by renaming it as for example \mydate.
>
> Adding extra options like with_date:nil seems overkill for this small issue. 

I agree; I think we shouldn't change basic behavior for more advanced
usages unless it's something many people are interested in and we keep a
backward compatibility.

> A second option would be is to analyze the data format in the org file.
> If for example the date is specified as 
> #+date: {day}{something}

The thing is \date is a macro with one parameter, a string. That's way
\date{} doesn't do anything and \date{\today} prints today's date where
\today return today's date as a string. Starting to introduce new kinds
of inputs - e.g. {y}{m}{d} - to the \date macro would just confuse
people, I think.

Daniel



Re: [PATCH]: ox-latex: omit empty date

2022-08-01 Thread General discussions about Org-mode.
On 31/07/2022 09:38, Ihor Radchenko wrote:

>> Max Nikulin writes:
>>
 All the above makes sense. Do I miss something?

>>>
>>> To be precise, \date is not exported to LaTeX file, but current date
>>> appears in PDF. That is why I consider the change as a breaking one.
>>>
>>> Try to export to PDF the following document.
>>>
>>>  >8 
>>> #+options: title:t
>>> # #+options: date:nil
>>> # #+date:
>>> #+title: Title
>>> test
>>>  8< 
>>>
>>> PDF file is produced with current date. Before the patch it was possible
>>> to suppress date in PDF file by removing comment for either "#+options:
>>> date:nil" or for "#+date:". With current main branch HEAD some other
>>> workaround is required. I think, it is not what is expected from the
>>> description of the #+options: keyword:
>>>
>>
>> Agree. I did not know about this LaTeX default.
>>
>> Bob, do you have any ideas? I am inclined to revert the patch.
>>
>
> We may ask the maintainer of ox-latex Daniel Fleischer if a better way to 
> handle \date exists.
>
> Bob, could you, please, provide more detail concerning your use case and the 
> purpose of the patch?
>
I was only looking at removing the empty date command string from my tex files. 
But I acknowledge the fact that it now generates an unwanted default date in 
the 
latex pdf file when "date:nil" is provided. 

In my use case, my template overwrites the date command and a date should be 
passed as 
\date{day}{month}{year}.
My template uses different formats for the date in different locations of the 
text. 
E.g. copyright notice, front cover, preface,...

My use case is very niche and be solved by changing my custom latex date 
command by renaming it as for example \mydate.

Adding extra options like with_date:nil seems overkill for this small issue. 

A second option would be is to analyze the data format in the org file.
If for example the date is specified as 
#+date: {day}{something}
and the regex \{.*\}  matches, then the date can be used as
and we use 
 (format "\\date%s\n" (org-export-data date info
instead of 
 (format "\\date{%s}\n" (org-export-data date info

This is non breaking and would not require any extra options to be passed on to 
the exporter. 
In this case, the date can also be suppressed by using 
#+date: {}

Kind regards,
Bob


Re: [PATCH]: ox-latex: omit empty date

2022-07-31 Thread Ihor Radchenko
Daniel Fleischer  writes:

> Daniel Fleischer [2022-07-31 Sun 18:25] wrote:
>
> In other words \date{} is what prevents from the date being printed. Or
> put differently \date{\today} and not putting \date is equivalent. See
> http://www.emerson.emory.edu/services/latex/latex_125.html.

Would you mind adding a short comment to the code of
`org-latex-template' explaining this pitfall?

Best,
Ihor



Re: [PATCH]: ox-latex: omit empty date

2022-07-31 Thread Daniel Fleischer
Daniel Fleischer [2022-07-31 Sun 18:25] wrote:

> I would reckon people don't want the date displayed when they set it to
> nil. But removing the line \date{} just prints today's date. I don't
> understand the purpose of the patch.

In other words \date{} is what prevents from the date being printed. Or
put differently \date{\today} and not putting \date is equivalent. See
http://www.emerson.emory.edu/services/latex/latex_125.html.

Daniel



Re: [PATCH]: ox-latex: omit empty date

2022-07-31 Thread Daniel Fleischer
emacs--- via "General discussions about Org-mode." [2022-07-29 Fri 14:49] wrote:

> In the attachment you can find a patch which omits an empty \date{} line in
> a latex document when the option to include the date is set to nil or when 
> no date is provided. This empty date line can cause problems is certain 
> use cases. 

Sorry for the late response.

I would reckon people don't want the date displayed when they set it to
nil. But removing the line \date{} just prints today's date. I don't
understand the purpose of the patch.

Daniel



Re: [PATCH]: ox-latex: omit empty date

2022-07-31 Thread Max Nikulin

On 31/07/2022 09:38, Ihor Radchenko wrote:

Max Nikulin writes:


All the above makes sense. Do I miss something?


To be precise, \date is not exported to LaTeX file, but current date
appears in PDF. That is why I consider the change as a breaking one.

Try to export to PDF the following document.

 >8 
#+options: title:t
# #+options: date:nil
# #+date:
#+title: Title
test
 8< 

PDF file is produced with current date. Before the patch it was possible
to suppress date in PDF file by removing comment for either "#+options:
date:nil" or for "#+date:". With current main branch HEAD some other
workaround is required. I think, it is not what is expected from the
description of the #+options: keyword:


Agree. I did not know about this LaTeX default.

Bob, do you have any ideas? I am inclined to revert the patch.


We may ask the maintainer of ox-latex Daniel Fleischer if a better way 
to handle \date exists.


Bob, could you, please, provide more detail concerning your use case and 
the purpose of the patch?




Re: [PATCH]: ox-latex: omit empty date

2022-07-30 Thread Ihor Radchenko
Max Nikulin  writes:

>> All the above makes sense. Do I miss something?
>
> To be precise, \date is not exported to LaTeX file, but current date 
> appears in PDF. That is why I consider the change as a breaking one.
>
> Try to export to PDF the following document.
>
>  >8 
> #+options: title:t
> # #+options: date:nil
> # #+date:
> #+title: Title
> test
>  8< 
>
> PDF file is produced with current date. Before the patch it was possible 
> to suppress date in PDF file by removing comment for either "#+options: 
> date:nil" or for "#+date:". With current main branch HEAD some other 
> workaround is required. I think, it is not what is expected from the 
> description of the #+options: keyword:

Agree. I did not know about this LaTeX default.

Bob, do you have any ideas? I am inclined to revert the patch.

Best,
Ihor



Re: [PATCH]: ox-latex: omit empty date

2022-07-30 Thread Max Nikulin

On 31/07/2022 07:53, Ihor Radchenko wrote:

Max Nikulin writes:


   (let ((date (and (plist-get info :with-date) (org-export-get-date 
info
-   (format "\\date{%s}\n" (org-export-data date info)))
+   (cond date


I would consider (plist-get info :with-date) instead of date here to
allow to suppress date in the title by

#+options: title:t date:t
#+date:

With such approach to avoid \date{} in the latex file date:nil can be
used in the options line.


+ (format "\\date{%s}\n" (org-export-data date info


I am sorry, but I do not understand.

I tried

#+options: title:t date:nil

No \date is exported.

#+options: title:t date:t

\date is exported

#+options: title:t date:t
#+date:

No date is export.

All the above makes sense. Do I miss something?


To be precise, \date is not exported to LaTeX file, but current date 
appears in PDF. That is why I consider the change as a breaking one.


Try to export to PDF the following document.

 >8 
#+options: title:t
# #+options: date:nil
# #+date:
#+title: Title
test
 8< 

PDF file is produced with current date. Before the patch it was possible 
to suppress date in PDF file by removing comment for either "#+options: 
date:nil" or for "#+date:". With current main branch HEAD some other 
workaround is required. I think, it is not what is expected from the 
description of the #+options: keyword:



‘date:’
 Toggle inclusion of a date into exported file
 (‘org-export-with-date’).


info "(org) Export Settings" https://orgmode.org/manual/Export-Settings.html



Re: [PATCH]: ox-latex: omit empty date

2022-07-30 Thread Ihor Radchenko
Max Nikulin  writes:

>>   (let ((date (and (plist-get info :with-date) (org-export-get-date 
>> info
>> -   (format "\\date{%s}\n" (org-export-data date info)))
>> +   (cond date
>
> I would consider (plist-get info :with-date) instead of date here to 
> allow to suppress date in the title by
>
> #+options: title:t date:t
> #+date:
>
> With such approach to avoid \date{} in the latex file date:nil can be 
> used in the options line.
>
>> + (format "\\date{%s}\n" (org-export-data date info

I am sorry, but I do not understand.

I tried

#+options: title:t date:nil

No \date is exported.

#+options: title:t date:t

\date is exported

#+options: title:t date:t
#+date:

No date is export.

All the above makes sense. Do I miss something?

Best,
Ihor



Re: [PATCH]: ox-latex: omit empty date

2022-07-30 Thread Max Nikulin

On 29/07/2022 19:49, emacs--- via General discussions about Org-mode. wrote:


In the attachment you can find a patch which omits an empty \date{} line in
a latex document when the option to include the date is set to nil or when
no date is provided. This empty date line can cause problems is certain
use cases.



  (let ((date (and (plist-get info :with-date) (org-export-get-date info
-   (format "\\date{%s}\n" (org-export-data date info)))
+   (cond date


I would consider (plist-get info :with-date) instead of date here to 
allow to suppress date in the title by


#+options: title:t date:t
#+date:

With such approach to avoid \date{} in the latex file date:nil can be 
used in the options line.



+ (format "\\date{%s}\n" (org-export-data date info






Re: [PATCH]: ox-latex: omit empty date

2022-07-29 Thread Ihor Radchenko
em...@vergauwen.me writes:

> The updated (and still untested) patch is attached to this mail.

Well. The patch is simple enough to not worry too much about checking.
And the tests are passing.

Applied onto main via a753d0dd2.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a753d0dd26018a951fe21548ae6b513594b570a8

Also, we have a record that you have the FSF copyright assignment. Is it
still the case? If you have, you do not need to put TINYCHANGE cookie.

Best,
Ihor



Re: [PATCH]: ox-latex: omit empty date

2022-07-29 Thread General discussions about Org-mode.
Hi Ihor, 
sorry for not testing my code!
 My test halted on the main branch with the message: Warning (python): 
Your `python-shell-interpreter' doesn't seem to support readline, yet 
`python-shell-completion-native-enable' was t and "python" is not part
 of the `python-shell-completion-native-disabled-interpreters' list.  
Native completions have been disabled locally. 
Shell native completion is disabled, using fallback
and I was not in the mood to fix this small problem with my python
installation.

The updated (and still untested) patch is attached to this mail.
Kind regards, 

Bob 



Jul 29, 2022, 15:31 by yanta...@gmail.com:

> emacs--- via "General discussions about Org-mode."
>  writes:
>
>> From 120e4ca11f021fa2d7e7abf57187c2db71942302 Mon Sep 17 00:00:00 2001
>> From: Bob Vergauwen 
>> Date: Fri, 29 Jul 2022 14:28:21 +0200
>> Subject: [PATCH] lisp/ox-latex: Omit empty date
>>
>> * lisp/ox-latex.el: (org-latex-template): When no date is provided or
>> the export option date is nil, the empty '\date{}' string is no
>> longer included in the exported latex document.
>>
>> The default behaviour for ox-latex was to include an empty date line as
>> '\date{}'.  This empty date line can affect more complex latex templates
>> when the date is for example set by the template on compilation, or when
>> the date command is overwritten entirely.  In this new patch, the date
>> line is omitted from the exported document.
>>
>
> Thanks! This looks reasonable.
>
>> (let ((date (and (plist-get info :with-date) (org-export-get-date info
>> -   (format "\\date{%s}\n" (org-export-data date info)))
>> +   (cond date
>> + (format "\\date{%s}\n" (org-export-data date info
>>
>
> This will give compilation error. Did you mean (when date ...)?
>
> Best,
> Ihor
>



0001-lisp-ox-latex-Omit-empty-date.patch
Description: Binary data


Re: [PATCH]: ox-latex: omit empty date

2022-07-29 Thread Ihor Radchenko
emacs--- via "General discussions about Org-mode."
 writes:

> From 120e4ca11f021fa2d7e7abf57187c2db71942302 Mon Sep 17 00:00:00 2001
> From: Bob Vergauwen 
> Date: Fri, 29 Jul 2022 14:28:21 +0200
> Subject: [PATCH] lisp/ox-latex: Omit empty date
>
> * lisp/ox-latex.el: (org-latex-template): When no date is provided or
> the export option date is nil, the empty '\date{}' string is no
> longer included in the exported latex document.
>
> The default behaviour for ox-latex was to include an empty date line as
> '\date{}'.  This empty date line can affect more complex latex templates
> when the date is for example set by the template on compilation, or when
> the date command is overwritten entirely.  In this new patch, the date
> line is omitted from the exported document.

Thanks! This looks reasonable.

>   (let ((date (and (plist-get info :with-date) (org-export-get-date 
> info
> -   (format "\\date{%s}\n" (org-export-data date info)))
> +   (cond date
> + (format "\\date{%s}\n" (org-export-data date info

This will give compilation error. Did you mean (when date ...)?

Best,
Ihor



[PATCH]: ox-latex: omit empty date

2022-07-29 Thread General discussions about Org-mode.
 Dear list, 

In the attachment you can find a patch which omits an empty \date{} line in
a latex document when the option to include the date is set to nil or when 
no date is provided. This empty date line can cause problems is certain 
use cases. 
Kind regads,
Bob 


0001-lisp-ox-latex-Omit-empty-date.patch
Description: Binary data