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

2023-12-28 Thread Joseph Turner
Hello!

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]]".

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:

https://git.sr.ht/~ushin/hyperdrive.el/tree/33d8cef0507fbbe25839a019b5c42fda862ac4de/item/hyperdrive-org.el#L137

In org-transclusion.el, org-element-context is used to parse a link, and
then org-element-link-interpreter is used to insert it into a buffer:

https://github.com/nobiot/org-transclusion/blob/b10d4de93c6c0523bd4e7e72c11ef3a9a5630370/org-transclusion.el#L372

The problem is that the "file" protocol prefix is added to links which
have no protocol prefix.  When you call org-transclusion-make-from-link
with point on "[[/foobar]]", org-transclusion.el ends up inserting this:

#+transclude: [[file:/foobar]]

which, at least with hyperdrive.el, doesn't point to the same file as

#+transclude: [[/foobar]]

All suggestions are welcome!

Thank you!!!

Joseph



Re: [PATCH] assoc-delete-all missing from 26.1

2023-12-28 Thread Ihor Radchenko
Justin  writes:

> From 48c84e876018a9f2f7c818c2b9fa179e47ac45b9 Mon Sep 17 00:00:00 2001
> From: Justin Vallon 
> Date: Thu, 28 Dec 2023 17:16:45 -0500
> Subject: [PATCH] assoc-delete-all missing from 26.1
>
> * lisp/org-compat: add org-assoc-delete-all from compat/compat-27.el
> * lisp/org-persist: use org-assoc-delete-all

Thanks for the patch, but be informed that we no longer support Emacs 26.
See https://orgmode.org/worg/org-maintenance.html#emacs-compatibility

Some newly added functionality (like DnD support) is already not
compatible with Emacs 26 and older.

I still applied your patch because it is trivial.

Applied, onto main, amending the commit message and adding TINYCHANGE
cookie (see
https://orgmode.org/worg/org-contribute.html#commit-messages)

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

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



[PATCH] assoc-delete-all missing from 26.1

2023-12-28 Thread Justin

* lisp/org-compat: add org-assoc-delete-all from compat/compat-27.el
* lisp/org-persist: use org-assoc-delete-all
---
 lisp/org-compat.el  | 18 ++
 lisp/org-persist.el |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 8b1f16355..6fcea1837 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -348,6 +348,24 @@ Execute BODY, and unwind connection-local variables."
 `(with-connection-local-profiles (connection-local-get-profiles nil)
    ,@body)))

+;; assoc-delete-all missing from 26.1
+(if (fboundp 'assoc-delete-all)
+    (defalias 'org-assoc-delete-all 'assoc-delete-all)
+  ;; from compat/compat-27.el
+  (defun org-assoc-delete-all (key alist  test)
+    "Delete all matching key from alist, default test equal"
+    (unless test (setq test #'equal))
+    (while (and (consp (car alist))
+        (funcall test (caar alist) key))
+  (setq alist (cdr alist)))
+    (let ((tail alist) tail-cdr)
+  (while (setq tail-cdr (cdr tail))
+    (if (and (consp (car tail-cdr))
+         (funcall test (caar tail-cdr) key))
+    (setcdr tail (cdr tail-cdr))
+  (setq tail tail-cdr
+    alist))
+
 
 ;;; Emacs < 26.1 compatibility

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 82c31144a..229957fb0 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -1216,7 +1216,7 @@ Remove expired sessions timestamps."
 Remove current sessions from `org-persist-gc-lock-file'."
   (let* ((file (org-file-name-concat org-persist-directory 
org-persist-gc-lock-file))
  (alist (when (file-exists-p file) 
(org-persist--read-elisp-file file

-    (setq alist (assoc-delete-all before-init-time alist))
+    (setq alist (org-assoc-delete-all before-init-time alist))
 (org-persist--write-elisp-file file alist)
 ;; Only GC orphan files when there are no active sessions.
 (not alist)))

base-commit: 80ce6152ba915b7c53d239f2b030f7afb8e70e8e
--
2.20.1

From 48c84e876018a9f2f7c818c2b9fa179e47ac45b9 Mon Sep 17 00:00:00 2001
From: Justin Vallon 
Date: Thu, 28 Dec 2023 17:16:45 -0500
Subject: [PATCH] assoc-delete-all missing from 26.1

* lisp/org-compat: add org-assoc-delete-all from compat/compat-27.el
* lisp/org-persist: use org-assoc-delete-all
---
 lisp/org-compat.el  | 18 ++
 lisp/org-persist.el |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 8b1f16355..6fcea1837 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -348,6 +348,24 @@ Execute BODY, and unwind connection-local variables."
 `(with-connection-local-profiles (connection-local-get-profiles nil)
,@body)))
 
+;; assoc-delete-all missing from 26.1
+(if (fboundp 'assoc-delete-all)
+(defalias 'org-assoc-delete-all 'assoc-delete-all)
+  ;; from compat/compat-27.el
+  (defun org-assoc-delete-all (key alist  test)
+"Delete all matching key from alist, default test equal"
+(unless test (setq test #'equal))
+(while (and (consp (car alist))
+		(funcall test (caar alist) key))
+  (setq alist (cdr alist)))
+(let ((tail alist) tail-cdr)
+  (while (setq tail-cdr (cdr tail))
+	(if (and (consp (car tail-cdr))
+		 (funcall test (caar tail-cdr) key))
+(setcdr tail (cdr tail-cdr))
+  (setq tail tail-cdr
+alist))
+
 
 ;;; Emacs < 26.1 compatibility
 
diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 82c31144a..229957fb0 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -1216,7 +1216,7 @@ Remove expired sessions timestamps."
 Remove current sessions from `org-persist-gc-lock-file'."
   (let* ((file (org-file-name-concat org-persist-directory org-persist-gc-lock-file))
  (alist (when (file-exists-p file) (org-persist--read-elisp-file file
-(setq alist (assoc-delete-all before-init-time alist))
+(setq alist (org-assoc-delete-all before-init-time alist))
 (org-persist--write-elisp-file file alist)
 ;; Only GC orphan files when there are no active sessions.
 (not alist)))

base-commit: 80ce6152ba915b7c53d239f2b030f7afb8e70e8e
-- 
2.20.1



Re: [PATCH v4] org-manual: Describe export process flow

2023-12-28 Thread Matt


  On Thu, 28 Dec 2023 13:05:27 +0100  Ihor Radchenko  wrote --- 

 > See the attached.

All looks good to me.  

--
Matt Trzcinski
Emacs Org contributor (ob-shell)
Learn more about Org mode at https://orgmode.org
Support Org development at https://liberapay.com/org-mode




Re: [BUG] - org-agenda log view does not conform to org-timestamp-formats

2023-12-28 Thread Ihor Radchenko
Tebe Nigrelli  writes:

> I understand that `org-timestamp-formats' is a constant, but since 
> almost everything I need still works I would like to fix my setup.
>
> Could you please point me to the function that parses clock lines and 
> returns the duration of the clock, as I could not find it myself in 
> org-agenda.el nor org.el?

`org-agenda-get-progress' I think. There is a hard-coded regexp.

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



[PATCH v4] org-manual: Describe export process flow

2023-12-28 Thread Ihor Radchenko
Matt  writes:

> I was making a different point.  I was trying to say that it may be a
> good idea for the ox.el commentary section to specifically reference
> the new manual section (next to where it references Worg).

Makes sense. See the attached.
I added reference to the manual in `org-export-as' docstring and made it
explicit that the manual section is related to `org-export-as' by adding
#+findex entry.

>From b17d57c1afeb160783da36647f56462ee67c3558 Mon Sep 17 00:00:00 2001
Message-ID: 
From: Ihor Radchenko 
Date: Wed, 27 Dec 2023 14:23:29 +0100
Subject: [PATCH v4 1/5] doc/org-manual.org: Fix some obsolete variable names

* doc/org-manual.org (Export hooks): Use the new
`org-export-before-processing-functions' and
`org-export-before-parsing-functions' instead of their obsolete
aliases.
---
 doc/org-manual.org | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ff1b9cffb..377706ee7 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16397,12 +16397,14 @@ *** Export hooks
 :END:
 
 #+vindex: org-export-before-processing-hook
+#+vindex: org-export-before-processing-functions
 #+vindex: org-export-before-parsing-hook
 The export process executes two hooks before the actual exporting
-begins.  The first hook, ~org-export-before-processing-hook~, runs
-before any expansions of macros, Babel code, and include keywords in
-the buffer.  The second hook, ~org-export-before-parsing-hook~, runs
-before the buffer is parsed.
+begins.  The first hook, ~org-export-before-processing-functions~,
+runs before any expansions of macros, Babel code, and include keywords
+in the buffer.  The second hook,
+~org-export-before-parsing-functions~, runs before the buffer is
+parsed.
 
 Functions added to these hooks are called with a single argument: the
 export backend actually used, as a symbol.  You may use them for
@@ -16421,7 +16423,7 @@ *** Export hooks
  ;; the docstring of `org-map-entries' for details.
  (setq org-map-continue-from (point)
 
-(add-hook 'org-export-before-parsing-hook #'my-headline-removal)
+(add-hook 'org-export-before-parsing-functions #'my-headline-removal)
 #+end_src
 
 *** Filters
-- 
2.42.0

>From b195caf687793af228a2ea9a484f2fb8cb87ddab Mon Sep 17 00:00:00 2001
Message-ID: 
In-Reply-To: 
References: 
From: Ihor Radchenko 
Date: Tue, 26 Dec 2023 15:15:23 +0100
Subject: [PATCH v4 2/5] doc/org-manual.org: Describe export flow

* doc/org-manual.org (Summary of the export process): Explain how the
export process is handled in Org mode.
---
 doc/org-manual.org | 148 +
 1 file changed, 148 insertions(+)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 377706ee7..66a582eae 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -16505,6 +16505,154 @@ *** Defining filters for individual files
 ,#+END_SRC
 #+end_example
 
+*** Summary of the export process
+:PROPERTIES:
+:UNNUMBERED: notoc
+:END:
+
+Org mode export is a multi-step process that works on a temporary copy
+of the buffer.  The export process consists of 4 major steps:
+
+1. Process the temporary copy, making necessary changes to the buffer
+   text;
+
+2. Parse the buffer, converting plain Org markup into an abstract
+   syntax tree (AST);
+
+3. Convert the AST to text, as prescribed by the selected export
+   backend;
+
+4. Post-process the resulting exported text.
+
+
+#+texinfo: @noindent
+Process temporary copy of the source Org buffer [fn::Unless
+otherwise specified, each step of the export process only operates on
+the accessible portion of the buffer.  When subtree export is selected
+(see [[*The Export Dispatcher]]), the buffer is narrowed to the body of
+the selected subtree, so that the rest of the buffer text, except
+export keywords, does not contribute to the export output.]:
+
+1. Execute ~org-export-before-processing-functions~ (see [[*Export hooks]]);
+
+2. Expand =#+include= keywords in the whole buffer (see
+   [[*Include Files]]);
+
+3. Remove commented subtrees in the whole buffer (see [[*Comment
+   Lines]]);
+
+4. Replace macros in the whole buffer (see [[*Macro Replacement]]);
+
+5. When ~org-export-use-babel~ is non-nil (default), process code
+   blocks:
+
+   - Leave code blocks inside archived subtrees (see [[*Internal
+ archiving]]) as is;
+
+   - Evaluate all the other code blocks according to code block
+ headers (see [[*Limit code block evaluation]]);
+
+   - Remove code, results of evaluation, both, or neither according
+ to =:exports= header argument (see [[*Exporting Code Blocks]]).
+
+
+#+texinfo: @noindent
+Parse the temporary buffer, creating AST:
+
+1. Execute ~org-export-before-parsing-functions~ (see [[*Export hooks]]).
+   The hook functions may still modify the buffer;
+
+2. Calculate export option values according to subtree-specific export
+   settings, in-buffer keywords, =#+BIND= keywords, and buffer-local
+   and global 

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

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

> Ihor Radchenko  writes:
>
>> I think we have a misunderstanding here.
>>
>> Didn't we just discuss that C-c C-p in python is not equivalent to
>> `org-babel-python-initiate-session'?
>
> ob-python works fine with sessions started externally by `run-python'.
> And I have preserved this functionality, as I enjoy the flexibility of
> working this way.
>
> In particular, ob-python will detect when it needs to run
> `org-babel-python--setup-session', even if the session was started
> externally by `run-python'.

As long as it remains undocumented, we can break this in future (maybe
years from now, but still...). 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.

-- 
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-28 Thread Ihor Radchenko
Jack Kamm  writes:

> Liu Hui  writes:
>
>> I just want to set 'python-shell-buffer-name' in the edit buffer
>> according to the :session header and don't need to start the session
>> even if the session doesn't exist.
>
> Sorry that I missed this thread.
>
> I agree that `python-shell-buffer-name' should be set according to the
> :session header, and that Liu's patch fixes a problem in ob-python.
>
> Is there any objection if I go ahead and apply it?

Because I am still thinking about the idea with global customization and
`org-babel--associate-session'.

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



Re: [BUG] - org-agenda log view does not conform to org-timestamp-formats

2023-12-28 Thread Ihor Radchenko
Tebe Nigrelli  writes:

> Steps to reproduce:
>
> Changing org-timestamp-formats to include the timezone: ("<%Y-%m-%d %a 
> %Z>" . "<%Y-%m-%d %a %H:%M %Z>"), a clock line will look like this:

`org-timestamp-formats' is a constant. You are not supposed to change
it. And if you do, we give no guarantees that Org mode will continue to
function correctly.

Canceled.

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