Re: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Liu Hui
Jack Kamm  于2023年12月30日周六 06:20写道:
>
> Liu Hui  writes:
>
> > But it is indeed possible that two sessions are inconsistent, if users
> > intend to have different org-babel-python-command and
> > python-shell-interpreter, which are used by
> > `org-babel-python-initiate-session' and `run-python', respectively.
>
> I have just proposed this patch, which will reduce this discrepancy by
> having ob-python sessions use the same interpreter as `run-python' by
> default:
>
> https://list.orgmode.org/87edf41yeb@gmail.com/T/#u

Thanks! It is a nice change IMO.

> Additionally, we could set `python-shell-interpreter(-args)' in
> `org-babel-edit-prep:python' to make `run-python' in Org Src buffer use
> the same interpreter as :python header or customized
> `org-babel-python-command'.

Agree. I think it can address the concern about inconsistent sessions.



Suggestion to add hook to be run when org-indent completes a buffer's initialization

2023-12-29 Thread dark . key8799
The org-modern-indent package relies on org-indent having finished preparing a 
buffer to add its own customizations. Currently it relies on a timer mechanism 
to watch org-indent-agentized-buffers and execute once a buffer has been 
prepped by org-indent.

That leads to some downstream issues in particular use-cases 
(https://github.com/jdtsmith/org-modern-indent/issues/11)

Although there are some workarounds for the particular issue above, a cleaner 
solution would be org-indent calling some hook at the end of the preparation. 
As per link above, jdtsmith proposes to add such call in 
org-indent-initialize-buffer:

 ;; Job is complete: un-agentize buffer.
 (unless interruptp
   (setq org-indent-agentized-buffers
 (delq buffer org-indent-agentized-buffers))
   (run-hook-with-args 'org-indent-buffer-init-finished buffer)) ;; <-- 
added

-- 
Alexandre Avanian



Re: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Jack Kamm
Liu Hui  writes:

> But it is indeed possible that two sessions are inconsistent, if users
> intend to have different org-babel-python-command and
> python-shell-interpreter, which are used by
> `org-babel-python-initiate-session' and `run-python', respectively.

I have just proposed this patch, which will reduce this discrepancy by
having ob-python sessions use the same interpreter as `run-python' by
default:

https://list.orgmode.org/87edf41yeb@gmail.com/T/#u

Additionally, we could set `python-shell-interpreter(-args)' in
`org-babel-edit-prep:python' to make `run-python' in Org Src buffer use
the same interpreter as :python header or customized
`org-babel-python-command'. See the changes to
`org-babel-python-initiate-session-by-key' in the linked patch for an
example -- specifically the part using `split-string-and-unquote' to get
the 2 parts for `python-shell-interpreter' and
`python-shell-interpreter-args', respectively.



[PATCH] Change default ob-python session command to match run-python

2023-12-29 Thread Jack Kamm
The attached patch changes the default behavior of ob-python sessions,
to respect python-shell-interpreter(-args) when starting an interactive
session.

It also allows separate customization of the default Python command for
nonsessions and sessions.

This mainly benefits IPython users.  IPython isn't suitable as the
default command for nonsessions, but until now there isn't a way to set
it as the default interpreter for sessions only.

Another benefit is to promote greater consistency between ob-python.el
and upstream python.el, in particular for shells started with
run-python.  If a user configures python-shell-interpreter(-args), then
ob-python will respect those settings now.

As explained in the NEWS entry, this change should have no effect on
users who previously configured `org-babel-python-command', or on users
who stick to the default `python-shell-interpreter'.  But I submit the
patch for review before applying it, because it involves changing the
default values of some custom variables.

>From a49ddcb6ef72cfefab400e36e6d4a19e869c47a1 Mon Sep 17 00:00:00 2001
From: Jack Kamm 
Date: Fri, 29 Dec 2023 13:22:18 -0800
Subject: [PATCH] ob-python: Changed options for default Python command

ob-python will now use the same settings as `run-python' when starting
interactive sessions, by default.

* lisp/ob-python.el (org-babel-python-command): Changed to have
default value of nil.
(org-babel-python-command-session): New option to control default
session Python command.
(org-babel-python-command-nonsession): New option to control default
nonsession Python command.
(org-babel-execute:python): Set `org-babel-python-command-session' and
`org-babel-python-command-nonsession' using :python header arg.
(org-babel-python-initiate-session-by-key): Call `run-python' without
CMD arg.  Instead, set `python-shell-interpreter' and
`python-shell-interpreter-args' when needed.
(org-babel-python-evaluate-external-process): Use
`org-babel-python-command-nonsession' to start nonsession Python.
---
 etc/ORG-NEWS  | 30 
 lisp/ob-python.el | 58 ---
 2 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c54473f55..688735a5b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -551,6 +551,36 @@ Currently implemented options are:
 The capture template expansion element =%K= creates links using
 ~org-store-link~, which respects the values of ~org-id-link-to-use-id~.
 
+*** Changes to ~org-babel-python-command~, and new session/nonsession specific options
+
+The default Python command used by interactive sessions has been
+changed to match ~python-shell-interpreter~ and
+~python-shell-interpreter-args~ by default.  The default Python
+command for nonsessions has not changed.
+
+New options ~org-babel-python-command-nonsession~ and
+~org-babel-python-command-session~ control the default Python command
+for nonsessions and sessions, respectively.  By default,
+~org-babel-python-command-session~ is nil, which means to use the
+configuration for ~python-shell-interpreter(-args)~ as default.
+
+The old option ~org-babel-python-command~ has been changed to have
+default value of nil.  When non-nil, it overrides both
+~org-babel-python-command-nonsession~ and
+~org-babel-python-command-session~.  Therefore, users who had
+previously set ~org-babel-python-command~ will not experience any
+changes.
+
+Likewise, users who had neither set ~org-babel-python-command~ nor
+~python-shell-interpreter(-args)~ will not see any changes -- ~python~
+remains the default command.
+
+The main change will be for users who did not configure
+~org-babel-python-command~, but did configure
+~python-shell-interpreter~, e.g. to use IPython.  In this case,
+~ob-python~ will now start interactive sessions in a more consistent
+manner with ~run-python~.
+
 ** New features
 *** =ob-plantuml.el=: Support tikz file format output
 
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 6b3a608c8..2b17f41fe 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -46,10 +46,31 @@ (defconst org-babel-header-args:python
 (python . :any))
   "Python-specific header arguments.")
 
-(defcustom org-babel-python-command "python"
-  "Name of the command for executing Python code."
-  :version "24.4"
-  :package-version '(Org . "8.0")
+(defcustom org-babel-python-command nil
+  "Name of the command for interactive and non-interactive Python code.
+If set, it overrides `org-babel-python-command-session' and
+`org-babel-python-command-nonsession'."
+  :version "29.2"
+  :package-version '(Org . "9.7")
+  :group 'org-babel
+  :type '(choice string (const nil)))
+
+(defcustom org-babel-python-command-session nil
+  "Name of the command for starting interactive Python sessions.
+If `nil' (the default), uses the values from
+`python-shell-interpreter' and `python-shell-interpreter-args'.
+If `org-babel-python-command' is set, then it overrides this
+option."
+  :vers

[BUG] M-x org-lint gives spurious warning when file contains a link with percent-encoded url [9.6.13 ( @ /home/user/.emacs.d/elpa/org-9.6.13/)]

2023-12-29 Thread Suhail Singh


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


Running M-x org-lint on an org file with below contents results in a
spurious "Link escaped with obsolete percent-encoding syntax" warning.

#+begin_src org
* org-lint url percent-encoding syntax warning
[[https://www.example.com?param=hello%20world][test url]]
#+end_src

I would expect the above org file to not yield any warnings.

Emacs  : GNU Emacs 29.1 (build 2, x86_64-suse-linux-gnu, GTK+ Version 3.24.38, 
cairo version 1.18.0)
Package: Org mode version 9.6.13 ( @ /home/user/.emacs.d/elpa/org-9.6.13/)

-- 
Suhail



Adding functionality to org-latex-classes

2023-12-29 Thread Pedro Andres Aranda Gutierrez
Hi,

I was just wondering whether it would be possible to add further
functionality to org-latex-classes and would like to start a discussion ;-)

My use case is the following:

The document class is tightly coupled with  ~org-latex-subtitle-format~
and  ~org-latex-subtitle-separate~. Koma-script classes, for example, need
those variables to be defined with file or directory local variables in
order to take full profit of the layouts. If we found a way of
accommodating them in the class definitions, the fuzz of the extra
variables could easily be overcome.

Default would be the default values from ox-latex.el and both variables
should be handled separately, IMHO.

Any ideas?

Best wishes for 2024, peace everywhere as a result of running a couple of
leader-deposed hooks ;-)

/PA
--
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: [PATCH] Set Python shell in Org edit buffer

2023-12-29 Thread Jack Kamm
Ihor Radchenko  writes:

> As long as it remains undocumented, we can break this in future (maybe
> years from now, but still...).

Fair enough, I've had to fix this feature from time to time due to
breakage in the past.

I just pushed d0d838b02 which should hopefully prevent future breakage:

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d0d838b02e44a40adca14d6eae39fd4c364730da

It adds a unit test for this feature, and makes the docstrings for
org-babel-python-initiate-session(-by-key) more thorough. It also
improves robustness if the source block is executed before run-python
finishes initializing.

> What might be more robust is to provide an explicit "start session
> from Org Src buffer" command for ob-python and re-bind `run-python' to
> this command in Org Src buffers.

We could refactor `org-babel-python-initiate-session-by-key' to call a
separate `org-babel-python-run-python' interactive command that wraps
`run-python', and then rebind `run-python' to it in a local minor mode
for ob-python Src buffers, which could be started in
`org-babel-edit-prep:python'.

But I'm not sure if it's worth the hassle, or if d0d838b02 already
addresses the concern sufficiently?

Note that I'd like ob-python to keep working with run-python, even if
it's invoked outside of an Org Src buffer.



Re: [BUG] ox-odt.el overrides auto-mode-alist defaults [9.6.6 (release_9.6.6 @ /usr/share/emacs/29.1/lisp/org/)]

2023-12-29 Thread Ihor Radchenko
Ihor Radchenko  writes:

> I am not applying the patches yet just in case if some users are relying
> on the removed behaviour. If anyone reading this does use this undocumented
> feature, please reply, and we will discuss how to retain it.

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=69e746c1e
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=996441fd5

Fixed.

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



Re: Should org-link-parser add type "file" when link has no "file:" prefix?

2023-12-29 Thread Ihor Radchenko
Joseph Turner  writes:

> I expect the following to return "[[/foobar]]":
>
> (with-temp-buffer
>   (delay-mode-hooks (org-mode))
>   (insert "[[/foobar]]")
>   (goto-char (point-min))
>   (let ((link (org-element-link-parser)))
> (org-element-link-interpreter link nil)))
>
> Instead, it returns "[[file:/foobar]]".

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

> In hyperdrive.el currently, "[[/foobar]]" and "[[file:/foobar]]" have
> different meanings: a link with no protocol prefix, like "[[/foobar]]",
> points to a file inside of the same hyperdrive (virtual p2p folder),
> whereas a link with the "file" protocol prefix, like "[[file:/foobar]]",
> points to a file on the local filesystem:

I do not recommend such approach. From the point of view of most of the
Org mode code, it makes no difference whether file link has file: or
not. So, you may face unexpected issues.

It would be more reliable to provide a separate link type.
We might even extend the special file+application: link type syntax that
already allows special behavior for opening file links.

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