Re: Help: How to change faces of words between parenthesis

2024-02-13 Thread William Denton
On Sunday, February 11th, 2024 at 08:57, Ypo  wrote:

> Could it be possible to change the color of words between parentheses?
> 
> For example, in:
> 
> "mejorar su bienestar psicológico (Cronin et al., 2012; Molero, Fuster, 
> Jetten y Moriano, 2011; Outten, Schmitt, García y Branscombe, 2009; 
> Pérez-Garín et al., 2016)."

For citations in brackets, another approach might be to use Org's citation 
system with the CSL export processor, and then use András Simonyi's 
org-cite-csl-activate and customize the face:

https://github.com/andras-simonyi/org-cite-csl-activate

That might involve changing your whole citation process, which is a big step, 
but citations are on my mind so I thought I'd mention it.

Bill

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


> 
> 
> 
> Best regards



[BUG] Warning: The error was: (error "Invalid search bound (wrong side of point)") [9.6.15 (release_9.6.15 @ z:/emacs-i686/share/emacs/29.2/lisp/org/)]

2024-02-13 Thread Ypo
I got a warning, which asked to be reported. Not sure why it happened, I 
think it was when I refreshed calfw calendar:


https://pastebin.com/1C88sLdt

Best


Re: [patch] Add two new header args to LaTeX block

2024-02-13 Thread Juan Manuel Macías
Ihor Radchenko writes:

> Juan Manuel Macías  writes:
>
>>> Moreover, it would be nice to unify handling .png and imagemagick
>>> branches of the code.
>>
>> I agree. In any case, I still think that the coexistence of two methods
>> to convert to images, when one of the methods has a scheme so different
>> from the rest, becomes difficult: for the user as well as for
>> maintaining the code.
>>
>> The first solution that occurs to me (I'm afraid it's too radical) is to
>> leave only the :imagemagick method, and maintain the possibility of
>> using the other one through a variable. Something like
>> org-babel-latex-default-image-conversion-method or something similar.
>> But I suppose this could cause unwanted inconveniences. We should see
>> what more users think.
>
> I am not sure.
> Conceptually, .png method is more flexible than imagemagick - it uses
> `org-create-formula-image' that is handling (1) preamble; (2) conversion
> not only to png but to svg and other arbitrary formats.
> ob-latex is duplicating org-create-formula-image code, layering custom
> latex preamble and more commands on top.
> So, ideally, I'd prefer to obsolete the custom code in ob-latex and make
> use of `org-create-formula-image', possibly extending it to fit ob-latex
> needs.

It is true that the "org-create-formula-image" method is much more
complete. But, IMHO, I think it's a method focused on the buffer (rather
than the block) or previewing LaTeX code in the buffer. In the case of
the LaTeX block, I think the :imagemagick method is simpler. It depends
on two simple processes: imagemagick and org-latex-pdf-process and
parameters such as the width or height of the generated image, the
density in dpi, etc. can be easily applied, via arguments. In the case
of the other method, in addition to the value of
org-preview-latex-default-process, there is that of
org-format-latex-options. There are, in short, many parameters that are
perfect for a file or an Emacs session but for a simple block I find
overhelming.

In any case, if the org-create-formula-image method is going to stay, I
think it is fine as it is (except for extending the allowed file formats
to more extensions, and not only .png). I also believe that the :process
argument is sufficient for the user to control the value of
org-latex-pdf-process or org-preview-latex-default-process, as
appropriate.

Best regards,

Juan Manuel 

-- 
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño 
editorial y ortotipografía




Re: Best way to extract info from C files?

2024-02-13 Thread Jude DaShiell
Study sed once you get a script going correctly and you pass sed several
files you'll love the speed it uses to get the work done.  While I was
working I managed to break 106 different files.  I figured with no
mistakes I could fix them in two weeks manually and no mistakes never
happens on manual jobs.  So I studied sed and threw the 106 files at sed
and sed took care of that job for me in 6 minutes and did it accurately.


--
 Jude 
 "There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo.
 Please use in that order."
 Ed Howdershelt 1940.

On Tue, 13 Feb 2024, Stefano Ghirlanda wrote:

> Hi all!
>
> I'm trying to build a simple code documentation tool for org-mode, so
> I'm looking for ways to get information from C files (to begin with,
> ideally it will be easy to add other languages). Things like function
> prototypes, struct definitions, etc. What would be the best tool for
> this? My search has come up with things like lsp-mode, semantic, etags
> but I have no experience with any of these. What would be easiest to
> work with / setup, and have the necessary functionality? Or should I
> just write my own parsing code?
>
> More specifically, my initial goal is to be able to parse things in a
> format similar naturaldocs.org, for example:
>
> // Function: This is a brief description.
> // Parameters:
> // - x: The first parameter
> // - y: The second parameter
> // Return: A value
> int my_function( int x, int y );
>
> and transform this into something like:
>
> * Documentation
>
> ** my_function
>
> This is a brief description
>
> | Parameters: |  |
> | x   | The first parameter   |
> | y   | The second parameter |
> ||
> | Return  | A value |
>
> To be improved iteratively :)
>
> Thanks!
>
>



Re: Retaking AUTO for \usepackage{fontenc}

2024-02-13 Thread Juan Manuel Macías
Pedro Andres Aranda Gutierrez writes:

> neither do I, This is why I'm asking for people to tell me what they
> use ;-)

The babel ini files (why hadn't I thought of this before :-): look in the babel 
ini files:

/tex/generic/babel/locale/

There you have all the information by language. For example, in
babel-fr.ini:

8<--

; This file is part of babel. For further details see:
;   https://www.ctan.org/pkg/babel
; Data has been collected mainly from the following sources:
; * babel language styles (license LPPL):
;   https://www.ctan.org/pkg/babel-contrib
; * Common Locale Data Repository (license Unicode):
;   http://cldr.unicode.org/
;   http://unicode.org/copyright.html

[identification]
charset = utf8
version = 0.981
date = 2022-05-14
name.local = français
name.english = French
name.babel = french
name.polyglossia = french
tag.bcp47 = fr
language.tag.bcp47 = fr
tag.bcp47.likely = fr-Latn-FR
tag.opentype = FRA
script.name = Latin
script.tag.bcp47 = Latn
script.tag.opentype = latn
level = 1
encodings = T1 OT1 LY1 <==
derivate = no
.
-->8

--

Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño 
editorial y ortotipografía



Re: Retaking AUTO for \usepackage{fontenc}

2024-02-13 Thread Pedro Andres Aranda Gutierrez
Hi Juan,

neither do I, This is why I'm asking for people to tell me what they use ;-)

best, /PA

On Tue, 13 Feb 2024 at 12:57, Juan Manuel Macías 
wrote:

> Pedro Andres Aranda Gutierrez writes:
>
> > Hi,
> >
> > Next step, @all, please help me filling up the list of codings vs.
> > languages. I currently am somehow confident of the following:
> >
> > greek -> LGR
> > russian -> T2A
>
> The information is in the encguide PDF (you can run texdoc fontenc or
> texdoc encguide). You should look especially at section 2.3 256 glyph
> encodings. I don't know if some languages require more than one
> encoding. Cyrillic appears to be T2A, T2B and T2C. T4 is for
>
> "The African Latin fonts contain in their lower half (0–127) the same
> characters as the European Latin (T1-encoded) Fonts, while in their
> upper half (128–255) they contain letters and symbols for African
> languages that use extended Latin alphabets."
>
> etc.
>
> But I can't find a simpler list anywhere.
>
> Best regards,
>
> Juan Manuel
>
> --
> Juan Manuel Macías -- Composición tipográfica, tratamiento de datos,
> diseño editorial y ortotipografía
>
>

-- 
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


Re: Best way to extract info from C files?

2024-02-13 Thread Stefano Ghirlanda
And I have just learned about org-ctags from another post on the
list... Would that be an option?

On Tue, Feb 13, 2024 at 7:58 AM Stefano Ghirlanda
 wrote:
>
> Hi all!
>
> I'm trying to build a simple code documentation tool for org-mode, so
> I'm looking for ways to get information from C files (to begin with,
> ideally it will be easy to add other languages). Things like function
> prototypes, struct definitions, etc. What would be the best tool for
> this? My search has come up with things like lsp-mode, semantic, etags
> but I have no experience with any of these. What would be easiest to
> work with / setup, and have the necessary functionality? Or should I
> just write my own parsing code?
>
> More specifically, my initial goal is to be able to parse things in a
> format similar naturaldocs.org, for example:
>
> // Function: This is a brief description.
> // Parameters:
> // - x: The first parameter
> // - y: The second parameter
> // Return: A value
> int my_function( int x, int y );
>
> and transform this into something like:
>
> * Documentation
>
> ** my_function
>
> This is a brief description
>
> | Parameters: |  |
> | x   | The first parameter   |
> | y   | The second parameter |
> ||
> | Return  | A value |
>
> To be improved iteratively :)
>
> Thanks!
>
> --
> Stefano Ghirlanda
> CTO, DataWorks - https://dataworks.consulting
> Guest Professor - Stockholm University Centre for Cultural Evolution



-- 
Stefano Ghirlanda
CTO, DataWorks - https://dataworks.consulting
Guest Professor - Stockholm University Centre for Cultural Evolution



Re: [patch] ox.latex.el: Add missing character warnings

2024-02-13 Thread Juan Manuel Macías
Ihor Radchenko writes:

> Probably something to do with my Texlive technically having Chinese
> support.
>
> I am getting
>
> ! Package inputenc Error: Unicode character 你 (U+4F60)
> (inputenc)not set up for use with LaTeX.
>
> See the inputenc package documentation for explanation.
> Type  H   for immediate help.
>  ...  
>   
> l.28 Hello. 你
>好.
>
> ! Package inputenc Error: Unicode character 好 (U+597D)
> (inputenc)not set up for use with LaTeX.
>
> See the inputenc package documentation for explanation.
> Type  H   for immediate help.
>  ...  
>   
> l.28 Hello. 你好

I have fixed the org-latex-known-warnings regexp in the attached patch.
I think it should work fine now...

-- 
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño 
editorial y ortotipografía

>From 742d67f2e8d4f1896d89f7543948facd65687ffe Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias 
Date: Tue, 13 Feb 2024 16:56:23 +0100
Subject: [PATCH] lisp/ox-latex.el: Add missing character warnings

* (org-latex-known-warnings): Two missing character warnings are
added: one for LuaLaTeX/XelaTeX and another for pdfLaTeX.
---
 lisp/ox-latex.el | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index cfa2b8178..2fdc2afe8 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1511,6 +1511,8 @@ logfiles to remove, set `org-latex-logfiles-extensions'."
 ("Underfull \\hbox" . "[underfull hbox]")
 ("Overfull \\hbox" . "[overfull hbox]")
 ("Citation.*?undefined" . "[undefined citation]")
+("^!.+Unicode character" . "[unicode character(s) not set up for use with pdflatex. You can run lualatex or xelatex instead]")
+("Missing character: There is no" . "[Missing character(s): please load an appropriate font with the fontspec package]")
 ("Undefined control sequence" . "[undefined control sequence]"))
   "Alist of regular expressions and associated messages for the user.
 The regular expressions are used to find possible warnings in the
@@ -4435,7 +4437,11 @@ encountered or nil if there was none."
 (save-excursion
   (goto-char (point-max))
   (when (re-search-backward "^[ \t]*This is .*?TeX.*?Version" nil t)
-	(if (re-search-forward "^!" nil t) 'error
+	(if (and
+	 (re-search-forward "^!\\(.+\\)" nil t)
+ ;; This error is passed as missing character warning
+ (not (string-match-p "Unicode character" (match-string 1
+'error
 	  (let ((case-fold-search t)
 		(warnings ""))
 	(dolist (warning org-latex-known-warnings)
-- 
2.43.1



Best way to extract info from C files?

2024-02-13 Thread Stefano Ghirlanda
Hi all!

I'm trying to build a simple code documentation tool for org-mode, so
I'm looking for ways to get information from C files (to begin with,
ideally it will be easy to add other languages). Things like function
prototypes, struct definitions, etc. What would be the best tool for
this? My search has come up with things like lsp-mode, semantic, etags
but I have no experience with any of these. What would be easiest to
work with / setup, and have the necessary functionality? Or should I
just write my own parsing code?

More specifically, my initial goal is to be able to parse things in a
format similar naturaldocs.org, for example:

// Function: This is a brief description.
// Parameters:
// - x: The first parameter
// - y: The second parameter
// Return: A value
int my_function( int x, int y );

and transform this into something like:

* Documentation

** my_function

This is a brief description

| Parameters: |  |
| x   | The first parameter   |
| y   | The second parameter |
||
| Return  | A value |

To be improved iteratively :)

Thanks!

-- 
Stefano Ghirlanda
CTO, DataWorks - https://dataworks.consulting
Guest Professor - Stockholm University Centre for Cultural Evolution



Re: [PATCH] org-agenda: Make sure skipping warning/delay days never increases their number

2024-02-13 Thread Tim Ruffing
Added a test.

> Please do not remove arguments from the public functions. This may
> break
> code outside Org mode.
> 

Hm, sure, I assumed it's okay for this niche thing. Can we deprecate
the argument somehow?

Best,
Tim
From b886446be8ea02f38d9be6cccf6899d6de396d06 Mon Sep 17 00:00:00 2001
From: Tim Ruffing 
Date: Tue, 13 Feb 2024 10:57:29 +0100
Subject: [PATCH] org-agenda: Make sure skipping warning/delay days never
 increases their number

* lisp/org-agenda.el (org-agenda-get-deadlines, org-agenda-get-scheduled):
Use minimum of warning/delay days specified in timestamp cookie and the
limit specified by `org-agenda-skip-deadline-prewarning-if-scheduled' or
`org-agenda-skip-scheduled-delay-if-deadline`, respectively.
* testing/lisp/test-org-agenda.el (test-org-agenda/skip-deadline-prewarning-if-scheduled):
New test
---
 lisp/org-agenda.el  | 15 +---
 testing/lisp/test-org-agenda.el | 41 +
 2 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 514359b62..53878e441 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6399,14 +6399,14 @@ specification like [h]h:mm."
 		   (org-agenda--timestamp-to-absolute
 		s base 'future (current-buffer) pos)
 	  (diff (- deadline current))
-	  (suppress-prewarning
+	  (max-wdays
 		   (let ((scheduled
 		  (and org-agenda-skip-deadline-prewarning-if-scheduled
(org-element-property
 :raw-value
 (org-element-property :scheduled el)
 		 (cond
-		  ((not scheduled) nil)
+		  ((not scheduled) most-positive-fixnum)
 		  ;; The current item has a scheduled date, so
 		  ;; evaluate its prewarning lead time.
 		  ((integerp org-agenda-skip-deadline-prewarning-if-scheduled)
@@ -6420,7 +6420,7 @@ specification like [h]h:mm."
 			org-deadline-warning-days))
 		  ;; Set pre-warning to deadline.
 		  (t 0
-	  (wdays (or suppress-prewarning (org-get-wdays s
+	  (wdays (min max-wdays (org-get-wdays s
 	 (cond
 	  ;; Only display deadlines at their base date, at future
 	  ;; repeat occurrences or in today agenda.
@@ -6610,13 +6610,13 @@ scheduled items with an hour specification like [h]h:mm."
 	  (futureschedp (> schedule today))
 	  (habitp (and (fboundp 'org-is-habit-p)
(string= "habit" (org-element-property :STYLE el
-	  (suppress-delay
+	  (max-ddays
 		   (let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
 (org-element-property
  :raw-value
  (org-element-property :deadline el)
 		 (cond
-		  ((not deadline) nil)
+		  ((not deadline) most-positive-fixnum)
 		  ;; The current item has a deadline date, so
 		  ;; evaluate its delay time.
 		  ((integerp org-agenda-skip-scheduled-delay-if-deadline)
@@ -6636,10 +6636,7 @@ scheduled items with an hour specification like [h]h:mm."
 		((and (string-match-p "--[0-9]+[hdwmy]" s)
 		  (> schedule (org-agenda--timestamp-to-absolute s)))
 		 0)
-		(suppress-delay
-		 (let ((org-scheduled-delay-days suppress-delay))
-		   (org-get-wdays s t t)))
-		(t (org-get-wdays s t)
+		(t (min max-ddays (org-get-wdays s t))
 	 ;; Display scheduled items at base date (SCHEDULE), today if
 	 ;; scheduled before the current date, and at any repeat past
 	 ;; today.  However, skip delayed items and items that have
diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index f98214b25..3348db473 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -687,6 +687,47 @@ Sunday  7 January 2024
 (should-not (org-agenda-files)))
   (org-test-agenda--kill-all-agendas))
 
+(ert-deftest test-org-agenda/skip-deadline-prewarning-if-scheduled ()
+  "Test `org-agenda-skip-deadline-prewarning-if-scheduled'."
+  (org-test-at-time
+   "2024-01-15"
+   (let ((org-agenda-skip-deadline-prewarning-if-scheduled t))
+ (org-test-agenda-with-agenda
+  "* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
+  (org-agenda-list nil nil 1)
+  (should-not (search-forward "In " nil t
+   (let ((org-agenda-skip-deadline-prewarning-if-scheduled 10))
+ (org-test-agenda-with-agenda
+  "* TODO foo\nDEADLINE: <2024-01-20 Sat> SCHEDULED: <2024-01-19 Fri>"
+  (org-agenda-list nil nil 1)
+  (should (search-forward "In " nil t
+   ;; Custom prewarning cookie "-3d", so there should be no warning anyway.
+   (let ((org-agenda-skip-deadline-prewarning-if-scheduled 10))
+ (org-test-agenda-with-agenda
+  "* TODO foo\nDEADLINE: <2024-01-20 Sat -3d> SCHEDULED: 

Re: [DISCUSSION, default settings] Using mailcap as default handler for opening file links

2024-02-13 Thread Max Nikulin

On 13/02/2024 22:44, Max Nikulin wrote:

(info "emacs-mailcap")


(info "emacs-mime")




interaction of fontified calendar entries and org-read-date

2024-02-13 Thread John Kitchin
I am trying to debug something in org-read-date.

If I run this code:

(let* ((mark-calendar (lambda ()
(calendar-mark-visible-date
(read (format-time-string "(%m %d %Y)"))
'font-lock-warning-face)))
   (calendar-today-visible-hook))
  (add-hook 'calendar-today-visible-hook
   mark-calendar)
  (org-read-date))

I get a little calendar that pops up, today is marked red, and there is a
red square on it. I can use shift arrows to move the red box around so i
can see what day is selected.

This slightly different code (differs only in assigning an anonymous face
instead of an actual face doesn't do that exactly. Today is still marked
red, but it is no longer selected with the inverse square. Neighboring days
do get the red square, but not "today".

(let* ((mark-calendar (lambda ()
(calendar-mark-visible-date
(read (format-time-string "(%m %d %Y)"))
(list :foreground "red" :weight 'bold
   (calendar-today-visible-hook))
  (add-hook 'calendar-today-visible-hook
   mark-calendar)
  (org-read-date))

This is somewhat of an xy kind of question. I am writing code that sets the
color of a day based on the number of tasks due that day, so I can't
exactly define faces for all of those, and I was using the anonymous face
for that. However, in doing that I lost the inverse video selection cursor
so it is hard to tell where the cursor actually is.

I assume that somewhere the cursor is getting an inverse-video attribute
from the face that isn't present in the anonymous face, but I haven't been
able to figure out where that comes in.

Any suggestions for either how to fix this, or another approach to coloring
the days in the calendar?

-- 
John

---
Professor John Kitchin (he/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
https://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroad.com/ pycse bookstore


Re: [DISCUSSION, default settings] Using mailcap as default handler for opening file links

2024-02-13 Thread Max Nikulin

On 13/02/2024 18:27, Ihor Radchenko wrote:

Max Nikulin writes:

I am mostly going to address user confusion about mailcap


XDG configuration and so xdg-open behavior is often confusing to users 
as well, especially in the cases of KDE and no DE. In GNOME it is 
alleviated by a step with the application chooser if default application 
has not been set yet.



(1) a number
of people are using DMs that rely on FreeDesktop and xdg-open;


DM is display manager. Even DE (desktop environment) is not necessary, 
some toolkits and applications have their own implementations of XDG specs.



(2) Emacs' mailcap does not implement the specification fully - only a
subset of mailcap format is obeyed.


Agree. On the other hand, mailcap.el is aware that Emacs can handle some 
files internally. This feature should be preserved in some way. In 
addition, mailcap has to be used if neither DISPLAY nor WAYLAND_DISPLAY 
is set for current terminal.



xdg-mime is more close to the file(1) tool


That might be a good alternative to file indeed; although file is
probably more widely installed.


xdg-mime and xdg-open belong to the same package. In the case of no DE 
xdg-mime calls file(1) (if mimetype(1) is not installed).



Yes, but mailcap is not documented in Emacs manual.


(info "emacs-mailcap") However it is not as useful as it should be.


Is it necessary to modify Org? Maybe an alternative is to add "xdg-open
%s" for */* to `mailcap-user-mime-data'.


Do you mean changing the default value of `mailcap-mime-data'?


I am unsure what is a proper way to do it. I am not confident enough 
with the code that selects handlers for files.



I believe that xdg-open issue has been fixed by you in
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5db61eb0f
org.el: Avoid xdg-open silent failure


I am still not really comfortable due to the strategy to start external
processes diverged from methods used in browse-url.el.


Is it related to the problem at hand?


- Eli had objections, but did not provide any details.
- Error handling code was dropped for the sake of Emacs-25.
- In the case of no DE, quit from emacs means terminating of started 
applications.

- I hope a bug I faced is exotic enough to never happen in real life.

Unfortunately another approach is a kind of trade-off, not an 
unambiguous advantage.



AFAIK, xdg.el does not support xdg-open functionality. We cannot use it
here.


`xdg-mime-apps' looks like a building block. However it is not enough 
and perhaps has enough bugs.


Ideally Emacs should provide API that uses either xdg.el or mailcap.el 
as backend depending on runtime and user configuration. Org is not the 
only package that needs it.


P.S.
Ihor, perhaps your clock is several minutes ahead.




Re: [BUG] org-clock-in opens buffers for all agenda files

2024-02-13 Thread jman


I am a bit confused and I am probably missing some context.

The documentation of `org-clock-auto-clock-resolution` states: "When to 
automatically resolve open clocks found in Org buffers." and the options are 
"Never", "Always", "When no clock is running".

I think I understand the idea behind this variable but I can't relate that to a 
solution of the problem stated.

Why checking for dangling clocks in all files in `org-directory`? Is it a 
common usecase to have clocks split in different files? I'd like `org-clock-in` 
to close any running clocks but only check the file open in current buffer and 
not in all .org files in `org-directory`.

Thanks for any help!



Re: Async Python src block behavior with :dir header property

2024-02-13 Thread Ihor Radchenko
Nasser Alkmim  writes:

> On the same note, it would be convenient to have a hook to run after the
> async execution returns the output.  Similar to
> 'org-babel-after-execute-hook'.  So I could, for instance, redisplay the
> inline image previews.  Is there an easy way to do that?

Maybe we can add a hook for `org-babel-insert-result'.

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



Re: [patch] ox.latex.el: Add missing character warnings

2024-02-13 Thread Ihor Radchenko
Juan Manuel Macías  writes:

 When I try the patch with a simple file like

 Hello. 你好。

 I do not see any warnings or errors indicated.
>>
>> I did
>> ...
>
> I have done the same, on a clean Emacs init. Warning appears.
>
> And in *Messages*:
>
> PDF file produced with warnings: [unicode character(s) not set up for use 
> with pdflatex. You can run lualatex or xelatex instead]
>
> In *Org PDF LaTeX Output*:
>
> ! LaTeX Error: Unicode character 你 (U+4F60)
>not set up for use with LaTeX.
>
> (this error is the one that passes as a warning in my patch when
> compiled with pdfLaTeX).

Probably something to do with my Texlive technically having Chinese
support.

I am getting

! Package inputenc Error: Unicode character 你 (U+4F60)
(inputenc)not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H   for immediate help.
 ...  
  
l.28 Hello. 你
   好.

! Package inputenc Error: Unicode character 好 (U+597D)
(inputenc)not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H   for immediate help.
 ...  
  
l.28 Hello. 你好


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



Re: [PATCH] org-agenda: Make sure skipping warning/delay days never increases their number

2024-02-13 Thread Ihor Radchenko
Tim Ruffing  writes:

> The attached patch fixes the following bug:
>
>  * Have a scheduled item that has also has a deadline with a cusom
>prewarning cookie, e.g. <... -3d>.
>  * Set `org-agenda-skip-deadline-prewarning-if-scheduled' to 7
>
> Then in the agenda, the item is shown already 7 days before the
> deadline (instead of 3). Judging from their name and documentation, the
> "skip" variables `org-agenda-skip-deadline-prewarning-if-scheduled' and
> `org-agenda-skip-scheduled-delay-if-deadline` should only ever skip
> items in the agenda. In other words, they should only shorten the
> prewarning or delay period, but never extend it. 

Thanks!
May you also add a test?

> -(defun org-get-wdays (ts  delay zero-delay)
> +(defun org-get-wdays (ts  delay)

Please do not remove arguments from the public functions. This may break
code outside Org mode.

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



Re: [patch] Add two new header args to LaTeX block

2024-02-13 Thread Ihor Radchenko
Juan Manuel Macías  writes:

>> Moreover, it would be nice to unify handling .png and imagemagick
>> branches of the code.
>
> I agree. In any case, I still think that the coexistence of two methods
> to convert to images, when one of the methods has a scheme so different
> from the rest, becomes difficult: for the user as well as for
> maintaining the code.
>
> The first solution that occurs to me (I'm afraid it's too radical) is to
> leave only the :imagemagick method, and maintain the possibility of
> using the other one through a variable. Something like
> org-babel-latex-default-image-conversion-method or something similar.
> But I suppose this could cause unwanted inconveniences. We should see
> what more users think.

I am not sure.
Conceptually, .png method is more flexible than imagemagick - it uses
`org-create-formula-image' that is handling (1) preamble; (2) conversion
not only to png but to svg and other arbitrary formats.
ob-latex is duplicating org-create-formula-image code, layering custom
latex preamble and more commands on top.
So, ideally, I'd prefer to obsolete the custom code in ob-latex and make
use of `org-create-formula-image', possibly extending it to fit ob-latex
needs.

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



Re: [BUG] Org may fetch remote content without asking user consent

2024-02-13 Thread Ihor Radchenko
Max Nikulin  writes:

> On 08/02/2024 22:07, Ihor Radchenko wrote:
>> 
>> `org--safe-remote-resource-p' checks the containing Org file as well, in
>> addition to #+included URL.
>
> If my reading of the code is correct then it considers 
> /ssh:host:org/include.org as safe if file:///ssh:host:org/test.org is 
> added to `org-safe-remote-resources'. I was considering a case when 
> there is no matching entry in `org-safe-remote-resources'. The user 
> opens (C-x C-f) /ssh:host:org/test.org and likely it is enough to 
> consider /ssh:host:org/include.org safe as well due to the same origin 
> "/ssh:host:".

I don't think so. And even if it is safe, I do not view it as a major
obstacle that will annoy users. There is an option to add the current
host to safe resources. No reason to layer complicated logic here -
simpler is more reliable.

>>> I am not confident in proper policy though. When some URI matches a
>>> pattern in the safe list, likely it is suitable for files created by the
>>> user and it is not really safe to allow it for a mail message attachment.
>> 
>> May you elaborate?
>
> Consider a user that has "#+include:" loaded from their own public 
> repository and used for some babel computations. It is safe when 
> included into user's files. I am not sure that it is safe for an org 
> file opened through a link in the browser. Perhaps it is better to avoid 
> included files in `org-safe-remote-resources' and add local directories 
> there.

What we may do is to add #+include + current file combination as safe
when user answers "!".

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



Re: Retaking AUTO for \usepackage{fontenc}

2024-02-13 Thread Juan Manuel Macías
Pedro Andres Aranda Gutierrez writes:

> Hi,
>
> Next step, @all, please help me filling up the list of codings vs.
> languages. I currently am somehow confident of the following:
>
> greek -> LGR
> russian -> T2A

The information is in the encguide PDF (you can run texdoc fontenc or
texdoc encguide). You should look especially at section 2.3 256 glyph
encodings. I don't know if some languages require more than one
encoding. Cyrillic appears to be T2A, T2B and T2C. T4 is for

"The African Latin fonts contain in their lower half (0–127) the same
characters as the European Latin (T1-encoded) Fonts, while in their
upper half (128–255) they contain letters and symbols for African
languages that use extended Latin alphabets."

etc.

But I can't find a simpler list anywhere.

Best regards,

Juan Manuel 

-- 
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño 
editorial y ortotipografía




Re: Org-cite/Citar cannot recognize neither biblatex nor natbib

2024-02-13 Thread Ihor Radchenko


Alessandro Bertulli  writes:
> I think I spotted the problem. It's difficult to be sure, but
> apparently, since version 4.31, latexmk automatically detects and run
> biber as a citation engine (see this post
> https://tex.stackexchange.com/a/231351/259874). In fact, in the latexmk
> man page, it is said to use the option -bibtex to use BibTeX.

On the latest Org, using latexmk 4.80, I can compile using both biblatex
and natbib citation processors just fine.

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



Re: Extra paragraphs incorrectly spawning when ":end:" appears.

2024-02-13 Thread Ihor Radchenko
Ihor Radchenko  writes:

> "Tom Alexander"  writes:
>
>> This test document should have 1 paragraph but org-mode is parsing it as 2:
>> ```
>> foo
>> :end:
>> baz
>> ```
>>
>> which parses as:
>> ```
>> (section
>>   (paragraph "foo\n")
>>   (paragraph ":end:\nbaz\n")
>> )
>> ```
> 
> The documentation is not accurate here.
>
> The parser uses anything that _potentially_ looks like the beginning of
> another element to calculate paragraph boundaries
> (`org-element-paragraph-separate'). ":end:" is potentially a drawer and
> thus ends the preceding paragraph.

I was wrong.
`org-element-paragraph-parser' actually does perform forward-checking.
So, your example is a genuine bug in the parser. (and the relevant tests
were not very accurate due to copy-pasting)
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=61c235b77

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



Re: [DISCUSSION, default settings] Using mailcap as default handler for opening file links

2024-02-13 Thread Ihor Radchenko
Max Nikulin  writes:

>> I have been digging more on this issue recently, and I have found that
>> Carsten once attempted to tweak this default to use xdg-mime:
>
> Have you faced another issue with mailcap? Frankly speaking, I am unsure 
> what particular issues we are going to address (file type, Emacs and Org 
> versions, OS).

I am mostly going to address user confusion about mailcap - (1) a number
of people are using DMs that rely on FreeDesktop and xdg-open; they get
surprised when .mailcap is used - I've seen a number of questions in
IRC/Matrix and on reddit related to how Org mode opens file links; (2)
Emacs' mailcap does not implement the specification fully - only a
subset of mailcap format is obeyed.

So, I do not feel that Emacs' implementation of mailcap support is a
good default for most users.

> Did you intentionally mentioned "xdg-mime"?

No. I meant xdg-open.

> ... While xdg-open tries to find 
> suitable .desktop file to open a file, xdg-mime is more close to the 
> file(1) tool, but it consults signatures from shared-mime-info and 
> site config files. In addition, unlike file(1), it uses file 
> extensions to guess media type.

That might be a good alternative to file indeed; although file is
probably more widely installed.

> An advantage of mailcap.el is that it should allow users have 
> Emacs-specific Emacs-wide configuration for viewers.

Yes, but mailcap is not documented in Emacs manual.
FYI, I first heard that .mailcap files are a thing when I encountered
org-file-apps.

> ... In principle it 
> should be more reliable when invoking emacs through xdg-open when Emacs 
> is configured as a handler for some media types.

I doubt so. There are problems with mailcap.el and there might be
problems with Emacs media type configuration. I prefer xdg.

> Is it necessary to modify Org? Maybe an alternative is to add "xdg-open 
> %s" for */* to `mailcap-user-mime-data'.

Do you mean changing the default value of `mailcap-mime-data'?

>> I believe that xdg-open issue has been fixed by you in
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5db61eb0f
>> org.el: Avoid xdg-open silent failure
>
> I am still not really comfortable due to the strategy to start external 
> processes diverged from methods used in browse-url.el.

Is it related to the problem at hand?

> I have not had a look into xdg.el yet.

AFAIK, xdg.el does not support xdg-open functionality. We cannot use it
here.

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



Re: [DISCUSSION, default settings] Using mailcap as default handler for opening file links

2024-02-13 Thread Max Nikulin

On 12/02/2024 19:36, Ihor Radchenko wrote:

Max Nikulin writes:


I believe, there are enough issues with mailcap implementation in Emacs,
but do we have some alternative?

[...]


I have been digging more on this issue recently, and I have found that
Carsten once attempted to tweak this default to use xdg-mime:


Have you faced another issue with mailcap? Frankly speaking, I am unsure 
what particular issues we are going to address (file type, Emacs and Org 
versions, OS).


Did you intentionally mentioned "xdg-mime"? While xdg-open tries to find 
suitable .desktop file to open a file, xdg-mime is more close to the 
file(1) tool, but it consults signatures from shared-mime-info and 
site config files. In addition, unlike file(1), it uses file 
extensions to guess media type.


An advantage of mailcap.el is that it should allow users have 
Emacs-specific Emacs-wide configuration for viewers. In principle it 
should be more reliable when invoking emacs through xdg-open when Emacs 
is configured as a handler for some media types.


Is it necessary to modify Org? Maybe an alternative is to add "xdg-open 
%s" for */* to `mailcap-user-mime-data'.



I believe that xdg-open issue has been fixed by you in
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5db61eb0f
org.el: Avoid xdg-open silent failure


I am still not really comfortable due to the strategy to start external 
processes diverged from methods used in browse-url.el.


I have not had a look into xdg.el yet.




[PATCH] org-agenda: Make sure skipping warning/delay days never increases their number

2024-02-13 Thread Tim Ruffing
Hello,

The attached patch fixes the following bug:

 * Have a scheduled item that has also has a deadline with a cusom
   prewarning cookie, e.g. <... -3d>.
 * Set `org-agenda-skip-deadline-prewarning-if-scheduled' to 7

Then in the agenda, the item is shown already 7 days before the
deadline (instead of 3). Judging from their name and documentation, the
"skip" variables `org-agenda-skip-deadline-prewarning-if-scheduled' and
`org-agenda-skip-scheduled-delay-if-deadline` should only ever skip
items in the agenda. In other words, they should only shorten the
prewarning or delay period, but never extend it. 

Best,
Tim
From 5db0ac7115b86a12d1a2106eb54b07d339f69ed6 Mon Sep 17 00:00:00 2001
From: Tim Ruffing 
Date: Tue, 13 Feb 2024 10:57:29 +0100
Subject: [PATCH] org-agenda: Make sure skipping warning/delay days never
 increases their number

* lisp/org-agenda.el (org-agenda-get-deadlines, org-agenda-get-scheduled):
Use minimum of warning/delay days specified in timestamp cookie and the
limit specified by `org-agenda-skip-deadline-prewarning-if-scheduled' or
`org-agenda-skip-scheduled-delay-if-deadline`, respectively.
* lisp/org.el (org-get-wdays): Remove unused (and confusing) ZERO-DELAY
argument.
---
 lisp/org-agenda.el | 15 ++-
 lisp/org.el|  7 ++-
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 514359b62..53878e441 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6399,14 +6399,14 @@ specification like [h]h:mm."
 		   (org-agenda--timestamp-to-absolute
 		s base 'future (current-buffer) pos)
 	  (diff (- deadline current))
-	  (suppress-prewarning
+	  (max-wdays
 		   (let ((scheduled
 		  (and org-agenda-skip-deadline-prewarning-if-scheduled
(org-element-property
 :raw-value
 (org-element-property :scheduled el)
 		 (cond
-		  ((not scheduled) nil)
+		  ((not scheduled) most-positive-fixnum)
 		  ;; The current item has a scheduled date, so
 		  ;; evaluate its prewarning lead time.
 		  ((integerp org-agenda-skip-deadline-prewarning-if-scheduled)
@@ -6420,7 +6420,7 @@ specification like [h]h:mm."
 			org-deadline-warning-days))
 		  ;; Set pre-warning to deadline.
 		  (t 0
-	  (wdays (or suppress-prewarning (org-get-wdays s
+	  (wdays (min max-wdays (org-get-wdays s
 	 (cond
 	  ;; Only display deadlines at their base date, at future
 	  ;; repeat occurrences or in today agenda.
@@ -6610,13 +6610,13 @@ scheduled items with an hour specification like [h]h:mm."
 	  (futureschedp (> schedule today))
 	  (habitp (and (fboundp 'org-is-habit-p)
(string= "habit" (org-element-property :STYLE el
-	  (suppress-delay
+	  (max-ddays
 		   (let ((deadline (and org-agenda-skip-scheduled-delay-if-deadline
 (org-element-property
  :raw-value
  (org-element-property :deadline el)
 		 (cond
-		  ((not deadline) nil)
+		  ((not deadline) most-positive-fixnum)
 		  ;; The current item has a deadline date, so
 		  ;; evaluate its delay time.
 		  ((integerp org-agenda-skip-scheduled-delay-if-deadline)
@@ -6636,10 +6636,7 @@ scheduled items with an hour specification like [h]h:mm."
 		((and (string-match-p "--[0-9]+[hdwmy]" s)
 		  (> schedule (org-agenda--timestamp-to-absolute s)))
 		 0)
-		(suppress-delay
-		 (let ((org-scheduled-delay-days suppress-delay))
-		   (org-get-wdays s t t)))
-		(t (org-get-wdays s t)
+		(t (min max-ddays (org-get-wdays s t))
 	 ;; Display scheduled items at base date (SCHEDULE), today if
 	 ;; scheduled before the current date, and at any repeat past
 	 ;; today.  However, skip delayed items and items that have
diff --git a/lisp/org.el b/lisp/org.el
index 7da23310d..75f062508 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14454,17 +14454,14 @@ If SECONDS is non-nil, return the difference in seconds."
   (and (<= (org-timestamp-to-now timestamp-string) ndays)
(not (org-entry-is-done-p
 
-(defun org-get-wdays (ts  delay zero-delay)
+(defun org-get-wdays (ts  delay)
   "Get the deadline lead time appropriate for timestring TS.
 When DELAY is non-nil, get the delay time for scheduled items
-instead of the deadline lead time.  When ZERO-DELAY is non-nil
-and `org-scheduled-delay-days' is 0, enforce 0 as the delay,
-don't try to find the delay cookie in the scheduled timestamp."
+instead of the deadline lead time."
   (let ((tv (if delay org-scheduled-delay-days
 	  org-deadline-warning-days)))
 (cond
  ((or (and delay (< tv 0))
-	  (and delay zero-delay (<= tv 0))
 	  (and (not delay) (<= tv 

Re: Async Python src block behavior with :dir header property

2024-02-13 Thread Nasser Alkmim
Excellent job Ihor and Jack.

On the same note, it would be convenient to have a hook to run after the
async execution returns the output.  Similar to
'org-babel-after-execute-hook'.  So I could, for instance, redisplay the
inline image previews.  Is there an easy way to do that?

-- 
Nasser Alkmim 
 +43 677 6408 9171