[PATCH] org-macs: Fix incorrect use of relative paths in org-compile-file

2023-08-04 Thread Roshan Shariff
* org-macs.el (org-compile-file, org-compile-file-commands): Avoid
converting the source path to be relative to the default-directory,
which breaks for absolute source paths when the current directory is a
symlink.

Commit 5a8a1d4ff [1] changed org-compile-file to use
`file-relative-name` for the source argument. This was intended to fix
bug [2] by expanding ~ directories in the source path, like a shell.

Unfortunately, this forced use of relative paths breaks when
default-directory is a symlink, and the source to be compiled has an
absolute path.

For example, on macOS Ventura, ~/Dropbox is a symlink to
~/Library/CloudStorage/Dropbox. Suppose `default-directory` is
/Users/username/Dropbox and you try to compile /var/tmp/test.org. Its
relative path is ../../../var/tmp/test.org. But the working directory
of a compilation process is actually ~/Library/CloudStorage/Dropbox,
relative to which the source path resolves to
"/Users/username/var/tmp/test.org". The process thus cannot find the
source file.

This commit changes `org-compile-file` and its helper function
`org-compile-file-commands` to avoid the use of relative
paths. Instead, to address bug [2], `expand-file-name` is used (only
on absolute paths) for ~ expansion. Otherwise, the source path is
passed unchanged to the compilation command. The `file-truename` of
the source directory is used to construct absolute source and output
paths if needed by the command.

[1] https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5a8a1d4ff
[2] https://orgmode.org/list/25528.42190.53674.62...@gargle.gargle.howl
---
 lisp/org-macs.el | 39 +++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index e102f01c3..5d8f65193 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1606,16 +1606,20 @@ filename.  Otherwise, it raises an error.
 When PROCESS is a list of commands, optional argument LOG-BUF can
 be set to a buffer or a buffer name.  `shell-command' then uses
 it for output."
+  (when (file-name-absolute-p source)
+;; Expand "~" and "~user" .  Shell expansion will be disabled
+;; in the shell command call.
+(setq source (expand-file-name source)))
   (let* ((commands (org-compile-file-commands source process ext spec err-msg))
- (output (expand-file-name (concat (file-name-base source) "." ext)
-   (file-name-directory source)))
+ (output (file-name-concat (file-name-directory source)
+   (concat (file-name-base source) "." ext)))
  (log-buf (and log-buf (get-buffer-create log-buf)))
  (time (file-attribute-modification-time (file-attributes output
 (save-window-excursion
   (dolist (command commands)
 (cond
  ((functionp command)
-  (funcall command (shell-quote-argument (file-relative-name source
+  (funcall command (shell-quote-argument source)))
  ((stringp command) (shell-command command log-buf)
 ;; Check for process failure.  Output file is expected to be
 ;; located in the same directory as SOURCE.
@@ -1658,22 +1662,33 @@ argument SPEC, as an alist following the pattern
 
 Throw an error if PROCESS does not satisfy the described patterns.
 The error string will be appended with ERR-MSG, when it is a string."
+  (when (file-name-absolute-p source)
+;; Expand "~" and "~user" .  Shell expansion will be disabled
+;; in the shell command call.
+(setq source (expand-file-name source)))
   (let* ((base-name (file-name-base source))
-(full-name (file-truename source))
- (relative-name (file-relative-name source))
-(out-dir (if (file-name-directory source)
-  ;; Expand "~".  Shell expansion will be disabled
-  ;; in the shell command call.
-  (file-name-directory full-name)
-"./"))
-(output (expand-file-name (concat (file-name-base source) "." ext) 
out-dir))
+(out-dir (file-name-directory source))
+ ;; Don't use (expand-file-name SOURCE) for the absolute path,
+ ;; in case SOURCE starts with ../ and default-directory is a
+ ;; symlink.  Instead, resolve symlinks in the directory
+ ;; component of SOURCE...
+ (true-out-dir (file-truename out-dir))
+ ;; but use the original file name component of SOURCE in case
+ ;; it is a symlink; we want %f and %F to have the same file
+ ;; name component:
+(full-name (file-name-concat true-out-dir
+  (file-name-nondirectory source)))
+ ;; The absolute path OUTPUT is the same as FULL-NAME, except
+ ;; with extension EXT:
+(output (file-name-concat true-out-dir
+   (concat base-name "." ext)))
 (err-msg (if (stringp err-msg) (concat ".  " err-msg) "")))
 (pc

Re: [accessibility] worg obscures text (Re: [PATCH] ob-sqlite: Use a transient in-memory database by default)

2023-08-04 Thread Samuel Wales
[i.e. agree that the manuals and standard toc at top imo do a good job
for accessibility.]

On 8/4/23, Samuel Wales  wrote:
> fwiw i agree with the non-fancy toc concept for accessibility.
>
> On 8/4/23, Max Nikulin  wrote:
>> On 05/08/2023 05:57, Rudolf Adamkovič wrote:
>>> P.S. #2: The Table of Contents (TOC) on the
>>> WORG is "jumpy" on Safari.  In fact, it has
>>> always been problematic for me, in one way or
>>> another.  Why cannot TOC be included at the
>>> beginning of the document, like in standard
>>> Org exports?  Org and Emacs manuals, with no
>>> "smart" side bars, get it right, IMO.
>>
>> I have found your message in a dedicated thread
>>
>> Rudolf Adamkovič to emacs-orgmode… Re: [accessibility] worg obscures
>> text. Sun, 12 Jun 2022 21:35:14 +0200.
>> https://list.org.mode.org/m2v8t5y8st@me.com
>>
>> Somebody should propose a CSS for responsive design for Worg. Perhaps
>> with ability to open/close table of contents on mobile devices.
>>
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: [accessibility] worg obscures text (Re: [PATCH] ob-sqlite: Use a transient in-memory database by default)

2023-08-04 Thread Samuel Wales
fwiw i agree with the non-fancy toc concept for accessibility.

On 8/4/23, Max Nikulin  wrote:
> On 05/08/2023 05:57, Rudolf Adamkovič wrote:
>> P.S. #2: The Table of Contents (TOC) on the
>> WORG is "jumpy" on Safari.  In fact, it has
>> always been problematic for me, in one way or
>> another.  Why cannot TOC be included at the
>> beginning of the document, like in standard
>> Org exports?  Org and Emacs manuals, with no
>> "smart" side bars, get it right, IMO.
>
> I have found your message in a dedicated thread
>
> Rudolf Adamkovič to emacs-orgmode… Re: [accessibility] worg obscures
> text. Sun, 12 Jun 2022 21:35:14 +0200.
> https://list.org.mode.org/m2v8t5y8st@me.com
>
> Somebody should propose a CSS for responsive design for Worg. Perhaps
> with ability to open/close table of contents on mobile devices.
>
>


-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



[accessibility] worg obscures text (Re: [PATCH] ob-sqlite: Use a transient in-memory database by default)

2023-08-04 Thread Max Nikulin

On 05/08/2023 05:57, Rudolf Adamkovič wrote:

P.S. #2: The Table of Contents (TOC) on the
WORG is "jumpy" on Safari.  In fact, it has
always been problematic for me, in one way or
another.  Why cannot TOC be included at the
beginning of the document, like in standard
Org exports?  Org and Emacs manuals, with no
"smart" side bars, get it right, IMO.


I have found your message in a dedicated thread

Rudolf Adamkovič to emacs-orgmode… Re: [accessibility] worg obscures 
text. Sun, 12 Jun 2022 21:35:14 +0200. 
https://list.org.mode.org/m2v8t5y8st@me.com


Somebody should propose a CSS for responsive design for Worg. Perhaps 
with ability to open/close table of contents on mobile devices.




Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-08-04 Thread Max Nikulin

On 05/08/2023 05:57, Rudolf Adamkovič wrote:

+*** Make ~ob-sqlite~ use in-database by default


"use in-memory database"


+
+SQLite source blocks with no ~:db~ argument now execute against a
+transient in-memory database by default.


I am unsure, but perhaps it would be more clear to say that the default 
value of the header argument has changed and it is possible to omit 
setting :db per-block or as a header argument. It should give a hint how 
to revert this change in local configuration if somebody wish it.



 This makes Org match the
+default behavior of the ~sqlite3~ shell and makes SQLite blocks more
+practical out of the box.
+


Feel free to just ignore the following. Perhaps to get *really* default 
behavior ob-sqlite should not check :db value and should not pass it to 
the command in the case of nil. As a result the command spits a warning.


Earlier I was thinking on buffer-local variables whether the warning has 
been shown to the user (to do it once), but I think it would lead to 
unreasonable complication of code with a little value for users.




Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-08-04 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> However, I think that it will provide more freedom to users if you alter
> org-babel-default-header-args:sqlite instead of hard-coding the default.
> May you update the patch accordingly?

Please see the attached patch.

> Also, can you update the docs at
> https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sqlite.html
> ? The current docs declare :db header arg as mandatory.

Ditto, please see the second attached patch.

P.S. #1: This is my first contribution to the
WORG, and I am not sure if the patch is OK.
I do ever not plan to contribute to the WORG,
as I am not a fan of the idea and think that
all built-in backends (and more!) should be
documented in the Org manual.

P.S. #2: The Table of Contents (TOC) on the
WORG is "jumpy" on Safari.  In fact, it has
always been problematic for me, in one way or
another.  Why cannot TOC be included at the
beginning of the document, like in standard
Org exports?  Org and Emacs manuals, with no
"smart" side bars, get it right, IMO.

Rudy

>From aac17ad21bf5fe85a57efd4183b80fdc5221d3aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Wed, 3 May 2023 14:59:03 +0200
Subject: [PATCH] ob-sqlite: Use a transient in-memory database by default

* etc/ORG-NEWS (New features): Add a news entry.
* lisp/ob-sqlite.el (org-babel-default-header-args:sqlite): Default
':db' to ":memory:".
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-file): Test the old behavior.
* testing/lisp/test-ob-sqlite.el (ob-sqlite/in-memory): Test the new behavior.
---
 etc/ORG-NEWS   |  7 +++
 lisp/ob-sqlite.el  |  2 +-
 testing/lisp/test-ob-sqlite.el | 36 --
 3 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 4f16eda24..40a4e79bd 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -489,6 +489,13 @@ Final hooks are added to the following commands:
 
 The prefix arguments are passed to ~org-insert-todo-heading~.
 
+*** Make ~ob-sqlite~ use in-database by default
+
+SQLite source blocks with no ~:db~ argument now execute against a
+transient in-memory database by default.  This makes Org match the
+default behavior of the ~sqlite3~ shell and makes SQLite blocks more
+practical out of the box.
+
 *** Add support for ~logind~ idle time in ~org-user-idle-seconds~
 
 When Emacs is built with =dbus= support and
diff --git a/lisp/ob-sqlite.el b/lisp/ob-sqlite.el
index 526b73ebd..75ef50913 100644
--- a/lisp/ob-sqlite.el
+++ b/lisp/ob-sqlite.el
@@ -39,7 +39,7 @@
 (declare-function orgtbl-to-csv "org-table" (table params))
 (declare-function org-table-to-lisp "org-table" (&optional txt))
 
-(defvar org-babel-default-header-args:sqlite '())
+(defvar org-babel-default-header-args:sqlite '((:db . ":memory:")))
 
 (defvar org-babel-header-args:sqlite
   '((db. :any)
diff --git a/testing/lisp/test-ob-sqlite.el b/testing/lisp/test-ob-sqlite.el
index 72d75c9b7..621a11b0b 100644
--- a/testing/lisp/test-ob-sqlite.el
+++ b/testing/lisp/test-ob-sqlite.el
@@ -39,8 +39,40 @@
   .import $tb TestTable
   select * from TestTable;
 #+end_src"
-	(org-babel-next-src-block)
-	(org-babel-execute-src-block)
+	   (org-babel-next-src-block)
+	   (org-babel-execute-src-block)
+
+(ert-deftest ob-sqlite/in-memory ()
+  "Test in-memory temporariness."
+  (should
+   (equal 0
+  (progn
+(org-test-with-temp-text
+	 "#+BEGIN_SRC sqlite
+PRAGMA user_version = 1;
+#+END_SRC"
+	 (org-babel-execute-src-block))
+(org-test-with-temp-text
+	 "#+BEGIN_SRC sqlite
+PRAGMA user_version;
+#+END_SRC"
+	 (org-babel-execute-src-block))
+
+(ert-deftest ob-sqlite/in-file ()
+  "Test in-file permanency."
+  (should
+   (equal 1
+  (let ((file (org-babel-temp-file "test" ".sqlite")))
+(org-test-with-temp-text
+	 (format "#+BEGIN_SRC sqlite :db %s
+PRAGMA user_version = 1;
+#+END_SRC" file)
+	 (org-babel-execute-src-block))
+(org-test-with-temp-text
+	 (format "#+BEGIN_SRC sqlite :db %s
+PRAGMA user_version;
+#+END_SRC" file)
+	 (org-babel-execute-src-block))
 
 (provide 'test-ob-sqlite)
 ;;; test-ob-sqlite.el ends here
-- 
2.37.1 (Apple Git-137.1)

>From 2d756f51299131727a978da3bbdfbaaa3c67d36d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Sat, 5 Aug 2023 00:36:07 +0200
Subject: [PATCH] Document the new default value of the Babel/SQLite ':db'
 argument

---
 org-contrib/babel/languages/ob-doc-sqlite.org | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/org-contrib/babel/languages/ob-doc-sqlite.org b/org-contrib/babel/languages/ob-doc-sqlite.org
index d7febb0c..981eca34 100644
--- a/org-contrib/babel/languages/ob-doc-sqlite.org
+++ b/org-contrib/babel/languages/ob-doc-sqlite.org
@@ -91,7 +91,8 @@ There are no language-specific default header arguments for SQLite.
 There are 11 SQLite-specific header arguments.
 
  - db :: a stri

Re: How to put a string produced by an Elisp form in an Org source block in the Org file?

2023-08-04 Thread Marcin Borkowski


On 2023-08-04, at 10:03, Ihor Radchenko  wrote:

> Marcin Borkowski  writes:
>
>> I have an Elisp form in an Org source block, returning a (multi-line)
>> string.  I'd like to put that string into the same Org buffer.  I tried
>> `:results raw', but the string contains `|' characters, so Org treats
>> its as a table and tries to format it as such, which is not what I want.
>>
>> How to do that?
>
> Maybe :wrap example?

Thanks a lot, that works!  (Apart from the issue with lines beginning
with a star, possibly preceded by whitespace, which are "escaped" with
a comma - but that is a known thing in Org, and I can easily circumvent
it.)

BTW, that means that my blog post for this weekend (about plotting
charts from Org tables, all within Org mode and using ASCII art) is
basically almost ready!

Best,

-- 
Marcin Borkowski
http://mbork.pl



Re: [ANN] lisp/ob-tangle-sync.el

2023-08-04 Thread Mehmet Tekman
Ignore the patches in that last email, (but please do address some of
the concerns I had about the number of `:any` outputs).

Anyway, I finally did it - I got it to work. Every single patch now
pasts tests.

Please review these patches and *not the patches in the last email*.
(Apologies for the frequency of my emails today)

Best,
Mehmet
From 020992b46b5a7c2ae18c677afb5c29c00de58059 Mon Sep 17 00:00:00 2001
From: Mehmet Tekman 
Date: Tue, 1 Aug 2023 05:14:46 +0200
Subject: [PATCH 1/3] * testing/lisp/test-ob.el: New tests for merge-params

(test-ob/get-src-block-property):
(test-ob/merge-params): add new tests for the merge-params source
block header handling function.
(test-ob/merge-params-tangle): add new tests for tangle specific
headers.
---
 testing/lisp/test-ob.el | 146 
 1 file changed, 146 insertions(+)

diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index c8dbd44f4..460afbf9b 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -314,6 +314,152 @@ this is simple"
 (org-babel-next-src-block)
 (should (= 14 (org-babel-execute-src-block)
 
+(defun test-ob/get-src-block-property (properties)
+  "Get plist of PROPERTIES and values for the first src block in buffer.
+PROPERTIES is a list of property keywords or a single keyword."
+  (org-with-wide-buffer
+   (goto-char (point-min))
+   (org-babel-next-src-block)
+   (org-set-regexps-and-options)
+   (let ((all-props (nth 2 (org-babel-get-src-block-info
+ (if (listp properties)
+ (apply #'nconc (mapcar (lambda (p) (list p (cdr (assoc p all-props properties))
+   (list properties (cdr (assoc properties all-props)))
+
+(ert-deftest test-ob/merge-params()
+  "Test the output of merging multiple header parameters."
+  (should
+   (equal '(:file-mode "#o755")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :file-mode #o755
+* One
+#+begin_src conf
+#+end_src"
+(test-ob/get-src-block-property :file-mode
+  (should
+   (equal '(:file-mode "anything" :exports "both")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :file-mode #o755 :exports both
+* One
+#+begin_src conf :file-mode anything
+#+end_src"
+(test-ob/get-src-block-property '(:file-mode :exports)
+  (should
+   (equal '(:mkdirp "no" :dir nil :padline "yes")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :dir /tmp/ :padline no
+* One
+:PROPERTIES:
+:header-args: :mkdirp no
+:END:
+#+begin_src conf :padline yes
+#+end_src"
+(test-ob/get-src-block-property '(:mkdirp :dir :padline)
+  (should
+   (equal '(:results "value code replace file" :file "file")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :results file :file file
+* One
+#+begin_src conf :results code value
+#+end_src"
+(test-ob/get-src-block-property '(:results :file)
+  (should
+   (equal '(:results "value html silent")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :results file
+* One
+:PROPERTIES:
+:header-args: :results html silent
+:END:
+#+begin_src conf :results value
+#+end_src"
+(test-ob/get-src-block-property :results)
+
+(ert-deftest test-ob/merge-params-tangle()
+  "Test the output of merging multiple header parameters."
+  (should
+   (equal '(:tangle "/tmp/default_tangle.txt")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should ;; 2. inherit-document-header-with-local-sync-action
+   (equal '(:tangle "skip")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* Two
+#+begin_src conf :tangle skip
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should
+   (equal '(:tangle "randomfile")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* Three
+#+begin_src conf :tangle randomfile
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should
+   (equal '(:tangle "newfile.txt")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* Four
+:PROPERTIES:
+:header-args: :tangle \"newfile.txt\"
+:END:
+** A
+#+begin_src conf
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should
+   (equal '(:tangle "./headfile.txt")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle ./headfile.txt
+* Five
+:PROPERTIES:
+:header-args: :tangle ./headfile.txt
+:END:
+** A
+#+begin_src conf
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should
+   (equal '(:tangle "yes")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :ta

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

2023-08-04 Thread William Denton

On 4 August 2023, Michael Dauer wrote:


I'm on main (Org mode version 9.7-pre (release_9.6.7-594-gf03b83), and it's
not fixed. Am I missing something?


The fix did fix it for me, and the problem went away.  It did seem to introduce 
a new problem with searching in a buffer with Swiper, where the search would 
fail or throw an error or require me to collapse headings before it would work, 
but that hasn't happened in a while and I didn't try to debug it.



Bill

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

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

2023-08-04 Thread Ihor Radchenko
Michael Dauer  writes:

> I'm on main (Org mode version 9.7-pre (release_9.6.7-594-gf03b83), and it's
> not fixed. Am I missing something?

If I try to follow the recipe described in
https://list.orgmode.org/orgmode/CAP7OBx+L11ck3Ni6rv94HGU3otdj6C4rG-rMDzkwR1LTj=b...@mail.gmail.com/
using the latest main, I cannot reproduce the problem.

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



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

2023-08-04 Thread Michael Dauer
I'm on main (Org mode version 9.7-pre (release_9.6.7-594-gf03b83), and it's
not fixed. Am I missing something?

Am Do., 1. Juni 2023 um 13:33 Uhr schrieb Ihor Radchenko <
yanta...@posteo.net>:

> Michael Dauer  writes:
>
> > I think I found a way to consistently reproduce the issue:
> > ...
>
> Thanks!
> I now came up with another, more reliable, workaround.
> Since `query-replace', evil, and swiper all arrange the call of
> `isearch-clean-overlays', I can advice it to make sure that we clean
> everything at the end.
>
> Fixed, hopefully, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7dee2c07f
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: [ANN] lisp/ob-tangle-sync.el

2023-08-04 Thread Mehmet Tekman
Ihor Radchenko  writes:

>
> Side note: I had one newly added test failing on the latest main. You
> may need to rebase your branch and check if tests are still passing.
>

The rebase was fine, but I'm having a problem aligning my patch branch
to work without any tangle involvement.

The first hurdle is that I'm a little bit unsure about the validity of one of
 the tests.

* Under vanilla `org-babel-merge-params', any number of :tangle header
  values are permitted and concatenated together.

  e.g 4:
  __
  ´
(should  ;; 4.
override-document-and-parent-header-with-local-tfile-and-action
 (equal '(:tangle "randomfile sync")
(org-test-with-temp-text
"\
  #+PROPERTY: header-args :tangle /tmp/default_tangle.txt
  * Four
  :PROPERTIES:
  :header-args: :tangle \"newfile.txt\" import
  :END:
  ** A
  #+begin_src conf :tangle randomfile sync
  #+end_src"
  (test-ob/get-src-block-property :tangle
  `---

  This result of "randomfile sync" for the :tangle header is seen as
  valid but it shouldn't, should it? Tangle can only take one value,
  so the action of `:any` should also just output one value?

  From the docstring text:

  > Symbol `:any' in the value list implies that any value is allowed.

  It's not clear to me if this means that `:any' or `:any :any` or
  `":any :any"` is permitted.

  In my rewrite, I very much take the `:any` or `":any :any"` single
  value interpretation when merging the headers together.

* Sometimes the value of another header is caught in the value of
  another

  e.g 8: "wrap" is caught in the output of `:results' despite it not being
 a valid results keyword in `org-babel-common-header-args-w-values'.

   __
  ´
(should  ;; 8. test-results-and-exports
 (equal '(:results "wrap file replace" :exports "code")
(org-test-with-temp-text
"\
  * Eight
  #+begin_src sh :results file wrap
  #+end_src"
  (test-ob/get-src-block-property '(:results :exports)
(should  ;; 9. do-not-tangle-this-block --
  `---

  This test results in "true" for both my rewrite, and the vanilla
  function, but I'm not sure how accurate or value this is.


I've been reordering and splitting commits for a while now, but I think
it's really not easy to seperate the new tangle-sync component from my
merge-params rewrite.

I've attached my patches, including fixes from the last review you gave
- I hope you can make more sense of this than I can.

Best,
Mehmet
From bcbd184d7b7effa6cda1f6c3680a1e4a28b8be30 Mon Sep 17 00:00:00 2001
From: Mehmet Tekman 
Date: Tue, 1 Aug 2023 05:14:46 +0200
Subject: [PATCH 1/4] * testing/lisp/test-ob.el: New tests for merge-params

(test-ob/get-src-block-property):
(test-ob/merge-params): add new tests for the merge-params source
block header handling function.
---
 testing/lisp/test-ob.el | 138 
 1 file changed, 138 insertions(+)

diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index c8dbd44f4..f12533258 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -314,6 +314,144 @@ this is simple"
 (org-babel-next-src-block)
 (should (= 14 (org-babel-execute-src-block)
 
+(defun test-ob/get-src-block-property (properties)
+  "Get plist of PROPERTIES and values for the first src block in buffer.
+PROPERTIES is a list of property keywords or a single keyword."
+  (org-with-wide-buffer
+   (goto-char (point-min))
+   (org-babel-next-src-block)
+   (org-set-regexps-and-options)
+   (let ((all-props (nth 2 (org-babel-get-src-block-info
+ (if (listp properties)
+ (apply #'nconc (mapcar (lambda (p) (list p (cdr (assoc p all-props properties))
+   (list properties (cdr (assoc properties all-props)))
+
+(ert-deftest test-ob/merge-params ()
+  "Test the output of merging multiple header parameters."
+  (should ;; 1. inherit-document-header-args
+   (equal '(:tangle "/tmp/default_tangle.txt")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should-not ;; 2. inherit-document-header-with-local-sync-action
+   ;; This should pass with newer merge function with multiple tangle parameters
+   (equal '(:tangle "/tmp/default_tangle.txt skip")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* Two
+#+begin_src conf :tangle skip
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should ;; 3. override-document-header-with-local-tfile
+   (equal '(:tangle "randomfile sync")
+  (org-test-with-temp-text
+  "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* Three
+#+begin_src conf :tangle randomfile sync
+#+end_src"
+(test-ob/get-src-block-property :tangle
+  (should  ;; 4

Re: [patch] Fix inner smart quotes in French

2023-08-04 Thread Bastien
Hi Juan,

Juan Manuel Macías  writes:

> In the meantime, I'm submitting this patch with a fix for second-level
> French `smart quotes': the correct quotes should be “” (without spaces,
> as in Spanish or Greek) (please, some francophone correct me, if I'm
> wrong...).

Applied, thanks!

-- 
 Bastien



Re: Worg: issue with org-tools page

2023-08-04 Thread Bastien Guerry
Ihor Radchenko  writes:

> I am attaching tentative patch that will revert demoting errors to
> messages. However, I do not fully understand the purpose of the original
> `condition-case' code in the publish.sh. Bastien?

Applied.  I'm aware it only fixes part of the issue at hand, but I
believe this is already better.

Thanks,

-- 
 Bastien



Re: [PATCH v3.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-04 Thread Ihor Radchenko
"Christopher M. Miles"  writes:

>> I think that instead of changing the existing function, we can convert
>> your patch into a new function `org-toggle-inline-images-command' that
>> will be free to alter the argument order. We can then re-bind that
>> function in org-keys to make it used by default, but only interactively.
>>
> I don't think so, the patch main purpose is for improve image refreshing
> after babel result image displaying. Because the function is hooked by
> other ob-* packages. Another purpose is headline level images displaying.
> So modifying this function is the only way.

Fair point.
Then, for backward compatibility, we may treat any non-nil, non-list
(like '(4), '(16), '(64)), non-number (like 1, 11) value as
INCLUDE-LINKED. This way, the existing calls like
(org-toggle-inline-images t) will not be broken.

Also, the signature should be

(defun org-toggle-inline-images (&optional arg beg end include-linked)

So that the meaning of the second and third argument is unchanged.

>> As for displaying linked images, what about something like
>>
>>
>> C-1 C-c C-x C-v being equivalent of
>> C-c C-x C-v + INCLUDE-LINKED=t
>> (display in current section/region, with linked)
>>
>> and
>>
>> C-11 C-c C-x C-v being equivalent of
>> C-u C-u C-c C-x C-v + INCLUDE-LINKED=t
>> (display in the whole buffer, with linked)
>>
> Don't know, I have not use it this way. I think INCLUDE-LINKED is just a
> option argument for function org-display-inline-images. No need to be
> available for toggle in interactive command. An option like
> org-inline-images-include-linked is enough.

Sorry, but ignoring backwards compatibility is not an option.
If you personally haven't used some feature, it does not mean that
others also didn't.

We can make limited compromises, but should try our best not to break
things that were working before.
See https://bzg.fr/en/the-software-maintainers-pledge/

>>> +If cursor is on an inline image link, display the inline image.
>>> +If there is none, remove it otherwise.
>>
>> I do not quite understand what the last line is trying to say.
>
> Emmm, I forget the meaning of it. I read the docstring again, seems it
> can be deleted. I will delete it in my patch.

> After yesterday night studying source code, I still can't figure out
> solution. So I pass this patch to you. Wait you to finish the unfinished
> part of path.

I hope that now you have enough information to update the patch.
Let me know if not.

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



Re: [ANN] lisp/ob-tangle-sync.el

2023-08-04 Thread Ihor Radchenko
Mehmet Tekman  writes:

> Pre-weekend update: I have a `merge-params' solution, and it's passing tests.

Side note: I had one newly added test failing on the latest main. You
may need to rebase your branch and check if tests are still passing.

> I will need to refactor/cherry pick my branch somehow to make the patch
> less "tangle sync"-centric, but I'm sure I can make it work.

FYI: Interactive rebasing with magit is a lot easier.

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



Re: [PATCH] ob-sqlite: Use a transient in-memory database by default

2023-08-04 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> As Max described, it might be a potential issue.
>
> How about (1) we merge the patch, and then
> (2) we add the lint warning if/when someone
> has the [hypothesized] problem?

Maybe. After re-thinking, your change should not break any existing Org
files, except those that were already broken because of the missing :db.

However, I think that it will provide more freedom to users if you alter
org-babel-default-header-args:sqlite instead of hard-coding the default.
May you update the patch accordingly?

Also, can you update the docs at
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-sqlite.html
? The current docs declare :db header arg as mandatory.

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



Re: How to put a string produced by an Elisp form in an Org source block in the Org file?

2023-08-04 Thread Ihor Radchenko
Marcin Borkowski  writes:

> I have an Elisp form in an Org source block, returning a (multi-line)
> string.  I'd like to put that string into the same Org buffer.  I tried
> `:results raw', but the string contains `|' characters, so Org treats
> its as a table and tries to format it as such, which is not what I want.
>
> How to do that?

Maybe :wrap example?

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



How to put a string produced by an Elisp form in an Org source block in the Org file?

2023-08-04 Thread Marcin Borkowski
Hi Orgers,

I have an Elisp form in an Org source block, returning a (multi-line)
string.  I'd like to put that string into the same Org buffer.  I tried
`:results raw', but the string contains `|' characters, so Org treats
its as a table and tries to format it as such, which is not what I want.

How to do that?

-- 
Marcin Borkowski
http://mbork.pl



Re: [BUG] Bad interaction between org-add-log-setup and org-with-remote-undo [9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]

2023-08-04 Thread Ihor Radchenko
"Aaron Zeng"  writes:

> I wonder if org-add-log-setup should be removed and refactored away,
> or if org-with-remote-undo should not be creating an undo boundary
> (which sounds redundant with the automatic ones created by the command
> loop?).

`org-add-log-setup' is indeed causing a lot of problems because of how
it is implemented. You have found yet another one.

I think that we need to rewrite logging code to use recursive editing
instead of 'post-command-hook.

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



Re: [ANN] lisp/ob-tangle-sync.el

2023-08-04 Thread Mehmet Tekman
Pre-weekend update: I have a `merge-params' solution, and it's passing tests.

I will need to refactor/cherry pick my branch somehow to make the patch
less "tangle sync"-centric, but I'm sure I can make it work.

On Thu, 3 Aug 2023 at 10:46, Mehmet Tekman  wrote:
>
> > You dropped mailing list from the CC. Was it intentional?
>
> Whoops, no. Still figuring out an email solution in emacs.
>
> > If I understand your concern correctly, you may simply let-bind
> > `org-babel-common-header-args-
> > w-values' in the tests to make sure that
> > your new parameter merging code is working.
>
> Okay, I will try this



[BUG] Bad interaction between org-add-log-setup and org-with-remote-undo [9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]

2023-08-04 Thread Aaron Zeng
Hi folks,

It seems there is a bad interaction between org-add-log-setup and
org-with-remote-undo, such that org-agenda-undo does not function
correctly.  For example,

1. Enable logging on reschedule, by setting `org-log-reschedule' to
   `time'.
2. Reschedule an already-scheduled TODO item through an agenda buffer,
   by pressing C-c C-s (org-schedule).
3. Press C-/ (org-agenda-undo) while still in the agenda buffer.

This has the unfortunate consequence of undoing all of the changes in
the agenda buffer but only a subset of the changes in the source
buffer where the task was defined (namely, the "rescheduled" log entry
is removed but the timestamp is not restored to the original time).

I believe this is because org-with-remote-undo creates an undo
boundary after executing the body of the macro, but org-add-log-setup
makes changes to the buffer in post-command-hook, after the
undo-boundary is created.  This means that /two/ undoable changes in
the source buffer now logically correspond to the same change in the
agenda buffer, which org-agenda-undo does not handle correctly.

Some commands do not have this issue, such as org-agenda-todo, which
calls org-add-log-note instead of org-add-log-setup and therefore does
not make use of post-command-hook.  This seems to be intentional:

;; Make sure that log is recorded in current undo.
(when (and org-log-setup
   (not (eq org-log-note-how 'note)))
  (org-add-log-note))

I wonder if org-add-log-setup should be removed and refactored away,
or if org-with-remote-undo should not be creating an undo boundary
(which sounds redundant with the automatic ones created by the command
loop?).

Emacs  : GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 
Version 12.6.6 (Build 21G646))
of 2023-07-30
Package: Org mode version 9.6.6 (release_9.6.6 @ 
/Applications/Emacs.app/Contents/Resources/lisp/org/ 
)



[patch] Fix inner smart quotes in French

2023-08-04 Thread Juan Manuel Macías
Hi,

These last months I have been disconnected from the list for family
reasons. Now, trying to catch up with the news on the list and pending
things that I left here :-).

In the meantime, I'm submitting this patch with a fix for second-level
French `smart quotes': the correct quotes should be “” (without spaces,
as in Spanish or Greek) (please, some francophone correct me, if I'm
wrong...).

Best regards,

Juan Manuel 

-- 
Juan Manuel Macías 

https://juanmanuelmacias.com

https://lunotipia.juanmanuelmacias.com

https://gnutas.juanmanuelmacias.com


>From 202a085ce9e0e3e7c0e67bcdde91e706050fd976 Mon Sep 17 00:00:00 2001
From: Juan Manuel Macias 
Date: Fri, 4 Aug 2023 09:04:03 +0200
Subject: [PATCH] lisp/ox.el: fix inner smart quotes in French.

* (org-export-smart-quotes-alist): the correct French second level
quotation marks are added.
---
 lisp/ox.el | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 3a6dd8ded..473bd927c 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -5840,11 +5840,8 @@ transcoding it."
  (primary-closing
   :utf-8 " »" :html " »" :latex "\\fg{}"
   :texinfo "@tie{}@guillemetright{}")
- (secondary-opening
-  :utf-8 "« " :html "« " :latex "\\og "
-  :texinfo "@guillemetleft{}@tie{}")
- (secondary-closing :utf-8 " »" :html " »" :latex "\\fg{}"
-			:texinfo "@tie{}@guillemetright{}")
+ (secondary-opening :utf-8 "“" :html "“" :latex "``" :texinfo "``")
+ (secondary-closing :utf-8 "”" :html "”" :latex "''" :texinfo "''")
  (apostrophe :utf-8 "’" :html "’"))
 ("is"
  (primary-opening
-- 
2.41.0