[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-08 Thread Peter Prevos




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.


Hi,

ox-odt.el overrides the auto-mode-alist settings and instructs 
Emacs to open od[fgpst] files in archive-mode instead of 
doc-view-mode.


This line can be removed because it prevents Emacs from opening 
LibreOffice files.


The test is to open a LibreOffice file in vanilla Emacs and when 
ox-odt.el is activated.


Regards

P:)

Emacs  : GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.38, cairo version 1.17.8)
Package: Org mode version 9.6.6 (release_9.6.6 @ 
/usr/share/emacs/29.1/lisp/org/)


current state:
==
(setq
org-agenda-prefix-format '((dashboard-agenda . " %i %-12:c %s ")
(agenda . " %i %-12:c%?-12t% s")
(todo . " %i %-12:c")
(tags . " %i %-12:c")
(search . " %i %-12:c"))
org-archive-location 
"~/Documents/notes/20230604T152600--gtd-archive__productivity.org::* 
From %s"

org-link-elisp-confirm-function 'yes-or-no-p
org-directory "/home/peter/Documents/notes/"
org-cite-insert-processor 'citar
org-hide-emphasis-markers t
org-bibtex-headline-format-function #[257 "\300\236A\207" 
[:title] 3 "\n\n(fn ENTRY)"]

org-log-done 'time
org-capture-bookmark nil
org-agenda-custom-commands '(("n" "Netherlands" ((tags-todo 
"nl"))

   ((org-agenda-files
 (denote-directory-files-matching-regexp 
 "_gtd")

 )
)
   )
  ("h" "Third Hemisphere"
   ((agenda ""
 ((org-agenda-span 3)
  (org-agenda-start-on-weekday 
  nil))

 )
(todo "NEXT"
 ((org-agenda-overriding-header
   "Next Actions")
  )
 )
(todo "WAITING"
 ((org-agenda-overriding-header
   "Waiting")
  )
 )
(stuck))
   ((org-agenda-files
 (cl-remove-if
  (lambda (f)
   (string-match-p "_cw" f))
  (denote-directory-files-matching-regexp 
  "_gtd")

  )
 )
)
   )
  ("p" "Projects"
   ((todo "PROJECT")
(stuck ""
 ((org-agenda-sorting-strategy
   '(alpha-up priority-down))
  )
 )
)
   )
  ("c" "Work"
   ((agenda ""
 ((org-agenda-span 7)
  (org-agenda-start-on-weekday 1))
 )
(todo "NEXT") (todo "WAITING")
(stuck))
   ((org-agenda-files
 (denote-directory-files-matching-regexp 
 "_cw.*_gtd")

 )
)
   )
  )
org-log-into-drawer t
org-agenda-skip-scheduled-if-done t
org-agenda-files 
'("/home/peter/Documents/notes/20220718T190010--notes-inbox__gtd.org" 
"/home/peter/Documents/notes/20220719T125424--third-hemisphere-action-plan__gtd.org" 
"/home/peter/Documents/notes/20230104T060726--lucid-manager-action-plan__gtd_lucidmanager.org" 
"/home/peter/Documents/notes/20230104T193809--horizon-of-reason-action-plan__gtd.org" 
"/home/peter/Documents/notes/20230115T083737--magic-perspectives-action-plan__gtd_magic.org" 
"/home/peter/Documents/notes/20230821T094002--nederland__gjpc_gtd_nl.org" 
"/home/peter/Documents/notes/20230925T150445--coliban-water-actions__cw_gtd.org")

org-capture-templates '(("f" "Fleeting note" item
  (file+headline org-default-notes-file
   "Notes")
  "- %?")
 ("t" "New task" entry
  (file+headline org-default-notes-file
   "Tasks")
  

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

2023-12-08 Thread Liu Hui
Ihor Radchenko  于2023年12月8日周五 21:06写道:
>
> Liu Hui  writes:
>
> >> What about displaying a yes/no query about starting a new session when
> >> there is none?
> >
> > I think it is OK. I can add an option to allow users to disable the
> > query. WDYT?
>
> I now have second thoughts about obsoleting
> org-babel--associate-session.
> If we need a customization for the new session dialogue, I expect that
> users will be willing to set it for all src blocks that support such a
> feature, not just python. But then we somehow need to make this global
> customization visible to babel backend authors - something we normally
> do using the set of org-babel-...: functions.
>
> What I am thinking now is
> 1. Introduce a global customization for users to choose whether to
>start a new session in org-src buffers with allowed values t, nil,
>'ask, or an alist of (lang . t/nil/ask) for per-language customization.

I think it makes sense. Currently, org-babel-edit-prep:R/julia always
start the session when editing src blocks with a valid session header,
and other backends don't. It would allow users to change the behavior.

> 2. Check the new variable and attempt to run
>`org-babel--associate-session' in org-src-mode definition.

I think associating the edit buffer with some session doesn't require
starting the session, which is at least feasible for ob-python. When
editing python src block, users can use C-c C-p to start the session
themselves for evaluating code. So it would be nice to allow a value
of 'associate in the customization, which means just running
`org-babel--associate-session'.



Re: oeg-add-note and double backslash ?

2023-12-08 Thread David Masterson
Ihor Radchenko  writes:

> David Masterson  writes:
>
>> Hmm. glancing through the manual, there is a bit of assumption implicit
>> about the use of '\\'.  We had the problem with Unix Shell scripts that
>> we would need a backslash at the end of a line to prevent the EOL as
>> being interpreted as end-of-input. Depending on the layers of scripting
>> we were using, we added backslashes after the backslash because each
>> layer would peel off a backslash.  This is what I first thought of in
>> reading the manual.
>
> We do document the line breaks in
> https://orgmode.org/manual/Paragraphs.html

The only thing I see with respect to '\\' is:

  Paragraphs are separated by at least one empty line.  If you need to
  enforce a line break within a paragraph, use ‘\\’ at the end of a line.

Which doesn't answer the question of why org-add-note (etc) added it the
end of the first line of a Note which lead to my confusion. It's easy to
assume, if Org is adding '\\' to the first line of the Note and the Note
is a unit, then this is there to prevent folding/wrapping in the Note
when Org does "something" (but what?).

-- 
David Masterson



Re: [PATCH] Add new option 'org-imenu-flatten'

2023-12-08 Thread William Denton

On 8 December 2023, Morgan Smith wrote:


Have you considered adding a "flatten" option to imenu itself?
That way, you could automatically get the functionality for free
everywhere, not just in Org mode.


I have considered that but gave up with minimal investigation because it
seemed harder then this solution.  It's possible imenu did actually have
this functionality sometime before 1998 (see commit
fe2908be7b09f4c765ebdaf16fe07b0a77f78ba8).


One of the things I love about Emacs is the longevity, which leads to someone 
musing about a feature that might have existed 25 (!) years ago.



Bill

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

Re: [PATCH] Add new option 'org-imenu-flatten'

2023-12-08 Thread Morgan Smith
Ihor Radchenko  writes:

>
> Have you considered adding a "flatten" option to imenu itself?
> That way, you could automatically get the functionality for free
> everywhere, not just in Org mode.

I have considered that but gave up with minimal investigation because it
seemed harder then this solution.  It's possible imenu did actually have
this functionality sometime before 1998 (see commit
fe2908be7b09f4c765ebdaf16fe07b0a77f78ba8).

The doc-view imenu-flatten stuff was added 2022-09-28 (see commit
fe002cc8ce38efb256a2a60660ee626c2b2cdf81).  This makes me feel like
maybe that person thought adding it to imenu directly would be hard.

I might at some point investigate doing that but likely not soon.  Also
if that feature was ever added, it would still be compatible with the
patch I sent.  For those reasons, I advocate my patch should still be
applied even though it is clear that it is a sub-optimal solution.



Re: [PATCH] Move files when using org-babel-tangle-publish

2023-12-08 Thread Antero Mejr
Ihor Radchenko  writes:

> Also, may I know if you have an FSF copyright assignment? If not, you
> also need to add TINYCHANGE to the commit message - see
> https://orgmode.org/worg/org-contribute.html#first-patch

Yes I have assigned copyright to the FSF already.

> May you please submit a patch against Org mode git repository -
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git, as described at
> https://orgmode.org/worg/org-contribute.html ?
> Please quote `rename-file' and `copy-file' like I do - it is our commit
> message convention (https://orgmode.org/worg/org-contribute.html#orgd7441de)
>
>> -  (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file 
>> filename)))
>> +  (mapc (lambda (el) (rename-file el pub-dir t))
>> +(org-babel-tangle-file filename)))
>
> I think that it would be nice to add a brief comment why `rename-file'
> to the code as well.  `copy-file' looks innocent there from a first
> glance.

Fixed in attached patch.

>From 9cc194dcb9bf6825d68aac3118f18ae96b8642a5 Mon Sep 17 00:00:00 2001
From: Antero Mejr 
Date: Fri, 17 Nov 2023 16:06:53 +
Subject: [PATCH] Move files when using `org-babel-tangle-publish'

Fixes `copy-file' error when publishing to the current directory.
Don't leave behind the old tangled files when publishing.

* lisp/ob-tangle.el (org-babel-tangle-publish): Use `rename-file'
instead of `copy-file' on tangled files.
---
 lisp/ob-tangle.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index b30fd9274..e16b9e42d 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -219,7 +219,9 @@ Return list of the tangled file names."
   (unless (file-exists-p pub-dir)
 (make-directory pub-dir t))
   (setq pub-dir (file-name-as-directory pub-dir))
-  (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file filename)))
+  ;; Rename files to avoid copying to same file when publishing to ./
+  (mapc (lambda (el) (rename-file el pub-dir t))
+(org-babel-tangle-file filename)))
 
 ;;;###autoload
 (defun org-babel-tangle ( arg target-file lang-re)
-- 
2.41.0



Re: How to use mpirun with C or C++ Org-babel?

2023-12-08 Thread Ihor Radchenko
Leo Butler  writes:

> I submitted an imperfect patch some time ago [1] that targeted your use
> case: allow ob-C.el to create a named binary. Unfortunately, Ihor
> dropped the issue due to lack of interest from other users.
>
> My goal was to enable something like this to work:
>
> #+begin_src cpp :includes  :results none :file ./hello-world
> std::cout << "Hello World!\n";
> #+end_src
>
> #+begin_src bash :async t
> mpirun -np 4 ./hello-world
> #+end_src
>
> As I said, the patch I wrote was not perfect, but I am happy to re-visit
> the issue. The ability to create named binaries would significantly
> increase the usability of ob-C for projects where you want to compile
> the source once and run the binary repeatedly for potentially long
> periods of time.

Note that I did not oppose the above behaviour when the result of
evaluation is just compiling to :file. The problem was with compiling to
a :file and _also_ executing it.

If you want to propose a patch that will allow compile-only, I see no
problem at all.

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



Re: [PATCH] Add new option 'org-imenu-flatten'

2023-12-08 Thread Ihor Radchenko
Morgan Smith  writes:

> * lisp/org/org-compat.el: Add definition of 'org-imenu-flatten'.
> (org-imenu-get-tree): Use 'org-imenu-flatten'.
> ---
>
> Hello!
>
> I've been using this patch for a bit and I quite like it.  One would think
> there would be an option in imenu itself to flatten trees but that does not
> seem to be the case.  I copied the defcustom from 'doc-view-imenu-flatten'.

Have you considered adding a "flatten" option to imenu itself?
That way, you could automatically get the functionality for free
everywhere, not just in Org mode.

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



Re: [FR] Please add custom command variable to org-latex-footnote-reference

2023-12-08 Thread Ihor Radchenko
Alexander Gogl  writes:

> some LaTeX classes define their own footnote commands. For example, kaobook 
> (https://github.com/fmarotta/kaobook/blob/master/example_and_documentation.pdf)
>  has \footnotes and \sidenotes, whereby sidenotes (notes are put into the 
> outter margin) are the dominant form of putting notes in kaobook.
>
> It would be great if you could make the footnote command in the footnote 
> function customizable. It could look like this:
>
> ;; Replace footnote function to make the latex footnote command customizable
> (setq org-latex-footnote-command "\\footnote{%s%s}")

I see no problem with such an addition - it is conceptually similar to
the existing :latex-default-table-environment,
:latex-default-quote-environment, etc.

Would you be interested to write a patch?
See https://orgmode.org/worg/org-contribute.html

We might go even further, and allow setting default environments like
this per-document via keywords or as a part of `org-latex-classes'.

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



Re: Suggestion for org-agenda-list: pre-open org-agenda-files

2023-12-08 Thread Ihor Radchenko
"John Wiegley"  writes:

> Right away I discovered one of the reasons I had preferred properties at the
> bottom: When I startup my Emacs and run org-agenda-list, and then hit RET on
> an entry, no folding has been applied to the Org file and thus I see the full
> property block at the beginning of entries (and in my case, they can often be
> quite large). I have to scan down to find the actual text.
>
> Reading through the code, I found that org-agenda-list calls
> org-agenda-get-day-entries on each file in org-agenda-files, which
> intentionally disables code folding before opening the file if it isn’t open
> already:
>
>   (defun org-agenda-get-day-entries (file date  args)
> (let* ((org-startup-folded nil)
>   …)))

This should actually be redundant because all the agenda commands should
(if not, it is a bug) open the necessary buffers when calling
`org-agenda-prepare'->`org-agenda-prepare-buffers'. By default,
`org-agenda-prepare-buffers' applies initial folding, according to the
default nil value of `org-agenda-inhibit-startup'.

> My workaround for this is to visit every entry in org-agenda-files before
> calling org-agenda-list:
>
>   (require 'org-agenda)
>   (mapc #’find-file-noselect org-agenda-files)
>   (call-interactively 'org-agenda-list)

... and `org-agenda-list' does call `org-agenda-prepare'...

So, may you dig a bit further and check why `org-agenda-prepare' is not
opening the agenda files?

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



Re: org-agenda and org-agenda-columns, display time text property

2023-12-08 Thread Ihor Radchenko
Richard Sent  writes:

> It would be nice if there was a way to display the time text property 
> while using org-columns in the agenda by modifying 
> org-local-columns-format (or similar variables). Something like
>
> ;; in appropriate hook or similar
> (setq org-local-columns-format "%AGENDA_TIME %ITEM ..."
> ...
> a) it's overly wordy compared to the time text property e.g. [2023-11-18 
> Sat 11:30] vs. "11:30 ┄ "
> b) repeating timestamps are displayed as  [2023-11-11 Sat 14:30 +2d], 
> meaning you can't tell what time a particular entry is scheduled.
>
> org-columns does add some unique advantages to org-agenda. For example, 
> I like to add a LOCATION property to my entries and use %LOCATION to 
> display the location in the agenda. It's a shame that there's a tradeoff 
> when doing this.
>
> I have found an implementation that accomplishes this at 
> https://emacs.stackexchange.com/a/59940 and discussion at 
> https://lists.gnu.org/archive/html/emacs-orgmode/2020-08/msg00090.html, 
> but this seems to focus on a different problem related to 
> org-agenda-columns-add-appointments-to-effort-sum. It does not look like 
> the implementation discussed ever made its way in.

Providing a way to get some column values from agenda buffer does make
sense. Patches welcome!

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



Re: [PATCH] Move files when using org-babel-tangle-publish

2023-12-08 Thread Ihor Radchenko
Antero Mejr  writes:

> When publishing using org-babel-tangle-publish to the same directory
> that contains the org files, copy-file will signal an error, since the
> source and destination files refer to the same file. So use rename-file
> instead.
>
> When publishing to a different directory, this change also cleans up the
> old files, which matches the behavior of the other publishing functions
> like org-html-publish-to-html.

Thanks for the patch!
May you please submit a patch against Org mode git repository -
https://git.savannah.gnu.org/cgit/emacs/org-mode.git, as described at
https://orgmode.org/worg/org-contribute.html ?

Also, may I know if you have an FSF copyright assignment? If not, you
also need to add TINYCHANGE to the commit message - see
https://orgmode.org/worg/org-contribute.html#first-patch

> Fixes copy-file error when publishing to the current directory.
> Don't leave behind the old tangled files when publishing.
>
> * lisp/org/ob-tangle.el (org-babel-tangle-publish): Use rename-file
> instead of copy-file on tangled files.

Please quote `rename-file' and `copy-file' like I do - it is our commit
message convention (https://orgmode.org/worg/org-contribute.html#orgd7441de)

> -  (mapc (lambda (el) (copy-file el pub-dir t)) (org-babel-tangle-file 
> filename)))
> +  (mapc (lambda (el) (rename-file el pub-dir t))
> +(org-babel-tangle-file filename)))

I think that it would be nice to add a brief comment why `rename-file'
to the code as well.  `copy-file' looks innocent there from a first
glance.

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



Re: [PATCH] lisp/org-capture.el: use link ID's for %K

2023-12-08 Thread Ihor Radchenko
Kenny Ballou  writes:

> I'm currently struggling through modifying it to work with
> `org-store-link'.  Something, save-excursion -> org-clock-goto ->
> org-store-link -> org-insert-link is what I'm trying for now, but that's
> not quite working.  I'll come back to this in a few hours.

The last step is unnecessary. You may just examine `org-stored-links'
(documented in the docstring of `org-store-link') or
`org-store-link-plist' (undocumented, but containing more info and also
used by `org-capture-fill-template').

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



Re: Tags right alignment with font-lock

2023-12-08 Thread Nicolas P. Rougier (inria)



The above code has problems when you try editing the heading 
near the
end of the title (before the :align-to space). Especially when 
the

window is narrow. Also, when `org-auto-align-tags' is nil.
Not that they cannot be solved, but it is not just as trivial as 
the

above code.


Thanks, I noticed the problem and alleviated it by having two 
spaces at end of the title (and set org-tags-column to nil) but I 
see why it's not really usable


Nicolas

--
Nicolas P. Rougier —— www.labri.fr/perso/nrougier
Institute of Neurodegenerative Diseases, Bordeaux



Re: How to use mpirun with C or C++ Org-babel?

2023-12-08 Thread Leo Butler
On Fri, Dec 08 2023, tbanelwebmin  wrote:

> Caution: This message was sent from outside the University of Manitoba.
>
> On 23-12-08 00:10, Edgar Lux wrote:
>
> Hello, I found [1][2] that it is possible to change the compiler for C 
> and C++
> source blocks. I would like to know if there is a way to add =mpirun -np 
> 2=
> (where 2 can be any other number) to run the resulting executable. 
> Thanks! [1] 
> https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-C.html [2] 
> https://github.com/gheber/literate-hdf5
>
> I guess you want to run the executable after it has been compiled, with a 
> command
> like this one:
>
> mpirun -np 2 /tmp/babel-ad2pdk/C-bin-JTvjS4
>
> Currently it is not possible.
>
> There is the :cmdline specifier which adds parameters to the executable, like 
> this:
>
> #+begin_src C++ :cmdline AAA BBB CCC
> int main (int nargs, char** argv)
> {
>// argv will be {
>//   "/tmp/babel-ad2pdk/C-bin-JTvjS4",
>//   "AAA",
>//   "BBB",
>//   "CCC"
>// }
> }
> #+end_src
>
> Those parameters come AFTER the executable, whereas mpirun should come BEFORE 
> the
> executable.
>
> An extension may be written in ob-C.el, in the org-babel-C-execute function.
> The relevant line is:
>   (concat tmp-bin-file cmdline)
>
> If you want to contribute...

If you are wanting to run jobs with mpirun, then I will guess that they
are relatively long-running. However, ob-C.el does not support
asynchronous (background) execution, so your emacs would be tied up for
the duration. I doubt you want that.

I submitted an imperfect patch some time ago [1] that targeted your use
case: allow ob-C.el to create a named binary. Unfortunately, Ihor
dropped the issue due to lack of interest from other users.

My goal was to enable something like this to work:

#+begin_src cpp :includes  :results none :file ./hello-world
std::cout << "Hello World!\n";
#+end_src

#+begin_src bash :async t
mpirun -np 4 ./hello-world
#+end_src

As I said, the patch I wrote was not perfect, but I am happy to re-visit
the issue. The ability to create named binaries would significantly
increase the usability of ob-C for projects where you want to compile
the source once and run the binary repeatedly for potentially long
periods of time.

Leo

[1] https://list.orgmode.org/87fs81egk5@t14.reltub.ca/


Re: Bug with "BEAMER_OPT: shrink" and links

2023-12-08 Thread Ihor Radchenko
Guillaume MULLER  writes:

> Unfortunately, thanks to your follow up I just realized this issue was 
> closed, so I opened a brand new one:
> https://github.com/josephwright/beamer/issues/863

That's a wontfix on beamer side.
And I see no sane way to work around the problem on Org side (we do not
have any special support for shrink option).

Canceled.

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



Re: Tags right alignment with font-lock

2023-12-08 Thread Ihor Radchenko
"Nicolas P. Rougier (inria)"  writes:

> I'm using font lock to have tags right aligned with the following 
> code:
>
> ;; Right alignment (char wise)
> (add-to-list 'font-lock-extra-managed-props 'display)
> (font-lock-add-keywords 'org-mode
>   `(("^\\*+.*?\\( \\)\\(:[[:alnum:]_@#%:]+:\\)$"
>  (1 `(face nil
>display (space :align-to (- right 3
>,(org-string-width 
>(match-string 2)
> prepend))) t)
> ...
> I've not tested it thoroughly but it seems to be working 
> reasonably well on my machine. It is pretty similar to the code 
> posted by Ihor Radchenko (thread on "variable-pitch-mode misaligns 
> org-mode heading tags") and I wonder if there are any drawback 
> with such techniques (too slow? does not work on all situations?)

The above code has problems when you try editing the heading near the
end of the title (before the :align-to space). Especially when the
window is narrow. Also, when `org-auto-align-tags' is nil.

Not that they cannot be solved, but it is not just as trivial as the
above code.

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



Re: [orgweb/zh-CN] [DRAFT PATCH v7] Tentative zh-CN translation

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

 Double-dash only renders as a short dash on HTML, whereas quintuple-dash
 yields a long dash.  This is more in the spirit of Chinese writing,
 because we usually use two full-width dashes as a "dash punctuation".
>>>
>>> Maybe just use \mdash entity then?
>>
>> Sure, I find double-\mdash looks good on HTML as well.

Applied, onto master.
I addressed the zh_CN -> zh-CN typo and replaced the - with
\mdash\mdash.

I've left all the other discussed points unaddressed. They should not be
critical or require a native-speaker input.

P.S. Ruijie Yu's email appears to be no longer operational. I am trying
another email from debbugs. Hopefully it is not a different person with
the same name :)

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



Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]

2023-12-08 Thread TAKAHASHI Yoshio
Ihor Radchenko  writes:

> I followed your steps using the latest main.
> The results are identical for me.

Thank you for test.

My current environment is [1], org-mode in emacs master branch.  With
the latest org-mode main branch as of today, I get identical results,
too.

I'm happy to know the problem does not exist in org-mode main branch,
and will wait for merging them into emacs master branch.

Thank you for your time!


[1]
Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, 
cairo version 1.16.0)
 of 2023-11-19
Package: Org mode version 9.6.11 (release_9.6.11 @ 
/opt/emacs/share/emacs/30.0.50/lisp/org/)

-- 
TAKAHASHI Yoshio 



Re: [PATCH] lisp/org-capture.el: use link ID's for %K

2023-12-08 Thread Ihor Radchenko
Kenny Ballou  writes:

> * org-capture.el (org-capture-fill-template): fill %K values using org
> ID's if `org-id-link-to-org-use-id' is non-nil.
> * doc/ORG-NEWS: (Template variable expansion %K) Document new behavior.

Thanks for the patch!

> +  (if org-id-link-to-org-use-id
> +  (org-link-make-string
> +   (format "id:%s" (org-id-get org-clock-marker))
> +   v-k)

`org-id-link-to-org-use-id' may have a number of non-nil values with
slightly different behaviour: t, create-if-interactive,
create-if-interactive-and-no-custom-id, use-existing, nil.

Your patch will only work as expected for t and nil values, but not for
others. You may consider leveraging `org-store-link' to account for all
the possibilities.

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



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

2023-12-08 Thread Ihor Radchenko
Liu Hui  writes:

>> What about displaying a yes/no query about starting a new session when
>> there is none?
>
> I think it is OK. I can add an option to allow users to disable the
> query. WDYT?

I now have second thoughts about obsoleting
org-babel--associate-session.
If we need a customization for the new session dialogue, I expect that
users will be willing to set it for all src blocks that support such a
feature, not just python. But then we somehow need to make this global
customization visible to babel backend authors - something we normally
do using the set of org-babel-...: functions.

What I am thinking now is
1. Introduce a global customization for users to choose whether to
   start a new session in org-src buffers with allowed values t, nil,
   'ask, or an alist of (lang . t/nil/ask) for per-language customization.
2. Check the new variable and attempt to run
   `org-babel--associate-session' in org-src-mode definition.

WDYT?

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



Re: [BUG] org-babel-load-file, org-babel-tangle-use-relative-file-links and :tangle header [9.6.11 (release_9.6.11 @ /opt/emacs/share/emacs/30.0.50/lisp/org/)]

2023-12-08 Thread Ihor Radchenko
TAKAHASHI Yoshio  writes:

> TAKAHASHI Yoshio  writes:
>
>>> This is because the default value of `org-babel-default-header-args'
>>> already contains (:tangle . "no").
>> Your explanation is very clear.  Thank you.
>
> I did some tests.  Please check below transcript.  I expect to have the
> same results in bloth case.

I followed your steps using the latest main.
The results are identical for me.

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



Re: How to use mpirun with C or C++ Org-babel?

2023-12-08 Thread tbanelwebmin

  
  
On 23-12-08 00:10, Edgar Lux wrote:

Hello, I found [1][2] that it is possible to
change the compiler for C and C++ source blocks. I would like to
know if there is a way to add =mpirun -np 2= (where 2 can be any
other number) to run the resulting executable. Thanks!
[1]
https://orgmode.org/worg//org-contrib/babel/languages/ob-doc-C.html
[2] https://github.com/gheber/literate-hdf5
  

  I guess you want to run the executable after it has been compiled,
  with a command like this one:
  
  mpirun -np 2 /tmp/babel-ad2pdk/C-bin-JTvjS4
  
  Currently it is not possible.

There is the :cmdline specifier which adds
  parameters to the executable, like this:

#+begin_src C++ :cmdline AAA BBB CCC
int main (int nargs, char** argv)
{
   // argv will be {
   //   "/tmp/babel-ad2pdk/C-bin-JTvjS4",
   //   "AAA",
   //   "BBB",
   //   "CCC"
   // }
}
#+end_src

Those parameters come AFTER the executable,
  whereas mpirun should come BEFORE the executable.

An extension may be written in ob-C.el, in
  the org-babel-C-execute function.
The relevant line is:
  (concat tmp-bin-file cmdline)

  If you want to contribute...

  




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

2023-12-08 Thread Liu Hui
Ihor Radchenko  于2023年12月7日周四 23:16写道:
>
> Liu Hui  writes:
>
> > Ihor Radchenko  于2023年12月7日周四 18:33写道:
> >
> >> > +(defun org-babel-edit-prep:python (info)
> >> > +  "Set Python shell in Org edit buffer according to INFO."
> >> > +  (let ((session (cdr (assq :session (nth 2 info)
> >> > +(when (and session (not (string= session "none")))
> >> > +  (setq-local python-shell-buffer-name
> >> > +  (org-babel-python-without-earmuffs session)
> >>
> >> Will this work if Python session does not exist yet?
> >
> > If the specified session does not exist, users have to start the
> > session manually if they want to evaluate code directly in the edit
> > buffer. In fact, python-shell-send-* commands will clearly suggest
> > users using 'run-python' or C-c C-p to create the session in this
> > case.
>
> I am afraid that manually starting a python session with `run-python'
> will be misleading. Look at how much
> `org-babel-python-initiate-session-by-key' does. If users instead start
> the session with `run-python' they may get inconsistent results

ob-python has good support for using the existing session that created
by 'run-python', which contributes to a large part of
org-babel-python-initiate-session-by-key. It is common for users to
start a ob-python session with `run-python', even in the edit buffer.

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.

> > Another choice is to use '(org-babel-python-initiate-session session)'
> > in org-babel-edit-prep:python, like ob-R, to create the session when
> > the specified session does not exist, but I feel it is invasive as
> > users may just want to edit the code.
>
> What about displaying a yes/no query about starting a new session when
> there is none?

I think it is OK. I can add an option to allow users to disable the
query. WDYT?