Re: Noweb Function's body without evaluation

2023-03-15 Thread Ken Mankoff
Hi,

I'm not sure that I understand your issue or needs from the provided examples, 
but I wonder if the example I provide here would be helpful. It bypasses :var 
an lets you inject a PROPERTY value anywhere. It is also language agnostic. You 
can use it to execute commands (that are set as PROPERTY values) or set 
variables to values.

https://lists.gnu.org/archive/html/emacs-orgmode/2023-03/msg00251.html

  -k.

On 2023-03-15 at 18:54 -04, suarezmigu...@icloud.com wrote...
> Hello Org-mode community. I’m using Emacs Doom Framework, specifically:
>
> Emacs 28.2 (build 1, aarch64-apple-darwin22.3.0, Carbon Version 169
> AppKit 2299.4) of 2023-02-23.
>
> I use heavily org-mode for Literate DevOps, so I have a lot of shell
> commands that connect through SSH and do some things later, for
> example:
>
> #+name: initSSH
> #+begin_src shell :var connection=“admin@somehost"
>
> ssh -t miguel@host "sudo -u someuser ssh -t $connection 'sudo su'"
> #+end_src
>
> So then I can call:
>
> #+call: initSSH(connection=“admin@anotherhost”)
>
> With any other header parameters or session, the above works
> correctly. I cannot use tramp due to network latency issues, so this
> is the most performance way for me, since I also have to do some
> multi-hops which are indeed supported in tramp, but it is too slow for
> me, so I rather only commands.
>
> The thing is that, I then would like to call these not with a #+call
> function, but add them into a bigger script, let’s say that I define
> another command:
>
> #+name: getStorage
> #+begin_src shell
>
> df
> #+end_src
>
> Which has to be run in a remote server, could be any remote server as
> I have to connect to several. So I would like to be able to:
>
> #+begin_src shell
> <>
> <>
> #+end_src
>
>
> The first doesn’t work as org-mode runs the code and passes the
> resulting string to bash, which isn’t a command. The latter works
> normally. So the issue here are the parameters.
>
> So I made another simple example for this:
>
> #+name: greeting
> #+begin_src sh :var name="world" :results output :session testing
>
> echo "hello, $name\!"
> #+end_src
>
> #+results: greeting
> #+begin_src sh
>
> hello, world\!
> #+end_src
>
> #+begin_src shell
> <>
> #+end_src
>
>
> This results in sh: hello,: command not found, as it is executing the 
> function. I see in the documentation that I can:
> - Call a function’s body with <>
> - Execute a function and return its results with <>
> - Execute a function and return its results even with different params with 
> <>
>
> So right now, the one that’s missing is, call a function’s body with 
> different parameters. So the
> function <> is not evaluated.
>
> After searching a lot, I came across:
>
> #+begin_src shell :session testing
> <>
> #+end_src
>
> Which results in:
>
> sh-3.2$ PS1="org_babel_sh_prompt> "
> org_babel_sh_prompt> name='Testin'
> org_babel_sh_prompt> echo "hello, $name\!"
> hello, Testin\!
> org_babel_sh_prompt> echo 'org_babel_sh_eoe'
> org_babel_sh_eoe
> org_babel_sh_prompt> hello, Testin\!
> sh: hello,: command not found
> org_babel_sh_prompt> echo 'org_babel_sh_eoe'
> org_babel_sh_eoe
> org_babel_sh_prompt> 
>
> Which is somewhat what I need since at least the variable is changed,
> but the result of this execution is also passed to shell so, same
> error.
>
> I can’t find much documentation about this, what is the correct syntax
> here?,
>
> Thank you!




Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-03-15 Thread Ken Mankoff
Hi Ihor and Max,

Just a follow-up note that I am unlikely to be able to complete this patch 
anytime soon. Re-alignment of priorities because my need for :var header 
support in Org Babel is mitigated by a different method of injecting variables 
into Org Babel sections: Use noweb.

I find this more powerful than =:var=. The examples below show (1) setting a 
bash environment variable in screen, or (2) printing from a Python prompt after 
sshing to a remote computer. It is language agnostic. Because it uses 
PROPERTIES and not :var, it also lets me work in Org Column View mode.

* Header
:PROPERTIES:
:foo: 42
:END:

#+NAME: ex1-screen-bash
#+BEGIN_SRC screen
export foo="<>"
#+END_SRC

#+NAME: ex2-ssh-python
#+BEGIN_SRC bash
ssh somewhere
python
print("<>")
#+END_SRC

#+CALL: ex2-ssh-python()

#+RESULTS:
: foo


The relevant section from my library-of-babel is:

* Properties into header args
:PROPERTIES:
:hellomessage: hello
:END:

https://emacs.stackexchange.com/questions/41922/

#+NAME: get_property
#+BEGIN_SRC emacs-lisp :var prop_name="" :results silent
(org-with-point-at org-babel-current-src-block-location
  (org-entry-get nil prop_name t))
#+END_SRC

** Example Usage

*** Header arg

#+HEADER: :var prop_message=(org-entry-get nil "hellomessage" t)
#+BEGIN_SRC emacs-lisp
  (message prop_message)
#+END_SRC

#+RESULTS:
: hello

*** Noweb
#+BEGIN_SRC emacs-lisp :noweb yes
  (message "<>")
#+END_SRC

#+RESULTS:
: hello

#+BEGIN_SRC bash :noweb yes :results verbatim
echo "<>"
#+END_SRC

#+RESULTS:
: hello

If hope this helps someone if they need it.

  -k.



Noweb Function's body without evaluation

2023-03-15 Thread suarezmiguelc


Hello Org-mode community. I’m using Emacs Doom Framework, specifically:

Emacs 28.2 (build 1, aarch64-apple-darwin22.3.0, Carbon Version 169 AppKit 
2299.4) of 2023-02-23.

I use heavily org-mode for Literate DevOps, so I have a lot of shell commands 
that connect through SSH and do some things later, for example:

#+name: initSSH
#+begin_src shell :var connection=“admin@somehost"
ssh -t miguel@host "sudo -u someuser ssh -t $connection 'sudo su'"
#+end_src

So then I can call:

#+call: initSSH(connection=“admin@anotherhost”)

With any other header parameters or session, the above works correctly. I 
cannot use tramp due to network latency issues, so this is the most performance 
way for me, since I also have to do some multi-hops which are indeed supported 
in tramp, but it is too slow for me, so I rather only commands.

The thing is that, I then would like to call these not with a #+call function, 
but add them into a bigger script, let’s say that I define another command:

#+name: getStorage
#+begin_src shell
df
#+end_src

Which has to be run in a remote server, could be any remote server as I have to 
connect to several. So I would like to be able to:

#+begin_src shell
<>
<>
#+end_src

The first doesn’t work as org-mode runs the code and passes the resulting 
string to bash, which isn’t a command. The latter works normally. So the issue 
here are the parameters.

So I made another simple example for this:

#+name: greeting
#+begin_src sh :var name="world" :results output :session testing
echo "hello, $name\!"
#+end_src

#+results: greeting
#+begin_src sh
hello, world\!
#+end_src

#+begin_src shell
<>
#+end_src

This results in sh: hello,: command not found, as it is executing the function. 
I see in the documentation that I can:
- Call a function’s body with <>
- Execute a function and return its results with <>
- Execute a function and return its results even with different params with 
<>

So right now, the one that’s missing is, call a function’s body with different 
parameters. So the function <> is not evaluated.

After searching a lot, I came across:

#+begin_src shell :session testing
<>
#+end_src

Which results in:

sh-3.2$ PS1="org_babel_sh_prompt> "
org_babel_sh_prompt> name='Testin'
org_babel_sh_prompt> echo "hello, $name\!"
hello, Testin\!
org_babel_sh_prompt> echo 'org_babel_sh_eoe'
org_babel_sh_eoe
org_babel_sh_prompt> hello, Testin\!
sh: hello,: command not found
org_babel_sh_prompt> echo 'org_babel_sh_eoe'
org_babel_sh_eoe
org_babel_sh_prompt> 

Which is somewhat what I need since at least the variable is changed, but the 
result of this execution is also passed to shell so, same error.

I can’t find much documentation about this, what is the correct syntax here?,

Thank you!


Re: Haskell code blocks

2023-03-15 Thread Bruno Barbier


Hi Ihor,

Ihor Radchenko  writes:

> Bruno Barbier  writes:
>
>> Sorry, I'm still working on adding a 'test-ob-haskell.el', when I have
>> some spare time, but I'm unable so far to find tests that I can't
>> reliably break.
>
> May I know if you are still working on this?
> Do you need any help?

My tests were too easy to break. I tried to learn more about
haskell-mode, but I got lost. Then, it got down in my todo list.

I'll check what I have this week-end and come back to you.  But, that
might just be a set of tests that randomly fail.  Anyway, we'll decide
from there.

Thanks for your ping.

Bruno





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



Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2023-03-15 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> What about
>
> (define-fringe-bitmap
> 'sand-clock
> [#b
>  #b1001
>  #b0110
>  #b0110
>  #b01101110
>  #b0000
>  #b00011000
>  #b00100100
>  #b0110
>  #b01011010
>  #b
>  #b])

The good old hourglass is back! :)

Love it!

Rudy
-- 
"Strange as it may sound, the power of mathematics rests on its evasion
of all unnecessary thought and on its wonderful saving of mental
operations."
-- Ernst Mach, 1838-1916

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] org-manual.org: $n$-th is not math

2023-03-15 Thread Rudolf Adamkovič
Bummer the dash will not be supported. :(

(I am super-happy with $...$, except for the dash case.)

Max Nikulin  writes:

> Prefer =\(...\)= for + inline snippets.

Fragments, not snippets.  Right?

> The =$...$= alternative has some restrictions and may be source of confusion.

I am not a native speaker, but "may be a source of confusion" (note the "a")
sounds more correct.

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [POLL] Proposed syntax for timestamps with time zone info (was: [FEATURE REQUEST] Timezone support in org-mode datestamps and org-agenda)

2023-03-15 Thread Max Nikulin

On 10/02/2023 10:29, Jean Louis wrote:

https://icalendar.org/iCalendar-RFC-5545/3-3-5-date-time.html

,
| The form of date and time with UTC offset MUST NOT be used. For
| example, the following is not valid for a DATE-TIME value:
|
|  19980119T23-0800   ;Invalid time format
`

As with the above format, author would maybe think it is alright, but
in general it is confusing. If author wish to specify UTC time, then
no offset shall be used.


RFC-5545 specifies a machine readable format. Org files are for humans 
even in raw text format. Decisions suitable for iCalendar are not always 
applicable for Org.


The timestamp in the examples follows ISO-8601 and I have no idea why it 
is confusing.


Offsets for RFC5545 means
- More code for parsing (negligible amount though)
- Due to wide spread confusions, an implementer may pretend that 
timezones are supported just because offsets are saved despite missed 
IANA TZ ID.


In respect to Org offsets and time zone identifiers are discussed in 
this thread in details. As a format for humans it should be more 
permissible and convenient for direct typing. There is no reason to 
insist on UTC where timestamps with fixed offsets are equally valid.





Re: Find-file using org-protocol

2023-03-15 Thread Max Nikulin

On 15/03/2023 10:41, Kai Ma wrote:


I’m using org-protocol to open local files in an Emacs client.  Yes,
this is weird, but it is required for some Electron apps, because they
do not allow calling arbitrary commands.

...

It works, but there’s a minor annoyance: the buffer it opens is not
associated with the client.  And killing the client won’t kill the
buffer it creates.


Do you really need org-protocol for this purpose? I would suggest direct 
call of your function using --eval similar to `message-mailto` in 
https://git.savannah.gnu.org/cgit/emacs.git/tree/etc/emacsclient-mail.desktop


I admit that it is tricky to safely pass an argument to emacsclient, see
https://debbugs.gnu.org/57752
#57752 28.1.91; emacsclient-mail.desktop doesn't work for me.

However instead of long Exec entry in the desktop file I would use a 
script with *single* %u argument. The reason is a Firefox bug that may 
cause lost of everything besides the command and the URI.




Re: [PATCH] org-manual.org: $n$-th is not math

2023-03-15 Thread Loris Bennett
Max Nikulin  writes:

[snip (17 lines)]

> Detection of "$-" as closing math delimiters is broken since 2015 as a

[snip (44 lines)]

Detection of "$-" as closing math delimiters has been broken since 2015 as a

-- 
This signature is currently under constuction.



[PATCH] org-manual.org: $n$-th is not math

2023-03-15 Thread Max Nikulin

Hi,

yesterday an issue with $n$-th TeX markup was risen again. I think, the 
manual should not declare that it is supported. It is broken for a 
decade. So \(n\)-th should be suggested instead.From 6feb228a1bcc485441bab707771e6d87a3d69671 Mon Sep 17 00:00:00 2001
From: Max Nikulin 
Date: Wed, 15 Mar 2023 19:08:37 +0700
Subject: [PATCH] org-manual.org: $n$-th is not math
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* doc/org-manual.org (LaTeX fragments): Do not state that dash is
allowed after single "$" math delimiter and recommend "\(...\)".

Detection of "$-" as closing math delimiters is broken since 2015 as a
side effect of using punctuation class in regular expressions while
dash is considered as a word constituent.  See commits
6779f8f424 and c0369a7984.  Bring the manual in accordance to the code
instead of allowing "($-2 change)" false positives.  Users who do not
like "\(...\)" constructs may use a helper for typing it and may change
how it is displayed to minimize visual noise by fontification, see

- Eric S Fraga to emacs-orgmode. Re: Depreciating TeX-style LaTeX
  fragments. Sun, 16 Jan 2022 12:10:30 +.
  
- Ihor Radchenko to emacs-orgmode. Re: [PATCH] Add support for $…$ latex
  fragments followed by a dash. Thu, 27 Jan 2022 16:28:10 +0800.
  
---
 doc/org-manual.org | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 1c97d6aa8..7bb1ac637 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11152,14 +11152,14 @@ *** LaTeX fragments
   =\begin= statement appears on a new line, preceded by only
   whitespace.
 
-- Text within the usual LaTeX math delimiters.  To avoid conflicts
-  with currency specifications, single =$= characters are only
-  recognized as math delimiters if the enclosed text contains at most
-  two line breaks, is directly attached to the =$= characters with no
-  whitespace in between, and if the closing =$= is followed by
-  whitespace, punctuation or a dash.  For the other delimiters, there
-  is no such restriction, so when in doubt, use =\(...\)= as inline
-  math delimiters.
+- Text within the usual LaTeX math delimiters.  Prefer =\(...\)= for
+  inline snippets.  The =$...$= alternative has some restrictions and
+  may be source of confusion.  To avoid conflicts with currency
+  specifications, single =$= characters are only recognized as math
+  delimiters if the enclosed text contains at most two line breaks, is
+  directly attached to the =$= characters with no whitespace in
+  between, and if the closing =$= is followed by whitespace or
+  punctuation (but not a dash).
 
 #+texinfo: @noindent
 For example:
-- 
2.25.1



Find-file using org-protocol

2023-03-15 Thread Kai Ma
Hi org

I’m using org-protocol to open local files in an Emacs client.  Yes, this is 
weird, but it is required for some Electron apps, because they do not allow 
calling arbitrary commands.

This is how I do it:

(use-package org-protocol
  :config
  (add-to-list 'org-protocol-protocol-alist
   '("org-find-file" :protocol "find-file" :function 
org-protocol-find-file :kill-client nil))

  (defun org-protocol-find-file (fname)
"Process org-protocol://find-file?path= style URL."
(let ((f (plist-get (org-protocol-parse-parameters fname nil '(:path)) 
:path)))
  (find-file f)
  (raise-frame)
  (select-frame-set-input-focus (selected-frame)

It works, but there’s a minor annoyance: the buffer it opens is not associated 
with the client.  And killing the client won’t kill the buffer it creates.

Upon some inspection, I find that org-protocol-check-filename-for-protocol 
seems to discard information about the client, so I cannot set 
server-buffer-clients and server-existing-buffer accordingly myself.

I’m writing to ask if there is a better way than advising server-visit-files or 
org-protocol-check-filename-for-protocol?

Thanks!

Regards,
Kai


Re: [patch] ob-clojure: Fix results output

2023-03-15 Thread Daniel Kraus

Ihor Radchenko  writes:

> What will happen with users who customized `org-babel-clojure-backend'
> to 'nbb in the past?

They would have gotten an error.
I changed it now that 'nbb backend is still allowed in a clojure
source block but it will internally treated as ClojureScript.

>> +(defcustom org-babel-clojurescript-backend
>> +  (cond
>> +   ((or (executable-find "nbb") (executable-find "npx")) 'nbb)
>> +   ((featurep 'cider) 'cider)
>> +   (t nil))
>> +  "Backend used to evaluate Clojure code blocks."
>
> This docstring is exactly the same with `org-babel-clojure-backend'.
> What is the difference?
> I think ""Backend used to evaluate ClojureScript code blocks." will be
> more clear. I feel that other docstrings may also need to be clarified
> depending whether they affect Clojure or ClojureScript blocks.

I changed the docstrings to always mention either Clojure or ClojureScript.
I'm open for more improvements/suggestions.

Attached a new patch.

Thanks,
  Daniel

>From 391bdd403f643fa75cceeb0c81f117996c2374b0 Mon Sep 17 00:00:00 2001
From: Daniel Kraus 
Date: Thu, 9 Mar 2023 16:11:27 +0100
Subject: [PATCH] ob-clojure.el: Fix results output, support clojure-cli

* lisp/ob-clojure.el (org-babel-clojure-backend): Add support for
clojure-cli.
* lisp/ob-clojure.el (org-babel-clojurescript-backend): Move nbb to
clojurescript.
* lisp/ob-clojure.el (org-babel-expand-body:clojure)
* lisp/ob-clojure.el (ob-clojure-eval-with-cider): Return only the
last expression when :results is not set or value, and return only
stdout when :results is set to output.
* lisp/ob-clojure.el (ob-clojure-eval-with-cmd): Rename function as
it is not only for babashka.
* lisp/ob-clojure.el (org-babel-execute:clojure): Differentiate
between Clojure and ClojureScript source blocks.

The problem was that the ob-clojure results where not correctly
taking the results parameter into account.
E.g. with the cider backend, you would get all printed or returned
values for each line in your block:

(def small-map {:a 2 :b 4 :c 8})
{:some :map}
(prn :xx)
(:b small-map)

| #'user/small-map |
| {:some :map} |
| 4|

or for babashka you would only get the printed values but not the
last return value:
(def small-map {:a 2 :b 4 :c 8})
{:some :map}
(prn :xx)
(:b small-map)

: :xx

Now when you specify :results value, the result is only the last
returned value, and with :results output you get all values
printed to stdout.
So the examples above would all result in the same:
(def small-map {:a 2 :b 4 :c 8})
{:some :map}
(prn :xx)
(:b small-map)

: 4
---
 etc/ORG-NEWS   |  23 +++
 lisp/ob-clojure.el | 156 -
 lisp/org-compat.el |   4 ++
 3 files changed, 126 insertions(+), 57 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index b9d7b3459..4ca13af17 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -96,6 +96,21 @@ The face ~org-agenda-calendar-daterange~ is used to show entries with
 a date range in the agenda.  It inherits from the default face in
 order to remain backward-compatible.
 
+*** New ~org-babel-clojurescript-backend~ option to choose ClojureScript backend
+
+Before, a ClojureScript source block used the same backend as Clojure,
+configured in ~org-babel-clojure-backend~ and relied on an undocumented
+~:target~ paramter.
+
+Now, there's ~org-babel-clojurescript-backend~ to determine the
+backend used for evaluation of ClojureScript.
+
+*** Support for Clojure CLI in ~ob-clojure~
+
+~ob-clojure~ now supports executing babel source blocks with the
+official [[https://clojure.org/guides/deps_and_cli][Clojure CLI tools]].
+The command can be customized with ~ob-clojure-cli-command~.
+
 ** New features
 *** ~org-metaup~ and ~org-metadown~ now act on headings in region
 
@@ -116,6 +131,14 @@ selection.
 TODO state, priority, tags, statistics cookies, and COMMENT keywords
 are allowed in the tree structure.
 
+** Miscellaneous
+*** Remove undocumented ~:target~ header parameter in ~ob-clojure~
+
+The ~:target~ header was only used internally to distinguish
+from Clojure and ClojureScript.
+This is now handled with an optional function parameter in
+the respective functions that need this information.
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 5f589db00..70e032154 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -25,20 +25,21 @@
 
 ;;; Commentary:
 
-;; Support for evaluating Clojure code
+;; Support for evaluating Clojure / ClojureScript code.
 
 ;; Requirements:
 
 ;; - Clojure (at least 1.2.0)
 ;; - clojure-mode
-;; - inf-clojure, Cider, SLIME, babashka or nbb
+;; - babashka, nbb, Clojure CLI tools, Cider, inf-clojure or SLIME
 
 ;; For clojure-mode, see https://github.com/clojure-emacs/clojure-mode
-;; For inf-clojure, see https://github.com/clojure-emacs/inf-clojure
-;; For Cider, see https://github.com/clojure-emacs/cider
-;; For SLIME, see https://slime.common-lisp.dev
 

Re: [patch] ob-clojure: Fix results output

2023-03-15 Thread Ihor Radchenko
Daniel Kraus  writes:

> Ups, I attached the wrong one.
> Here the correct patch..

Thanks!
Some more comments ;)

>  (defcustom org-babel-clojure-backend (cond
>((executable-find "bb") 'babashka)
> -  ((executable-find "nbb") 'nbb)
> +  ((executable-find "clojure") 
> 'clojure-cli)
>((featurep 'cider) 'cider)
>((featurep 'inf-clojure) 'inf-clojure)
>((featurep 'slime) 'slime)
> (t nil))

What will happen with users who customized `org-babel-clojure-backend'
to 'nbb in the past?

> +(defcustom org-babel-clojurescript-backend
> +  (cond
> +   ((or (executable-find "nbb") (executable-find "npx")) 'nbb)
> +   ((featurep 'cider) 'cider)
> +   (t nil))
> +  "Backend used to evaluate Clojure code blocks."

This docstring is exactly the same with `org-babel-clojure-backend'.
What is the difference?
I think ""Backend used to evaluate ClojureScript code blocks." will be
more clear. I feel that other docstrings may also need to be clarified
depending whether they affect Clojure or ClojureScript blocks.

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



Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2023-03-15 Thread Ihor Radchenko
Timothy  writes:

>>> • Org mode can keep equation numbering consistent by regenerating previews 
>>> as needed.
>>
>> This is disabled by default, right?
>> But I am still seeing the numbering (see the attached) the Org text
>> below.
>
> Correct. Numbering settings have been re-done to hopefully make what’s 
> happening
> more obvious.

I see. The numbers are replaced by diamonds. Looks good.

>> Also, One of the preview is truncated.
>>
>> [2. image/png; preview-artifact.png]…
>
> LaTeX has a page width when generating previews, you can increase how wide the
> text area is easily via `org-latex-preview-width'. This could be developed 
> more in
> the future, but for now it works I think.

Ok. Let's see if relevant bug reports stream in.
For now, the functionality is acceptable.

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


Re: [Pre-PATCH] Overhaul of the LaTeX preview system

2023-03-15 Thread Ihor Radchenko
Timothy  writes:

>> 3. It took 20+ seconds (!!!) to generate previews in a single section in
>>my large notes.org. Profile attached - org-latex-preview parses the
>>whole 20Mb buffer to generate the preamble. Why?
>
> Because of the use of buffer info in generating the preamble, which calls
> `org-export--annotate-info'. I’m currently considering introducing a variable 
> to
> allow for the use of buffer-specific info to be toggled.

What if `org-export--annotate-info' could be made async?

>> 5. Why triangles? Something resembling “waiting” would be more
>>meaningful.
>
> It has to be a small icon, so that basically means simple geometric shapes 
> only.
> There’s also the “grey text” indicator, and “no indicator” option.

What about

(define-fringe-bitmap
'sand-clock
[#b
 #b1001
 #b0110
 #b0110
 #b01101110
 #b0000
 #b00011000
 #b00100100
 #b0110
 #b01011010
 #b
 #b])



>> 6. What will happen if I add/remove #+LATEX_HEADER in the buffer? in
>>subtree properties? Are in-buffer latex settings supposed to affect
>>anything? I tried to add #+LATEX_HEADER on top of the file, but the
>>preview do not appear to be re-generated.
>
> Currently you need to set `org-latex-preview--preamble-content' to nil, which
> currently can be done by doing `C-c C-c' on the header / otherwise running
> `org-restart'.

It would be better to provide a command.
C-c C-c is too dramatic - it will reset much more than just preview
cache. (Like org-element-cache).

Or better add a new prefix arg to org-latex-preview that will force
re-generation.

Further, as discussed in the DM, we may need to consider that equation
preview may depend on latex export settings:

1. preview might be generic, utilizing "average" common latex preamble
2. preview might try to conform to latex export settings according to
   full document export
3. preview might use a different latex preamble when the current subtree
   will not actually be exported - like in commented subtrees. In
   particular, it matters for equation numbering
4. preview might try to generate preamble according to subtree export
   settings - some Org workflows involve multiple documents in one Org
   file, exported separately via subtree export.
   
-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 


Re: 1 character fix to make ob-haskell compatible with table outputs

2023-03-15 Thread Ihor Radchenko
ParetoOptimalDev via "General discussions about Org-mode."
 writes:

> For something like:
>
> name:tbl
> #+begin_src sh
> echo -e "1\t2\t3"
> #+end_src
>
> #+RESULTS:
> | 1 | 2 | 3 |
>
> #+begin_src haskell :var table=tbl
> print table
> #+end_src
>
> #+RESULTS:
> | 1 | 2 | 3 |
>
> Whereas before it would not print the table out because it isn't parsed 
> correctly.

The table is parsed and printed correctly on the latest main.
I use GHC 9.0.2-r3.

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