emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: lra@phdk.org
To: Lra <lra@phdk.org>
Cc: Emacs Orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fixing a regression in org-persists ability to handle non-list container arguments.
Date: Wed, 18 Sep 2024 02:29:43 +0200 (CEST)	[thread overview]
Message-ID: <O71XEGm--B-9@phdk.org> (raw)
In-Reply-To: <O71W8io--B-9@phdk.org-O71WWax----9>


[-- Attachment #1.1: Type: text/plain, Size: 2021 bytes --]


And it is *with* the attachment.

Kind regards,
LRA


Sep 18, 2024, 02:26 by lra@phdk.org:

> Hello org-mode mailing list
>
> Long time, first time. This is just a tiny patch fixing a regression
> in org-persist--find-index that was missed in the 95f77669e0 bugfix. It affects
> calls to org-persist-read that don't use a list of containers,
> e.g. those in ox-latex's precompile function.
>
> I was having some issues getting the org-latex-preview branch to run
> smoothly when the xref-find-def trail led me to realize that it wasn't
> just my setup causing trouble. In the process of compiling a bug
> report I ended up fixing it on my end and thought I might as well send
> it your way and save sombody else the trouble. I took the liberty of
> clarifying a related comment that confused me a bit while working out
> the logic of the function.
>
> (This is just a quick fix of the specific regression, a more proper
> solution would probably move all the logic concerning container lists
> further up in the chain. However, actually doing something like
> rewriting o-p--normalize-container to achieve that is above my
> pay-grade. My experience writing elisp basically comes from writing a
> few advice-hacks to get stuff to do what I want, so feel free to
> reject and forget if you think this deserves a full treatment.)
>
> MWE running with -Q and org compiled from git (taken from the
> examples in org-persist documentation):
>   (let ((info1 "test")
>         (info2 "test 2"))
>     (org-persist-register
>      `("Named data" (elisp info1 local) (elisp info2 local))
>      nil :write-immediately t))
>   (org-persist-read
>    "Named data"
>    nil nil nil :read-related t)
>
> Expected result: org-persist-read will return ("Named data" "test" "test 2")
> Current result: it returns nil
>
> Kind regards,
> LRA
>
> P.S. Thank you all for all the hard work you put into this
> wonderful tool. It does not go unappreciated!
>
>


[-- Attachment #1.2: Type: text/html, Size: 3540 bytes --]

[-- Attachment #2: 0001-lisp-org-persist.el-Fix-regression-missed-by-7fd8099.patch --]
[-- Type: text/x-patch, Size: 1646 bytes --]

From caf7ff050876c4e604c8d4e159e7c2d51ad7f897 Mon Sep 17 00:00:00 2001
From: Lukas Rudd Andersen <lra@phdk.org>
Date: Wed, 18 Sep 2024 00:54:27 +0200
Subject: [PATCH] lisp/org-persist.el: Fix regression missed by 7fd8099

* lisp/org-persist.el: (org-persist--find-index): Fix regression that
  makes the function return nil when container in COLLECTION is not a
  list of containers.

TINYCHANGE
---
 lisp/org-persist.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index 8114fd5b9..7bae09f92 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -546,13 +546,15 @@ FORMAT and ARGS are passed to `message'."
                          (and hash (gethash (cons cont (list :hash hash)) org-persist--index-hash))
                          (and key (gethash (cons cont (list :key key)) org-persist--index-hash))))
              (when (and r
-                        ;; Every element in CONTAINER matches
-                        ;; COLLECTION.
+                        ;; Every element in container group of
+                        ;; COLLECTION matches returned CONTAINER. 
                         (seq-every-p
                          (lambda (cont)
                            (org-persist-collection-let r
                              (member cont container)))
-                         container))
+                         (if (listp (car container))
+                             container
+                           (list container))))
                (throw :found r))))))))
 
 (defun org-persist--add-to-index (collection &optional hash-only)
-- 
2.45.2


  parent reply	other threads:[~2024-09-18  0:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18  0:24 [PATCH] Fixing a regression in org-persists ability to handle non-list container arguments lra
     [not found] ` <O71W8io--B-9@phdk.org-O71WWax----9>
2024-09-18  0:29   ` lra [this message]
2024-09-22  9:11     ` Ihor Radchenko
2024-09-22 23:04       ` Karthik Chikmagalur
2024-10-02 17:34         ` Ihor Radchenko
2024-10-03 18:00           ` lra
2024-10-06 12:35             ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=O71XEGm--B-9@phdk.org \
    --to=lra@phdk.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).