Re: PATCH: ox-latex table of contents patch consolidated (was: [BUG] Latex exporter should consider export settings [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)])

2025-02-21 Thread Pedro Andres Aranda Gutierrez
Thanks for spotting the alt-title handling ;-) Apply this on top of my last
patch.

Best, /PA

On Thu, 20 Feb 2025 at 19:13, Ihor Radchenko  wrote:

> Pedro Andres Aranda Gutierrez  writes:
>
> > Final version... got the wrong file... sorry /PA
>
> Thanks!
> You still did not address all the earlier suggestions.
> I will repeat the missing ones below for your convenience.
>
> > modified   doc/org-manual.org
> > @@ -14852,6 +14852,41 @@ *** Quote blocks in LaTeX export
> >  \end{foreigndisplayquote}
> >  #+end_example
> >
> > +#+cindex: LaTeX ToC export a la ~org~
> > +#+cindex: @samp{org-latex-toc-include-unnumbered-style}
> > +If you want the LaTeX exporter to behave like other exporters,
> > +customise the variable ~org-latex-toc-include-unnumbered-style~ and
> > +set it to ~t~:
>
> When I was suggesting this customization, what I had in mind is not
> t/nil values but 'latex and 'org (style: latex or style: org).
> For t/nil, a better name would be simply
> org-latex-toc-include-unnumbered.
>
> > +*** ox-latex: Table of contents generation has been fixed and augmented
> > +
> > +The LaTeX exporter differs from other exporters in that it *does not*
> > +export unnumbered sections by default.
> > +
> > +The LaTeX exporter will use the new property =:UNNUMBERED: toc= to
> > +include unnumbered sections in the table of contents.
>
> New property value. UNNUMBERED is the existing property.
>
> > +(defcustom org-latex-toc-include-unnumbered-style nil
> > +  "Set this variable to true to include unnumbered headings in the
> > +table of contents as other exporters do.
> > +
> > +The default behaviour is to include numbered headings only.
> > +To include an unnumbered heading, set the `:UNNUMBERED:'
> > +property to `toc'"
> > +  :group 'org-export-latex
> > +  :package-version '(Org . "9.8")
> > +  :type 'boolean
> > +  :safe #'booleanp)
>
> I am wondering if we need to accompany this with an export option
> keyword to be set per-buffer.
>
> > +(when need-alternative
> > +  (if (string-suffix-p "*" section-kw)
> > +  (progn ;; unnumbered sections
> > +;; Then we need to obey what the :UNNUMBERED:
> property says
> > +(if org-latex-toc-include-unnumbered-style ;;
> legacy or new behavior ?
> > +;; new behavior (á la org)
>
> May you not use "new" and "legacy" here? Instead, use LaTeX/Org style.
> "new" only makes sense for people familiar with the old version of the
> code, but not for people reading ox-latex afresh.
>
> > +;; In all cases
> > +;; Get rid of the footnotes in opt-title
> > +(unless (equal full-text-no-footnote full-text)
> > +  (setq opt-title full-text-no-footnote))
>
> What if ALT_TITLE is specified explicitly in the headline?
>
> --
> Ihor Radchenko // yantar92,
> Org mode maintainer,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run
a leader-deposed hook here, but we can't yet
Year 1 of the New Koprocracy
From 18944194a38f1d7449fe640b17d4f5c39113d16b Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" 
Date: Fri, 21 Feb 2025 09:09:44 +0100
Subject: [PATCH 2/2] Ihor's comments and fix alternative title handling

---

* doc/org-manual.org: fix variable name: use
org-latex-toc-include-unnumbered to make it a boolean
* etc/ORG-NEWS: reflect changes in variable names
and minor quirks.
* lisp/ox-latex.el: rename variable to
org-latex-toc-include-unnumbered and fix alternative
title handling for titles with footnotes
* testing/lisp/test-ox-latex.el: Add tests for footnotes
in section titles with alternative title for the ToC

 doc/org-manual.org|  8 
 etc/ORG-NEWS  |  4 ++--
 lisp/ox-latex.el  | 19 ++-
 testing/lisp/test-ox-latex.el | 12 ++--
 4 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 2edb74986..dcc9a6dec 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -14867,13 +14867,13 @@ contents, use the property =UNNUMBERED= and set it to =toc=:
 #+end_example

 #+cindex: LaTeX ToC export a la ~org~
-#+cindex: @samp{org-latex-toc-include-unnumbered-style}
+#+cindex: @samp{org-latex-toc-include-unnumbered}
 If you want the LaTeX exporter to behave like other exporters,
-customise the variable ~org-latex-toc-include-unnumbered-style~ and
+customise the variable ~org-latex-toc-include-unnumbered~ and
 set it to ~t~:

 #+begin_example
-(setq org-latex-toc-include-unnumbered-style t)
+(setq org-latex-toc-include-unnumbered t)
 #+end_example

 or add this setting in the local variables.
@@ -

Re: Publish and file exclude

2025-02-21 Thread Sébastien Gendre
Yes, you are right.

Ihor Radchenko  writes:

> Sébastien Gendre  writes:
>
>> I have checked the source code, but I didn't find when the generation of
>> the site map also publish it.
>
> `org-publish-get-base-files'


signature.asc
Description: PGP signature


Re: [PATCH] cosmetic of begin/end lines

2025-02-21 Thread Ihor Radchenko
Phil Estival  writes:

>> Does the attached diff fix the problem you are encountering?
>
> Yes it does. Thank you!
>
> But we are losing that previous possibility we had of a
> bi-color display of meta lines, with the second part (past
> the text of a meta line) being of the color of the block.

That's an accidental feature. Just happen to work.

Historically, we always used org-fontifiy-whole-block-delimiter-line = t.
It became optional to fontify the newline to avoid underline extending
too far. See https://yhetil.org/emacs-bugs/83d0hd8ceh@gnu.org/

Looking at that discussion, it seems that it happened before :extend t
face attribute got introduced into Emacs. Maybe we can get along with
letting users set :extend t/nil in the face itself and deprecating
org-fontify-whole-block-delimiter-line.

> Maybe we can simplify a little the fontification of that
> area now by replacing org-fontify-whole-block-delimiter-line
> with the respective extend attribute instead and introducing
> an other variable.

What do you mean by "introducing another variable"?

> Line 5566 of org.el:
> ;; Fontify the #+begin and #+end lines of the blocks.
>
> A quick reminder of the structure of a block to
> understand what I'm saying next :
> [[#+begin_src] [lang] [switches]][remainder of the line]
> [block]
> [#+end_src][remainder of the line]
>
>  1) Begin/end src have a face inheriting from org-meta-line.
> They can extend all over the line.
>  2) A block fontification starts on the next line of
> a begin declaration.
>  3) When a meta line is not extended, the remainder is either:
>- not fontified (it has no text, it's a default face).
>- or, optionally, it is fontified like a block.
>  This, without identifying if the block fontification
>  should starts right past the meta-line text or at eol,
>  but simply, when set and not extending, adding the
>  extra strike of marker along the line.
>
> => Introduces org-block-fontify-meta-line
> (Non-nil means fontify past the text of begin/end
> lines of blocks with the block face to give the
> allure of a block covering those lines too.)
>
> Adding a face for the remainder of the line would also
> achieve the same result and even more for the area aspects.

So, you want [remainder of the line] to be fontified differently from
the rest of the #+begin_src ...?

> To me it's fine in the current state. My proposals are only
> meant for someone who would observe the change differently.

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



Re: PATCH: ox-latex table of contents patch consolidated (was: [BUG] Latex exporter should consider export settings [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)])

2025-02-21 Thread Ihor Radchenko
Pedro Andres Aranda Gutierrez  writes:

> Thanks for spotting the alt-title handling ;-) Apply this on top of my last
> patch.

Thanks!

> -  (let ((need-alternative (string-match "\\`\\(.+?\\){" 
> section-fmt))
> +  (let ((need-alternative (not (null (string-match 
> "\\`\\(.+?\\){" section-fmt

May you please explain this change?

> -  ;; legacy behavior (á la LaTeX)
> +  ;; Treat the ToC as it has been originally

Maybe "Ignore unnumbered headings in ToC - as in LaTeX"

>  ;; In all cases
>  ;; Get rid of the footnotes in opt-title
> -(unless (equal full-text-no-footnote full-text)
> -  (setq opt-title full-text-no-footnote))
> +(when (and (not (string= full-text-no-footnote full-text)) ;; 
> when we have footnotess
> +   (string= full-text-no-footnote opt-title))  ;; 
> And we do not impose an alternative title
> +(setq opt-title full-text-no-footnote))

So, what happens if opt-title is not set at all and the heading contains
a footnote? (string= full-text-no-footnote nil) will err.

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



Re: Question regarding org-publish-find-title cache

2025-02-21 Thread Ihor Radchenko
"Thomas Ingram"  writes:

>> The API in this area is not ideal, unfortunately.
>
> Since the caching requirement is not noted in the docstring, would you be 
> interested in a patch to allow these functions to work regardless of if the 
> cache is present?

Maybe. I'd like to hear more details about the intended use case and
about the code changes you have in mind.

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



Re: May we have a variant of display-buffer-reuse-window that considers indirect buffers?

2025-02-21 Thread Sébastien Gendre

Ok, I tested it with success.

I apply the patch on top of the following commits:
- Emacs: 4ece0e2e46b
- Org-mode: ff33d9ec2

And I have followed your instruction.


Ihor Radchenko  writes:

> Sébastien Gendre  writes:
>
>> Can someone regroup the patch I need to apply ?
>>
>> I'm a bit lost between them.
>
> I am attaching two files here:
> 1. display-indirect-buffer.diff
> 2. 0001-org-agenda-goto-Reuse-visible-indirect-buffer-window.patch
>
> You should
> 1. Download Emacs git repo
> 2. Apply display-indirect-buffer.diff on top
> 3. Re-compile Emacs from the repo
> 4. Download Org git repo
> 5. Apply 0001-org-agenda-goto-Reuse-visible-indirect-buffer-window.patch
>on top
> 6. Run Emacs from git repo and load Org from the Org git repo to test
>things with your setup.
>
> Hope the steps are not too confusing.
>
> diff --git a/lisp/window.el b/lisp/window.el
> index e9d57652ec6..5178e302238 100644
> --- a/lisp/window.el
> +++ b/lisp/window.el
> @@ -2615,7 +2615,36 @@ get-largest-window
> (setq best-window window
>  best-window))
>  
> -(defun get-buffer-window-list (&optional buffer-or-name minibuf all-frames)
> +(defun window-indirect-buffer-p (&optional window buffer-or-name)
> +  "Return non-nil if specified WINDOW is indirectly related to 
> BUFFER-OR-NAME.
> +WINDOW must be a live window and defaults to the selected window.
> +BUFFER-OR-NAME may be a buffer or the name of an existing buffer and
> +defaults to the current buffer.
> +
> +WINODW is indirectly related to BUFFER-OR-NAME if one of the following
> +conditions hold:
> +
> +- BUFFER-OR-NAME specifies an indirect buffer and WINDOW's buffer is its
> +  base buffer.
> +
> +- WINDOW's buffer is an indirect buffer whose base buffer is the buffer
> +  specified by BUFFER-OR-NAME.
> +
> +- Both, WINDOW's buffer and the buffer specified by BUFFER-OR-NAME, are
> +  indirect buffer's sharing the same base buffer.
> +
> +Return nil if none of the above holds."
> +  (let* ((window (window-normalize-window window t))
> +  (window-buffer (window-buffer window))
> +  (window-base-buffer (buffer-base-buffer window-buffer))
> +  (buffer (window-normalize-buffer buffer-or-name))
> +  (buffer-base-buffer (buffer-base-buffer buffer)))
> +(or (eq buffer-base-buffer window-buffer)
> + (eq window-base-buffer buffer)
> + (and buffer-base-buffer
> +  (eq buffer-base-buffer window-base-buffer)
> +
> +(defun get-buffer-window-list (&optional buffer-or-name minibuf all-frames 
> indirect)
>"Return list of all windows displaying BUFFER-OR-NAME, or nil if none.
>  BUFFER-OR-NAME may be a buffer or the name of an existing buffer
>  and defaults to the current buffer.  If the selected window displays
> @@ -2644,12 +2673,23 @@ get-buffer-window-list
>  - A frame means consider all windows on that frame only.
>  
>  Anything else means consider all windows on the selected frame
> -and no others."
> +and no others.
> +
> +INDIRECT non-nil means to append to the list of windows showing
> +BUFFER-OR-NAME a list of all windows that are indirectly related to
> +BUFFER-OR-NAME, that is, windows for which `window-indirect-buffer-p'
> +with the window and the buffer specified by BUFFER-OR-NAME as arguments
> +returns non-nil."
>(let ((buffer (window-normalize-buffer buffer-or-name))
> + (window-list (window-list-1 (selected-window) minibuf all-frames))
>   windows)
> -(dolist (window (window-list-1 (selected-window) minibuf all-frames))
> +(dolist (window window-list)
>(when (eq (window-buffer window) buffer)
>   (setq windows (cons window windows
> +(when indirect
> +  (dolist (window window-list)
> + (when (window-indirect-buffer-p window buffer)
> +   (setq windows (cons window windows)
>  (nreverse windows)))
>  
>  (defun minibuffer-window-active-p (window)
> @@ -8235,35 +8275,57 @@ display-buffer-reuse-window
>  event that a window on another frame is chosen, avoid raising
>  that frame.
>  
> +If ALIST has a non-nil `reuse-indirect' entry and no window showing
> +BUFFER has been found, try to find a window that is indirectly related
> +to BUFFER and return that window.  This would be a window for which
> +`window-indirect-buffer-p' with the window and BUFFER as arguments
> +returns non-nil.  If a suitable window has been found and the cdr of the
> +entry equals the symbol `buffer', do not replace the buffer of the
> +chosen window with BUFFER but return the window with its old buffer in
> +place.  Otherwise, put BUFFER into the chosen window and return the
> +window.
> +
>  This is an action function for buffer display, see Info
>  node `(elisp) Buffer Display Action Functions'.  It should be
>  called only by `display-buffer' or a function directly or
>  indirectly called by the latter."
> -  (let* ((alist-entry (assq 'reusable-frames alist))
> -  (frames (cond (alist-entry (cdr alist-entry))
> +  (let* ((reusable-frames (assq 'reusable-frames ali

Re: [RFC] The best way to choose an "action" at point: context-menu-mode, transient, which-key or embark?

2025-02-21 Thread Tor-björn Claesson
Thanks!

I have some questions.

Den tis 28 jan. 2025 kl 20:18 skrev Ihor Radchenko :

>
> Thanks!
> Here are more comments:
>
> 1. I am looking at C-- C-u prefix, and I am not sure if it is ideal
>What I think might be better is:
>- make a short C-- ('- argument) the switch
>- make the switch customizable (if users do not like C--)
>

I tried simply changing the switch from "-4" to "'", but this does not
work.
My google skills fail me here, and I would be grateful for some advice on
how to proceed.


> 4. Moving towards my item (2) in the plan, we need to generalize
>(transient-define-prefix org-cite-basic-follow ...) into a macro that
>can work for arbitrary command; not just for `org-cite-basic-follow'.
>Let me know if you want my help on how to write such a macro.


I'm trying to make this work. Is it OK to use (eval
`(transient-define-prefix ...)) here?
Also, I find it a bit easier to write this as a function rather than a
macro, but this makes calling it a bit uglier.
Should I try define this as a macro, or is a function acceptable?

Cheers,
Tor-björn


Re: [PATCH] lisp/org-collector.el: Add support for TBLFM

2025-02-21 Thread Slava Barinov
Hello,

Oh! Sorry, it seems I missed the last email.

Okay, in that case bounded re-search-forward up to the next paragraph should
work.

And as for maintenance, I think I can allocate some time for that.
What activities are expected from a script maintainer?

Best Regards,
Slava Barinov

Ihor Radchenko  writes:

> Ihor Radchenko  writes:
>
>> I am not familiar with org-collector code, but (goto-char (point-min))
>> seems dangerous - what if current Org buffer has multiple tables with
>> TBLFM lines?
>
> It has been a while since the last message in this thread.
> Have you had a chance to look into my comment?

>From 89325fcedf063ac69500ce9915721352819f9133 Mon Sep 17 00:00:00 2001
From: Slava Barinov 
Date: Fri, 21 Feb 2025 20:45:41 +0900
Subject: [PATCH] lisp/org-collector.el (org-dblock-write:propview): Add
 support for the :tblfm keyword.

---
 lisp/org-collector.el | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/org-collector.el b/lisp/org-collector.el
index b645d3a..ff1753d 100644
--- a/lisp/org-collector.el
+++ b/lisp/org-collector.el
@@ -122,6 +122,7 @@ preceding the dblock, then update the contents of the dblock."
 	(noquote (plist-get params :noquote))
 	(colnames (plist-get params :colnames))
 	(defaultval (plist-get params :defaultval))
+	(tblfm (plist-get params :tblfm))
 	(content-lines (org-split-string (plist-get params :content) "\n"))
 	id table line pos idpos stringformat)
 	(save-excursion
@@ -148,7 +149,19 @@ preceding the dblock, then update the contents of the dblock."
 	(while (setq line (pop content-lines))
 	  (when (string-match "^#" line)
 	(insert "\n" line)))
-	(goto-char pos)
+	(when tblfm
+	  (save-excursion
+	(let ((search-end (progn
+(forward-paragraph)
+(point
+	  (goto-char pos)
+	  (when (re-search-forward "^#\\+TBLFM:" search-end t)
+		(setq tblfm-pos (match-beginning 0))
+		(delete-region tblfm-pos (line-end-position)
+	  (unless (looking-back "\n" 1)
+	(insert "\n"))
+	  (insert (concat "#+TBLFM:" tblfm)))
+(goto-char pos)
 	(org-table-recalculate 'all))
 (org-collector-error (widen) (error "%s" er))
 (error (widen) (error "%s" er
-- 
2.48.1