BUG: (org-insert-subheading) fails when on true begin of line (first star) of heading

2023-05-11 Thread Michael Dauer
Example
* h1
<>** h11

brings:
* h1
*** <>
** h11

expected:
* h1
** h11
*** <>

Org mode version 9.7-pre (release_9.6.4-327-gf81ba4


[BUG] Wrap LaTeX Fragments in a Span [9.6.2 (release_9.6.2)]

2023-05-11 Thread Gustaf Waldemarson
Hello,

The other day I wanted to do some additional styling of LaTeX (MathJax)
elements, however, I noticed that none of them were actually captured in any
HTML tag or CSS class, making this a bit cumbersome.

So I spent a bit of time to look things up and see if this could be fixed
and
came up with the attached patch, which wraps all LaTeX fragments in a  tag. Ideally, one should probably have separate CSS
classes
for inline fragments and full environments, but I wasn't really able to
figure
out how to separate those.

Also, I don't know if this interferes with anything else, but it seems to
work
fine in some pretty big org-mode files for me at least.

Below is also a simple test org-mode file, in case someone wants to try it
out
or add more test cases.


#+TITLE: LaTeX to HTML Math Tests
#+OPTIONS:

* Environments

This section should contain some supported MathJax environments.

\begin{equation}
  e = mc^{2}
\end{equation}
\begin{equation*}
  f = ma
\end{equation*}

* Inline

In this section we are talking about inline math, such as the
equations \(e = mc^{2}\) or $f = ma$, which were proposed by some
famous person.


Best regards,
Gustaf


Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.20, cairo version 1.16.0)
 of 2023-04-04
Package: Org mode version 9.6.2 (release_9.6.2 @
/home/guswal01/.local/share/emacs/30.0.50/lisp/org/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-directory "/home/guswal01/.config/emacs/org/"
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-log-into-drawer t
 org-latex-images-centered nil
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
 org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-show-empty-lines
  org-cycle-optimize-window-after-visibility-change
org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-modules '(org-tempo ol-w3m ol-bbdb ol-bibtex ol-docview ol-gnus
ol-info ol-irc ol-mhe ol-rmail
   ol-eww)
 org-mode-hook '(#[0 " \205
From 4827ab1faca73ea9fba1031bfc5713c100f23bd3 Mon Sep 17 00:00:00 2001
From: Gustaf Waldemarson 
Date: Thu, 11 May 2023 10:49:57 +0200
Subject: [PATCH] ox-html: Wrap LaTeX fragments in a span.

It is sometimes useful to control the styling or post-processing of
LaTeX environments.
---
 lisp/ox-html.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index b519402b1..504c49213 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3012,7 +3012,7 @@ INFO is a plist containing export properties."
  :to-buffer (get-buffer-create " *Org HTML Export LaTeX*")
  :drop-visibility t :drop-narrowing t :drop-contents t
  (erase-buffer)
- (insert latex-frag)
+ (insert (format "%s" latex-frag))
  (org-format-latex cache-relpath nil nil cache-dir nil
 		   "Creating LaTeX Image..." nil processing-type)
  (buffer-string
-- 
2.25.1



Re: BUG: org-cycle does not unfold some subtrees

2023-05-11 Thread Ihor Radchenko
William Denton  writes:

>> Does it also help if you run M-: (org-fold-core--clear-isearch-overlays)?
>
> That worked!  I just had the problem.  I ran that, and the tree popped open!

Do you use evil-mode?

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



Re: refiling heading onto itself

2023-05-11 Thread Ihor Radchenko
Oliver Epper  writes:

> When choosing the very same heading that is going to be refiled as its
> target the message buffer states success but the heading is gone. This is
> version 9.5.5 of org-mode with emacs 28.2

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

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



Re: refiling heading onto itself

2023-05-11 Thread Ihor Radchenko
Ruijie Yu via "General discussions about Org-mode."
 writes:

> ... (2) the completiong system shouldn't even provide
> "two" as a completion candidate.

Maybe. The current implementation of refile target selection is not
aware about the context. One might try to temporarily extend
`org-refile-target-verify-function', but we currently approach this
differently and check (in `org-refile') the selected refile target only,
throwing an error when attempting to refile into the child subtree.

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



Re: BUG: (org-insert-subheading) fails when on true begin of line (first star) of heading

2023-05-11 Thread Ihor Radchenko
Michael Dauer  writes:

> Example
> * h1
> <>** h11
>
> brings:
> * h1
> *** <>
> ** h11

This is expected. `org-insert-subheading' inherits what
`org-insert-heading' does:

Insert a new heading or an item with the same depth at point.

***
If point is at the beginning of a heading, insert a new heading
or a new headline above the current one.  When at the beginning
of a regular line of text, turn it into a heading.
***

If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
org-M-RET-may-split-line on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

With a C-u prefix, set org-insert-heading-respect-content to
a non-nil value for the duration of the command.  This forces the
insertion of a heading after the current subtree, independently
on the location of point.

With a C-u C-u prefix, insert the heading at the end of the tree
above the current heading.  For example, if point is within a
2nd-level heading, then it will insert a 2nd-level heading at
the end of the 1st-level parent subtree.

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



[PATCH] org-babel-load-languages: load unbound scheme-mode

2023-05-11 Thread gerard . vermeulen

Hello,

the attached patch fixes (setopt org-babel-load-languages '((scheme . 
t)))

before scheme-mode has been loaded.

Best regards -- Gerard


0001-org-babel-load-languages-load-unbound-scheme-mode.patch
Description: Binary data


Re: It's possible, to translate the org-mode website into Spanish?

2023-05-11 Thread General discussions about Org-mode.


Antonio Simón  writes:

> Greetings from Spain.
>
> I'm a newbie in the FOSS world and a big fan of Emacs and org-mode in which 
> I'm taking my first steps.
>
> I have seen that the Org mode page is available in several languages, and 
> Spanish is not one of them.
>
> I was thinking of contributing my time to the project by developing the 
> Spanish version of the site, if you find it useful.
>
> If you accept this collaboration I would need a small list of the tools and 
> procedures to use, to ensure that I'm competent with them.
>
> Thank you for your patience, I look forward to hearing from you.
>
> Regards, 
>
> ___
> Antonio Simón (Quijote)

Hi Antonio,

Since your initial message in January, are you still interested in
contributing a new translation to orgweb?

Assuming you still are interested, you can take the skeleton of my
(which is, admittedly, stalled due to lack of time) translation on
zh-CN, and go from there.  If you don't know where it is, I'll dig up a
url for you.

The workflow I used for zh-CN translation was
(1): first make a single mega-copy+symlink commit
(2): translate the org files one-by-one

This way reviewers don't need to go back and forth between two files and
"diff with naked eyes".

You can also choose to start small and only translate the main site at
first -- in fact, no translations except mine covers all
(reasonably-sized) pages of orgweb.

I believe either Ihor or Bastien mentioned somewhere that you need to
finish the FSF copyright assignment for the translation work as well.
I don't know who to ask on orgmode ML, but someone should be able to get
you started if you express interest in the translation work.

In any case, let the list know if you encounter any problems -- someone
should be able to resolve them should any comes up.

-- 
Best,


RY



Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-11 Thread Tim Visher
On Wed, May 10, 2023 at 5:04 PM Tim Visher  wrote:

> Can `org-capture` templates be made to result in a sub-heading of the
> current heading?
>
> So
>
> ```
> * This Week
> ** TODO A TODO Item
>
>[2023-05-05 Fri 10:47]
>
>A description 
> ```
>
> and I whack my capture keychord and get
>
> ```
> * This Week
> ** TODO A TODO Item
>
>[2023-05-05 Fri 10:47]
>
>A description
> *** [2023-05-10 Wed 17:02]
>
> [2023-05-10 Wed 17:02]
>
> 
> ```
>

It's worth noting that with a capture template like

```
("twj" "TODO Work TODO Journal" entry
 (file+headline "~/Documents/todo.org" "Inbox")
 "* %U

   %U

   %?")
```

If I do the usual `M-0 M-x org-capture` with point in the original spot it
behaves exactly as I want it to. My goal is to get it to behave that way
just by invoking the capture template.


Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-11 Thread Tim Visher
On Thu, May 11, 2023 at 8:42 AM Tim Visher  wrote:

> On Wed, May 10, 2023 at 5:04 PM Tim Visher  wrote:
>
>> Can `org-capture` templates be made to result in a sub-heading of the
>> current heading?
>>
>> So
>>
>> ```
>> * This Week
>> ** TODO A TODO Item
>>
>>[2023-05-05 Fri 10:47]
>>
>>A description 
>> ```
>>
>> and I whack my capture keychord and get
>>
>> ```
>> * This Week
>> ** TODO A TODO Item
>>
>>[2023-05-05 Fri 10:47]
>>
>>A description
>> *** [2023-05-10 Wed 17:02]
>>
>> [2023-05-10 Wed 17:02]
>>
>> 
>> ```
>>
>
> It's worth noting that with a capture template like
>
> ```
> ("twj" "TODO Work TODO Journal" entry
>  (file+headline "~/Documents/todo.org" "Inbox")
>  "* %U
>
>%U
>
>%?")
> ```
>
> If I do the usual `M-0 M-x org-capture` with point in the original spot it
> behaves exactly as I want it to. My goal is to get it to behave that way
> just by invoking the capture template.
>

OK after poking around in `org-capture-set-target-location` I think I have
this sorted. Please let me know if I'm doing something obviously silly. :)

```
(defun timvisher--org-capture-sub-heading-insertion-point
()
  (insert "\n")
  (forward-char)
  (org-capture-put :exact-position (point) :insert-here t))

;; Embedded in the capture templates list
("twj" "TODO Work TODO Journal" entry
 (function timvisher--org-capture-sub-heading-insertion-point)
 "* %U

  %U

  %?")
```

The key was finding that it wasn't enough to merely move point to the
proper location. I _also_ needed to call `org-capture-put`. The docs on
this subject are a little misleading, IMHO.

‘(function function-finding-location)’
>  Most general way: write your own function which both visits
>  the file and moves point to the right location.


Empirically it seems like you have to visit the file, move point to the
right location, _and_ call `org-capture-put`.

-- Tim Visher


Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?

2023-05-11 Thread Tim Visher
On Thu, May 11, 2023 at 9:05 AM Tim Visher  wrote:

> On Thu, May 11, 2023 at 8:42 AM Tim Visher  wrote:
>
>> On Wed, May 10, 2023 at 5:04 PM Tim Visher  wrote:
>>
>>> Can `org-capture` templates be made to result in a sub-heading of the
>>> current heading?
>>>
>>> So
>>>
>>> ```
>>> * This Week
>>> ** TODO A TODO Item
>>>
>>>[2023-05-05 Fri 10:47]
>>>
>>>A description 
>>> ```
>>>
>>> and I whack my capture keychord and get
>>>
>>> ```
>>> * This Week
>>> ** TODO A TODO Item
>>>
>>>[2023-05-05 Fri 10:47]
>>>
>>>A description
>>> *** [2023-05-10 Wed 17:02]
>>>
>>> [2023-05-10 Wed 17:02]
>>>
>>> 
>>> ```
>>>
>>
>> It's worth noting that with a capture template like
>>
>> ```
>> ("twj" "TODO Work TODO Journal" entry
>>  (file+headline "~/Documents/todo.org" "Inbox")
>>  "* %U
>>
>>%U
>>
>>%?")
>> ```
>>
>> If I do the usual `M-0 M-x org-capture` with point in the original spot
>> it behaves exactly as I want it to. My goal is to get it to behave that way
>> just by invoking the capture template.
>>
>
> OK after poking around in `org-capture-set-target-location` I think I have
> this sorted. Please let me know if I'm doing something obviously silly. :)
>
> ```
> (defun timvisher--org-capture-sub-heading-insertion-point
> ()
>   (insert "\n")
>   (forward-char)
>   (org-capture-put :exact-position (point) :insert-here t))
>
> ;; Embedded in the capture templates list
> ("twj" "TODO Work TODO Journal" entry
>  (function timvisher--org-capture-sub-heading-insertion-point)
>  "* %U
>
>   %U
>
>   %?")
> ```
>

Minor correction. I need to both insert a newline _and *leave*_ point where
it was or I don't get a sub-heading at the proper level (the current level
of the previous journal entry). If I don't insert the newline then
cancelling the entry also pulls the next heading up into the text of the
current heading.

```
(defun timvisher--org-capture-sub-heading-insertion-point
()
  (insert "\n")
  (org-capture-put :exact-position (point) :insert-here t))
…
```

-- Tim Visher


Re: BUG: org-cycle does not unfold some subtrees

2023-05-11 Thread William Denton

On 11 May 2023, Ihor Radchenko wrote:


William Denton  writes:


Does it also help if you run M-: (org-fold-core--clear-isearch-overlays)?


That worked!  I just had the problem.  I ran that, and the tree popped open!


Do you use evil-mode?


Definitely not.


Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada
CO₂: 424.17 ppm (Mauna Loa Observatory, 2023-05-09)

Re: BUG: org-cycle does not unfold some subtrees

2023-05-11 Thread Ihor Radchenko
William Denton  writes:

>> Do you use evil-mode?
>
> Definitely not.

Curious.
This function is supposed to be run upon finishing or aborting isearch.
What is the value of `isearch-mode-end-hook' in your Org buffers?

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



Re: BUG: org-cycle does not unfold some subtrees

2023-05-11 Thread William Denton

On 11 May 2023, Ihor Radchenko wrote:


William Denton  writes:


Do you use evil-mode?


Definitely not.


Curious.
This function is supposed to be run upon finishing or aborting isearch.
What is the value of `isearch-mode-end-hook' in your Org buffers?


(anzu--reset-mode-line org-fold-core--clear-isearch-overlays t)
Local in buffer conforguration.org; global value is nil

I checked in a few buffers, and it always says it's local in that buffer, with 
global value of nil, if that matters.


Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada
CO₂: 424.32 ppm (Mauna Loa Observatory, 2023-05-10)

Re: [BUG] Wrap LaTeX Fragments in a Span [9.6.2 (release_9.6.2)]

2023-05-11 Thread Ihor Radchenko
Gustaf Waldemarson  writes:

> The other day I wanted to do some additional styling of LaTeX (MathJax)
> elements, however, I noticed that none of them were actually captured in any
> HTML tag or CSS class, making this a bit cumbersome.
>
> So I spent a bit of time to look things up and see if this could be fixed
> and
> came up with the attached patch, which wraps all LaTeX fragments in a  class="equation"> tag. Ideally, one should probably have separate CSS
> classes
> for inline fragments and full environments, but I wasn't really able to
> figure
> out how to separate those.

See `org-html--wrap-latex-environment'.
`org-html-latex-environment' does wrap latex environments into equation
class, but not for mathjax processing type.

CCing the maintainer.

It looks reasonable to wrap Mathjax fragments as well. But there might
be non-obvious pitfalls.

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



Re: [PATCH] org-babel-load-languages: load unbound scheme-mode

2023-05-11 Thread Ihor Radchenko
gerard.vermeu...@posteo.net writes:

> the attached patch fixes (setopt org-babel-load-languages '((scheme . 
> t)))
> before scheme-mode has been loaded.

Thanks, but may you please elaborate what is the problem you are trying
to solve?

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



Re: CVE-2023-28617 (was Re: [PATCH] Fix ob-latex.el command injection vulnerability.)

2023-05-11 Thread Max Nikulin

On 02/05/2023 18:21, Ihor Radchenko wrote:

Max Nikulin writes:


I posted the links as a reminder that shell commands should be avoided
when possible (and it does not break TRAMP) and arguments should be
escaped otherwise.


But this patch literally fixed the problem. What else should we do?


Do you really think that it was the last unsafe shell command in the Org 
code?


https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ob-ditaa.el#n101
and (shell-command pdf-cmd) below

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/ob-lilypond.el#n194

Of course, you may say that expanding shell constructs in :file header 
argument is a feature that allows more flexibility. Personally, I 
inspect Org files obtained from external resources in some dumb enough 
viewer before opening them in Emacs.



I suppose, the issue has been received too much attention already:

- https://security-tracker.debian.org/tracker/CVE-2023-28617
- https://ubuntu.com/security/notices/USN-6003-1
- https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2023-28617


These appear to be different issues.


Linux distributions had to react to the CVE with formally high score and 
updated Emacs packages applying 2 tiny patches from this thread.






Re: [PATCH] org-babel-load-languages: load unbound scheme-mode

2023-05-11 Thread gerard . vermeulen




On 11.05.2023 17:05, Ihor Radchenko wrote:

gerard.vermeu...@posteo.net writes:


the attached patch fixes (setopt org-babel-load-languages '((scheme .
t)))
before scheme-mode has been loaded.


Thanks, but may you please elaborate what is the problem you are trying
to solve?


I think that I have seen Emacs complaining about unbound scheme-mode
when playing with ob-scheme, but I cannot reproduce it.

I am sorry for the noise -- Gerard