[FR] Please consider adding "none" as option for ':mode' table LaTeX attribute

2022-04-11 Thread Paul van Gelder
Hello all,

This is my first time mailing to the orgmode mailing list; I've read the 
mailing list entry at orgmode.org and I've searched for an answer online, but 
please accept my apologies if this mail doesn't comply with the list etiquette 
after all.

I am trying to export tables from orgmode to LaTex/PDF. I am using the 
following:\

#+ATTR_LATEX: :environment xltabular :width \textwidth :align |l|X|X|X| 
:placement [H]

(Note that there is a lowercase "l" between the the first two pipes "|" after 
:align)

When I export a (long) table that doesn't fit on the page, the table just runs 
off the PDF page.

After some online searching, I found a work-around:

First, to manually delete the following three lines from the .tex file:

\begin{table}[H]
\centering

\end{table} 

Second, to move the \caption{} (which used to be above the now deleted 
\end{table} above \end{xltabular}.

Then the table formats correctly over multiple pages. It is no problem at all 
for me to do this manually, but I thought it may be convenient to have a 'none' 
or 'nil' option for ':mode' that wouldn't input the \table environment in the 
first place?

Perhaps I am doing it all wrong, and my feature request doesn't make any sense. 
In that case, I'd be delighted how to properly output an xltabular table that 
spans multiple pages - without having to manually edit the .text file.

I will try and figure out if I can edit some relevant Elisp code (and propose 
that as feature solution), but that may take a long time since I've never done 
that in the past.

Anyhow, thanks for this amazing mode and wish you all a good day.

Kind regards,

Paul

Re: [FR] Please consider adding "none" as option for ':mode' table LaTeX attribute

2022-04-11 Thread Eric S Fraga
Hi Paul,

On Monday, 11 Apr 2022 at 12:08, Paul van Gelder wrote:
> First, to manually delete the following three lines from the .tex file:

If you add these options to the ATTR_LATEX line:

 :float nil :center nil

you should get what you wanted.

-- 
: Eric S Fraga, with org release_9.5.2-426-gf6813d in Emacs 29.0.50



Re: About babel and header arguments

2022-04-11 Thread Henrik Frisk
> > #+begin_src scheme :var y=10 :results value
> >   (+ 10 y)
> > #+end_src
> >
> > #+RESULTS:
> > : 10
>
> I'm surprised by this one - shouldn't we expect the result 20 ?
>

Hi Neil, yes, that was a typo, I pasted in the wrong result. Sorry for the
confusion!

/h


Bug: Changed behaviour of org-at-timestamp-p after recent change

2022-04-11 Thread Anders Johansson
Hi,
I noticed that this commit:
b1a570b3b  org-agenda: Fix regression when diary sexp timestamps are ignored

made a call like (org-at-timestamp-p 'agenda) match against the regexp
`org-element--timestamp-regexp`. However, this regexp doesn’t have the
match groups setup as the others (`org-ts-regexp3` and `org-ts-regexp2`) so
the last part of the docstring for org-at-timestamp-p doesn’t hold anymore
(that the timestamp parts should now be put in match groups).

I was using this in some code of mine, but I also realize that this doesn’t
feel all that clean anyway. I am not sure if this is used elsewhere in org
though.

Best,
Anders


What's the flow for adding info: links in Org documents?

2022-04-11 Thread Kaushal Modi
Hello all,

I believe I am missing out something basic with inserting info: links
in Org documents.

The info links look like:

[[info:org#External links]]

But if I am on that Info node and I hit `w' to copy the node
reference, this gets copied: "(org) External Links"

So when I insert a link in Org, it goes like this:

1. Type "[[info:"
2. Paste the Info node ref, so that I get "[[info:(org) External Links"
3. Refactor that to make it parseable by ol-info: "[[info:org#External Links]]"

I can locally advice the `org-info-export' so that "[[info:(org)
External Links]]" would work as well. But I think I am missing out on
some flow that would make the above manually editing in step 3
unnecessary.

How do you insert info: links efficiently?

--
Kaushal Modi



Re: What's the flow for adding info: links in Org documents?

2022-04-11 Thread Kaushal Modi
On Mon, Apr 11, 2022 at 8:35 AM Kaushal Modi  wrote:

> I believe I am missing out something basic with inserting info: links
> in Org documents.

Yes, I was missing out on something :)

To my future self:

1. When in Info buffer, do M-x org-store-link (typically a user binds
this to C-c l: https://orgmode.org/manual/Activation.html ). The link
gets copied in the [[info:MANUAL#NODE]] format.
2. In Org buffer, do C-c C-l to insert that last stored link.



Re: [FR] Please consider adding "none" as option for ':mode' table LaTeX attribute

2022-04-11 Thread Paul Van Gelder
Hello Eric,

Thank you very much: that did it :-). Should have known there is always already 
a way!

Kind regards,

Paul

Sent from my iPhone

> On 11 Apr 2022, at 13:06, Eric S Fraga  wrote:
> 
> Hi Paul,
> 
>> On Monday, 11 Apr 2022 at 12:08, Paul van Gelder wrote:
>> First, to manually delete the following three lines from the .tex file:
> 
> If you add these options to the ATTR_LATEX line:
> 
> :float nil :center nil
> 
> you should get what you wanted.
> 
> -- 
> : Eric S Fraga, with org release_9.5.2-426-gf6813d in Emacs 29.0.50




Re: What's the flow for adding info: links in Org documents?

2022-04-11 Thread Max Nikulin

On 11/04/2022 19:47, Kaushal Modi wrote:

On Mon, Apr 11, 2022 at 8:35 AM Kaushal Modi wrote:


I believe I am missing out something basic with inserting info: links
in Org documents.


Yes, I was missing out on something :)

To my future self:

1. When in Info buffer, do M-x org-store-link (typically a user binds
this to C-c l: https://orgmode.org/manual/Activation.html ). The link
gets copied in the [[info:MANUAL#NODE]] format.
2. In Org buffer, do C-c C-l to insert that last stored link.


There are a some problems with info links outside of Emacs:
- Export to PDF
- Links to single page manuals as the result of export to HTML. E.g. 
Emacs manual is really huge

- info: is a registered scheme, but not for texinfo.
  https://www.rfc-editor.org/rfc/rfc4452.html
  RFC 4452 - The "info" URI Scheme for Information Assets




Suggestions to handle LaTeX environments in ox-html

2022-04-11 Thread Vitus Schäfftlein
Dear org-mode mailing list, dear Thibault,

first of all I want to express my appreciation for your work and the efforts 
you put into getting org-mode together! You guys are awesome.

My name is Vitus, and I'm writing to you because I am setting up my blog, for 
which I need fully-fledged LaTeX support, so I am inserting my code via `svg' 
images. There are quite some problems to get it working, though, and I am 
giving my best to try and report the issues I found. All of them regard 
`ox-html'.

1. The current code in `ox-html' does not support equation numbers in 
parentheses. If you add

,
| span.equation-label:before {
|   content: '(';
| }
| 
| span.equation-label:after {
|   content: ')';
| }
| 
`

to your `css' file, strings of the form `( no )' are produced instead of 
strings of the form `(no)'; for example, you get `( 1 )' instead of `(1)'. 
1. /Any/ environment (except in-line-math) gets an equation number. But some 
environments should not have (html) equation numbers, like `tcolorbox'.
2. /Any/ `LaTeX' environment name `foo' is changed to `foo*' (except it already 
ends with an asterisk). For example, `\begin{tabular}' is changed to 
`\begin{tabular*}'; same for `\end{tabular}'. But `tabular*' differs from 
`tabular' in needing an extra width-argument, so the export won't work properly.

I have put quite some elbow-grease into possible solutions, which I would like 
to share with you. I am an emacs lisp beginner with background only in 
philosophical logic, so bear with me.

Changing (1) is simple. `org-html--wrap-latex-environment' produces the `html' 
span class `equation-label', where the equation number is then inserted. 
Specifically, it adds this string:

,
| "\n\n%s\n"
`

Now the newline commands `\n' before and after `%s' are exported as whitespace. 
Just replacing `\n%s\n' by `%s' (that is, leaving the newlines out) solves the 
problem. HTML ignores newlines anyway.

Changing (2) seems to be doable, too, and I think I know how to do it in theory:

1. Create a new variable `ox-html-latex-environments-no-number' of the form 
`("foo" "bar" "baz" ...)', which contains all environments that should not 
receive equation numbers.

2. Change `org-html--latex-environment-numbered-p'. It is currently defined 
like this:

,
| (defun org-html--latex-environment-numbered-p (element)
|   "Non-nil when ELEMENT contains a numbered LaTeX math environment.
| Starred and \"displaymath\" environments are not numbered."
|   (not (string-match-p "\\`[ \t]*begin{\\(.*\\*\\|displaymath\\)}"
|  (org-element-property :value element
`

Now we need to adjust the regular expression in such a way that if `element' 
has `\begin{foo}' or `\begin{bar}' etc. (that is, the environment name is a 
member of `ox-html-latex-environments-no-number'), it also returns nil. I think 
this is doable. I thought about adding something like

,
|   (not 
|   (or
|  ; starred or display math
| (string-match-p "\\`[ \t]*begin{\\(.*\\*\\|displaymath\\)}"
| (org-element-property :value element))
|  ; environment of ox-html-latex-environments-no-number
|   (string-match-p (format "\\begin{%s}" [any element of 
ox-html-latex-environments-no-number])
|  (org-element-property :value element))
| ))
`

I don't know how to express in elisp what is in brackets, though. Does this 
make sense to you? I am a beginner with elisp, so I can only state the ideas I 
have but not implement them (yet).

As to (3): Which images receive label numbers is controlled by this part of 
`org-html-latex-environment':

,
| (let ((formula-link
|   (org-html-format-latex
|(org-html--unlabel-latex-environment latex-frag)
|processing-type info)))
`

As you can see, at the moment, `org-html--unlabel-latex-environment' is applied 
to /every/ `latex-frag'. So we would again need a variable 
`org-html--latex-environments-leave-unlabelled' of the same form as above whose 
members are all latex environments which should not be unlabelled. Then, we 
could implement a condition like

,
|  (let ((formula-link
|(org-html-format-latex
|; if latex-frag is one of org-html--unlabel-latex-environment
|   (if (string-match-p (format "\\begin{%s}" 
|  [any element 
of org-html--latex-environments-leave-unlabelled])
|  latex-frag) 
|  ; then do not apply org-html-format-latex to 
latex-frag
|(org-html-format-latex latex-frag)
|  ; else do apply 
org-html--unlabel-latex to latex-frag
| (org-html--unlabel-latex-environment latex-frag)
| processing-type info)))
`

It would be great if you could have a look at my solutions. The code 

[DRAFT][PATCH] org-encode-time compatibility and convenience helper

2022-04-11 Thread Max Nikulin

Hi,

After a recent report of incorrect daylight saving time handling in agenda:

Ignacio Casso [BUG] org-agenda thinks timestamps after 23:00 correspond 
to the next day Tue, 29 Mar 2022 15:09:10 +0200

https://list.orgmode.org/paxpr06mb7760238f410cbe3203f78ee0c6...@paxpr06mb7760.eurprd06.prod.outlook.com

I tried to create a compatibility helper that will use currently 
recommended way to call `encode-time' with single list argument for 
Emacs-27 and newer, but use the only available call style as separated 
arguments for older Emacs versions.


From my point of view
- it should work at the compile or load time to minimize runtime 
performance impact,
- since both ways to call `encode-time' are necessary (in a half of 
cases a list returned by `decode-time' is available, in other cases 
timestamps are assembled from scratch, none is preferred), it should be 
convenient in both cases,
- it should allow Org to work even if support of multiple `encode-time' 
arguments will be removed from Emacs.


Paul Eggert proposed org-encode-time-1 defsubst/defun
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54764#10

My patch requires more changes since the macro is just defined but not 
actually used. It does not fix the problem with "no DST" flag returned 
by some function in Org. I can prepare next patches, but I think it 
should be decided at first which approach should be accepted by Org Mode:

- org-encode-time accepting both list or separate arguments
- mix of `encode-time' with multiple arguments and org-encode-time-1 for 
lists.From e330999cefe40d6d9a2f25abfd48b1f332b3688d Mon Sep 17 00:00:00 2001
From: Max Nikulin 
Date: Fri, 8 Apr 2022 23:10:50 +0700
Subject: [PATCH] org-macs.el: Introduce a helper for `encode-time'

* lisp/org-macs.el (org-encode-time): New compatibility and convenience
helper macro to allow a list for time components or separate arguments
independently of Emacs version.
* testing/lisp/test-org.el (test-org/org-encode-time): Tests for various
ways to call `org-encode-time'.

Ensure recommended way to call `encode-time' for Emacs-27 and newer with
hope to avoid bugs due to attempts to modernize the code similar to
bug#54731.
---
 lisp/org-macs.el | 20 ++
 testing/lisp/test-org.el | 45 
 2 files changed, 65 insertions(+)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index a09115e7c..7e8c23d09 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1225,6 +1225,26 @@ nil, just return 0."
 	(b (org-2ft b)))
 (and (> a 0) (> b 0) (\= a b
 
+(if (version< emacs-version "27.1")
+(defmacro org-encode-time (&rest time)
+  (if (cdr time)
+  `(encode-time ,@time)
+`(apply #'encode-time ,(car time
+  (defmacro org-encode-time (&rest time)
+(pcase (length time)
+  (1 `(encode-time ,(car time)))
+  (6 `(encode-time (list ,@time nil -1 nil)))
+  (9 `(encode-time (list ,@time)))
+  (_ (error "`org-encode-time' may be called with 1, 6, or 9 arguments but %d given"
+(length time))
+(put 'org-encode-time 'function-documentation
+ "Compatibility and convenience helper for `encode-time'.
+May be called with 9 components list (SECONDS ... YEAR IGNORED DST ZONE)
+as the recommended way since Emacs-27 or with 6 or 9 separate arguments
+similar to the only possible variant for Emacs-26 and earlier.
+Warning: use -1 for DST that means guess actual value, nil means no
+daylight saving time and may be wrong at particular time.")
+
 (defun org-parse-time-string (s &optional nodefault)
   "Parse Org time string S.
 
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 6aecc3af8..a0ed36362 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -179,6 +179,51 @@
 
 ;;; Date and time analysis
 
+(ert-deftest test-org/org-encode-time ()
+  "Test various ways to call `org-encode-time'"
+  ;; list as the sole argument
+  (should (string-equal
+   "2022-03-24 23:30:01"
+   (format-time-string
+"%F %T"
+(org-encode-time '(01 30 23 24 03 2022 nil -1 nil)
+  ;; SECOND...YEAR
+  (should (string-equal
+   "2022-03-24 23:30:02"
+   (format-time-string
+"%F %T"
+(org-encode-time 02 30 23 24 03 2022
+  ;; SECOND...YEAR IGNORED DST ZONE
+  (should (string-equal
+   "2022-03-24 23:30:03"
+   (format-time-string
+"%F %T"
+(org-encode-time 03 30 23 24 03 2022 nil -1 nil
+  ;; function call
+  (should (string-equal
+   "2022-03-24 23:30:04"
+   (format-time-string
+"%F %T"
+(org-encode-time (apply #'list 04 30 23 '(24 03 2022 nil -1 nil))
+  ;; wrong number of arguments
+  (if (not (version< emacs-version "27.1"))
+  (should-error (string-equal
+ "2022-03-24 23:30:05"
+ (format-time-string
+  "%F %T"
+

[PATCH] org-todo-yesterday: Fix interactive arg when in agenda buffer

2022-04-11 Thread Aaron L. Zeng
* lisp/org.el (org-todo-yesterday): Fix an incorrect use of apply when
org-todo-yesterday intends to call org-agenda-todo-yesterday with the
same interactive arg.  Before this change, the command incorrectly set
the todo state of the task to blank when called with C-u C-u C-u in an
agenda buffer (supposed to bypass any blocked checkboxes/subtasks).

TINYCHANGE
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 54350faee..5e326e765 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9665,7 +9665,7 @@ nil or a string to be used for the todo mark." )
   "Like `org-todo' but the time of change will be 23:59 of yesterday."
   (interactive "P")
   (if (eq major-mode 'org-agenda-mode)
-  (apply 'org-agenda-todo-yesterday arg)
+  (org-agenda-todo-yesterday arg)
 (let* ((org-use-effective-time t)
   (hour (nth 2 (decode-time (org-current-time
   (org-extend-today-until (1+ hour)))
-- 
2.33.1




Re: [DRAFT][PATCH] org-encode-time compatibility and convenience helper

2022-04-11 Thread Paul Eggert

On 4/11/22 08:22, Max Nikulin wrote:


+  (defmacro org-encode-time (&rest time)
+(pcase (length time)
+  (1 `(encode-time ,(car time)))
+  (6 `(encode-time (list ,@time nil -1 nil)))
+  (9 `(encode-time (list ,@time)))


After seeing this code and thinking about it a bit more I now understand 
better why you'd prefer Emacs encode-time to accept a 6-argument list. 
I'll work on adding that to Emacs master (to become Emacs 29). Of course 
something like the above will still needed for Emacs 27 and 28.




ox-html: exporting LaTeX-environments

2022-04-11 Thread Vitus Schäfftlein
Dear org-mode mailing list,

first of all I want to express my appreciation for your work and the efforts 
you put into getting
org-mode together! You guys are awesome.

I’m writing to you because I am setting up my blog, for which I need
fully-fledged LaTeX support, so I am inserting my code via svg images. There 
are quite some
problems to get it working, though, and I am giving my best to try and report 
the issues I found.
All of them regard ox-html. Most of what I wrrite can be found in this github 
discussion: 
https://github.com/kaushalmodi/ox-hugo/discussions/618.

1. The current code in ox-html does not support equation numbers in 
parentheses. If you add

span.equation-label:before {
content: '(';
}

span.equation-label:after {
content: ')';
}

to your css file, strings of the form ( no ) are produced instead of strings of 
the form (no); for
example, you get ( 1 ) instead of (1).

2. Any environment (except in-line-math) gets an equation number. But some 
environments
 should not have (html) equation numbers, like tcolorbox.
3. Any LaTeX environment name foo is changed to foo* (except it already ends 
with an
 asterisk). For example, \begin{tabular} is changed to \begin{tabular*}; same 
for
 \end{tabular}. But tabular* differs from tabular in needing an extra 
width-argument, so
 the export won’t work properly.

I have put quite some elbow-grease into possible solutions, which I would like 
to share with you.
I am an emacs lisp beginner with background only in philosophical logic, so 
bear with me.

Changing (1) is simple. org-html--wrap-latex-environment produces the html span 
class
equation-label, where the equation number is then inserted. Specifically, it 
adds this string:

"\n\n%s\n"

Now the newline commands \n before and after %s are exported as whitespace. 
Just replacing
\n%s\n by %s (that is, leaving the newlines out) solves the problem. HTML 
ignores newlines
anyway.

Changing (2) seems to be doable, too, and I think I know how to do it in theory:

1 Create a new variable ox-html-latex-environments-no-number of the form ("foo"
 "bar" "baz" ...), which contains all environments that should not receive 
equation
 numbers.
2 Change org-html--latex-environment-numbered-p. It is currently defined like 
this:

(defun org-html--latex-environment-numbered-p (element)
  "Non-nil when ELEMENT contains a numbered LaTeX math environment.
Starred and \"displaymath\" environments are not numbered."
  (not (string-match-p "\\`[ \t]*begin{\\(.*\\*\\|displaymath\\)}"
   (org-element-property :value element

Now we need to adjust the regular expression in such a way that if element has 
\begin{foo}
or \begin{bar} etc. (that is, the environment name is a member of
ox-html-latex-environments-no-number), it also returns nil. I think this is 
doable. I thought
about adding something like

  (not
(or
 ; starred or display math
  (string-match-p "\\`[ \t]*begin{\\(.*\\*\\|displaymath\\)}"
  (org-element-property :value element))
 ; environment of ox-html-latex-environments-no-number
(string-match-p (format "\\begin{%s}" [any element of 
ox-html-latex-environments-no-number])
   (org-element-property :value element))
))

I don’t know how to express in elisp what is in brackets, though. Does this 
make sense to you? I
am a beginner with elisp, so I can only state the ideas I have but not 
implement them (yet).

As to (3): Which images receive label numbers is controlled by this part of
org-html-latex-environment:

(let ((formula-link
(org-html-format-latex
 (org-html--unlabel-latex-environment latex-frag)
 processing-type info)))

As you can see, at the moment, org-html--unlabel-latex-environment is applied 
to every
latex-frag. So we would again need a variable
org-html--latex-environments-leave-unlabelled of the same form as above whose
members are all latex environments which should not be unlabelled. Then, we 
could implement
a condition like

 (let ((formula-link
 (org-html-format-latex
   ; if latex-frag is one of org-html--unlabel-latex-environment
(if (string-match-p (format "\\begin{%s}"
   [any element of 
org-html--latex-environments-leave-unlabelled])
   latex-frag)
   ; then do not apply org-html-format-latex to latex-frag
 (org-html-format-latex latex-frag)
   ; else do apply org-html--unlabel-latex to latex-frag
(org-html--unlabel-latex-environment latex-frag)
  processing-type info)))

It would be great if you could have a look at my solutions. The code surely is 
awful, but the ideas
behind it might be of value to you. If you could tell me how to solve these 
problems (or add a
commit which addresses them), this would be awesome! I am planning to do an 
in-depth guide
on how to write full-fledged LaTeX in html using svg images created with 
ox-html, and this is
the last s

[BUG] Incorrect timestamp face in a heading if previous body contains link to such a heading [9.5.2 (release_9.5.2-25-gaf6f12 @ /usr/share/emacs/28.1/lisp/org/)]

2022-04-11 Thread Hanspeter Gisler
OBSERVED BEHAVIOR
=

The following 2 files 'correct_face_rendering.org' and
'incorrect_face_rendering.org' render the 3rd headings timestamp face
differently, once correctly and once incorrectly.

correct_face_rendering.org
--

* ~ [2022-04-11 Mo] teading 1 - referred to by some other heading's body
:PROPERTIES:
:ID:   41482d18-460a-4803-81dc-f4512b771151
:END:
* ~ [2022-04-11 Mo] Heading 2 - referring to Heading 1
Link to: [[id:41482d18-460a-4803-81dc-f4512b771151][~ [2022-04-11 Mo] Heading 1 
- referred to by some other heading's body]]
* ~ [2022-04-11 Mo] Heading 3's timestamp face is correct


incorrect_face_rendering.org


* [2022-04-11 Mo] Heading 1 - referred to by some other heading's body
:PROPERTIES:
:ID:   9549d52f-439d-4011-ad72-9a9a7baad58b
:END:
* [2022-04-11 Mo] Heading 2 - referring to Heading 1
Link to: [[id:9549d52f-439d-4011-ad72-9a9a7baad58b][[2022-04-11 Mo] Heading 1 - 
referred to by some other heading's body]] 
* [2022-04-11 Mo] Heading 3's timestamp face is incorrect


EXPECTED BEHAVIOR
=

With both files, org should render the headings timestamp face correctly.


SYSTEM
==

Emacs  : GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, 
cairo version 1.17.6)
 of 2022-04-04
Package: Org mode version 9.5.2 (release_9.5.2-25-gaf6f12 @ 
/usr/share/emacs/28.1/lisp/org/)



Re: `M-x org-open-at-point` on `[[file:/path/file.hs][name]]` says: "Running less /home/path/file.hs"

2022-04-11 Thread chris
On Wednesday, 6 April 2022 19:26:38 CEST chris wrote:
> [was: Issue with internal directory links]
> 
> > Hi Jonathan,
> > 
> > Jonathan Fox  writes:
> >> Here's a link I'm using:
> >> 
> >> [[./templates][Templates]]
> 
> I have similar issue with `[[file:/path/file.hs][name]]`
> `M-x org-open-at-point` says:
> "Running less /home/path/file.hs"
> In terminal:
> `mimetype /home/path/file.hs` => `text/x-haskell`
> 
> ```
> org-file-apps is a variable defined in ‘org.el’.
> Its value is
> ((auto-mode . emacs)
>  (directory . emacs)
>  ("\\.mm\\'" . default)
>  ("\\.x?html?\\'" . default)
>  ("\\.pdf\\'" . default))
> ```
> 
> I guess I can configure it alright, but I have no idea why it is invoking
> `less` in the first place. I also have no idea where the output of `less`
> should be found.
> 
> `org-version` => 9.5.2
> `emacs-version` => 29.0.50

Using `https://list.orgmode.org/87y2pbv4pw@kyleam.com/T/[1]`, I've guessed 
that 
`(straight-use-package 'haskell-mode)` should fix it, and it did.

> 
> Thanks,
> Chris
> 
> > You can try adding (directory . emacs) to `org-file-apps' in your
> > configuration like this:
> > 
> > (setq org-file-apps
> > 
> >   '((auto-mode . emacs)
> >   
> > (directory . emacs)
> > 
> > ("\\.mm\\'" . default)
> > ("\\.x?html?\\'" . default)
> > ("\\.pdf\\'" . default)))
> > 
> > A bug related to mailcap handling has been fixed in Emacs 27,
> > perhaps this is what caused the change in your setup.  I added
> > (directory . emacs) in `org-file-apps' by default in the master
> > branch.
> > 
> > Thanks for reporting this,




[1] https://list.orgmode.org/87y2pbv4pw@kyleam.com/T/


#+latex_header blocks, or, managing lots of LaTeX headers

2022-04-11 Thread William Denton
I have another question related to managing a book I'm doing building for export 
to LaTeX:  what do people do for managing all of the headers?


I have about 30 #+latex_header lines in the project I'm working on, and I'm 
still just working on it as a basic article.  When I'm ready to do more 
formatting I'll use the memoir class and then there will be more commands.  I 
imagine some of you have huge headers with custom commands and more.


It would be great if there was a way to manage these lines as LaTeX, for example 
in a "#+begin_export latex" block, but as far as I can tell, there isn't a way 
(unless once again I overlooked something).


The idea came up about seven years ago, and Nicolas mentioned the possibility of 
a "#+begin_export latex :header t" implementation.


https://lists.gnu.org/archive/html/emacs-orgmode/2015-05/msg00538.html

It's possible to add a new class to the org-latex-classes variable, and in the 
documentation on it I see there are options ([NO-DEFAULT-PACKAGES], 
[NO-PACKAGES], [NO-EXTRA]) that allow one to trim away all the default headers. 
That makes it easy to take away, but not to add in lines I want, short of 
managing them in my init file.


What sorts of practices do people have for managing lots of LaTeX headers? 
Juan Manuel Macías, you mentioned something like this---literate programming in 
Org to export LaTeX source---may I ask how you do it?


Thanks,

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada

Re: #+latex_header blocks, or, managing lots of LaTeX headers

2022-04-11 Thread Vikas Rawal
For a major project like this, I would just put these in a separate file,
and include it using #+INCLUDE:

Vikas


On Tue, 12 Apr 2022 at 06:37, William Denton  wrote:

> I have another question related to managing a book I'm doing building for
> export
> to LaTeX:  what do people do for managing all of the headers?
>
> I have about 30 #+latex_header lines in the project I'm working on, and
> I'm
> still just working on it as a basic article.  When I'm ready to do more
> formatting I'll use the memoir class and then there will be more
> commands.  I
> imagine some of you have huge headers with custom commands and more.
>
> It would be great if there was a way to manage these lines as LaTeX, for
> example
> in a "#+begin_export latex" block, but as far as I can tell, there isn't a
> way
> (unless once again I overlooked something).
>
> The idea came up about seven years ago, and Nicolas mentioned the
> possibility of
> a "#+begin_export latex :header t" implementation.
>
> https://lists.gnu.org/archive/html/emacs-orgmode/2015-05/msg00538.html
>
> It's possible to add a new class to the org-latex-classes variable, and in
> the
> documentation on it I see there are options ([NO-DEFAULT-PACKAGES],
> [NO-PACKAGES], [NO-EXTRA]) that allow one to trim away all the default
> headers.
> That makes it easy to take away, but not to add in lines I want, short of
> managing them in my init file.
>
> What sorts of practices do people have for managing lots of LaTeX headers?
> Juan Manuel Macías, you mentioned something like this---literate
> programming in
> Org to export LaTeX source---may I ask how you do it?
>
> Thanks,
>
> Bill
>
> --
> William Denton
> https://www.miskatonic.org/
> Librarian, artist and licensed private investigator.
> Toronto, Canada


Re: ox-html: exporting LaTeX-environments

2022-04-11 Thread Thibault Marin

Hi Vitus, list.

My memory is quite fuzzy on this and I won't have a chance to take a
deep look until later, but I will try to share the information I have.

On Mon, 11 Apr 2022 19:38:13 + (9 hours, 37 minutes, 37 seconds ago), Vitus 
Schäfftlein  wrote:

  Dear org-mode mailing list,

  [...]

  3. Any LaTeX environment name foo is changed to foo* (except it already ends 
with an
   asterisk). For example, \begin{tabular} is changed to \begin{tabular*}; same 
for
   \end{tabular}. But tabular* differs from tabular in needing an extra 
width-argument, so
   the export won’t work properly.

I had submitted a patch trying to address this
(https://list.orgmode.org/87h7ok3qi2.fsf@dell-desktop.WORKGROUP/, I have
attached a new version rebased on main to this message).  It never made
it in and I failed to follow-up.  This patch (or something similar)
could help with this issue.  It basically only adds the star for math
environments (using org-html--math-environment-p)

  [...]

  Now the newline commands \n before and after %s are exported as whitespace. 
Just replacing
  \n%s\n by %s (that is, leaving the newlines out) solves the problem. HTML 
ignores newlines
  anyway.

This seems to work better indeed; the \n's were just cosmetic.

  [...]

  1 Create a new variable ox-html-latex-environments-no-number of the form 
("foo"
   "bar" "baz" ...), which contains all environments that should not receive 
equation
   numbers.

I don't know whether org-html--math-environment-p (as used in the
attached patch) is sufficient to determine whether we need to add a star
to the environment or if we need another variable (in my use cases,
testing for a match environment is sufficient but it may not be the case
in general).

  [...]

  I don’t know how to express in elisp what is in brackets, though. Does this 
make sense to you? I
  am a beginner with elisp, so I can only state the ideas I have but not 
implement them (yet).

This can be made to work if there is a consensus that we want to add a
ox-html-latex-environments-no-number variable (I can try to help with
that if needed, even though my elisp isn't great)

  [...]

  (let ((formula-link
  (org-html-format-latex
   (org-html--unlabel-latex-environment latex-frag)
   processing-type info)))

The patch should address that, I would be curious to see if you
encounter additional problematic cases after applying it.

Thanks for resurrecting this and for your help detecting and fixing the issues.

Best,

thibault

From 61a27c4816a0dae1072f851cc67ea48cec2d362c Mon Sep 17 00:00:00 2001
From: thibault 
Date: Tue, 12 Apr 2022 00:45:18 -0400
Subject: [PATCH] lisp/ox-html.el: Fix automatic numbering of non-math
 environment

* ox-html.el (org-html-latex-environment): Prevent addition of * to
non-math environments.  Added * is used for math environments to
replace latex equation numbering by org labels for html linking.
---
 lisp/ox-html.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 81ef002a0..0968e2199 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2945,7 +2945,9 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
  ((assq processing-type org-preview-latex-process-alist)
   (let ((formula-link
  (org-html-format-latex
-  (org-html--unlabel-latex-environment latex-frag)
+	  (if (eq nil (org-html--math-environment-p latex-environment))
+		  latex-frag
+		(org-html--unlabel-latex-environment latex-frag))
   processing-type info)))
 (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
   (let ((source (org-export-file-uri (match-string 1 formula-link
--
2.33.0



Re: #+latex_header blocks, or, managing lots of LaTeX headers

2022-04-11 Thread Tim Cross


William Denton  writes:

> I have another question related to managing a book I'm doing building for 
> export to LaTeX:
> what do people do for managing all of the headers?
>

I only use the #+latex_headers or #+latext-headers-extra lines for 'one
off' type documents. If I'm going to be writing lots of documents where
those packages are needed, I define a new org-latex-classes entry.

> It's possible to add a new class to the org-latex-classes variable, and in 
> the documentation on
> it I see there are options ([NO-DEFAULT-PACKAGES], [NO-PACKAGES], [NO-EXTRA]) 
> that allow one to
> trim away all the default headers. That makes it easy to take away, but not 
> to add in lines I
> want, short of managing them in my init file.

The org-latex-classes 'placeholder' macros allow you to add or remove
the headers defined in either the default-packages or packages alist or
headers added via latex_headers/latex_headers_extra. However, the point
to note is that this 'value' is just a string, so you can just put in
exactly what you want - you don't have to use the placeholder macros
(though I almost always do - at least the [default-packages] macro, but
usually the [packages] one as well). The value isn't just restricted to
\usepackage lines either - you can put anything there which makes sense
in the latgex header.

>
> What sorts of practices do people have for managing lots of LaTeX headers? 
> Juan Manuel Macías,
> you mentioned something like this---literate programming in Org to export 
> LaTeX source---may I
> ask how you do it?
>

If I find myself using lots of #+latex_headers lines, this tells me
either

1. I need to update/add to the packages alist variable. This is
especially likely if I'm adding the same headers to every document. Just
add it to the packages alist. I tend to leave the default-packages alist
alone.

2. There is a specific 'style' of document I write often and all
documents of this style have the same additional headers. For this, I
create a new entry in org-latex-classes.

I think adding headers via #+latex_headers and #+latext_headers_extra
should be avoided as much as possible. It is a great escape hatch or for
doing 'on-offs', but not the right approach for doing something like
writing a book.

Consider the situation where you have been adding headers to load
language support or a particular code listing package or whatever. You
writing a book and it will have many org files (perhaps one per
chapter). You add these #+latex_header lines to add the packages. Later,
you find the listing package isn't suitable or you need to modify the
language encoding - now you have to edit every org file which makes up
the book.

Alternatively, you define a new org-latex-classes entry call 'my-book'
and use that to add the language encoding and code listing packages
(along with some other 'tweaks' you typically put in the header, maybe
even add a few custom commands etc). Now when you find it necessary to
change the language encoding, code listing package or whatever, you just
have that one definition to change and only need to edit one file.