[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] "Safe" local values for org-entities-user not recognized as su
From: |
Aaron Madlon-Kay |
Subject: |
Re: [BUG] "Safe" local values for org-entities-user not recognized as such [9.6.11 (release_9.6.11 @ /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/org/)] |
Date: |
Tue, 12 Dec 2023 21:29:28 +0900 |
> On Dec 12, 2023, at 21:01, Aaron Madlon-Kay <aaron@madlon-kay.com> wrote:
>
>> On Dec 12, 2023, at 20:40, Aaron Madlon-Kay <aaron@madlon-kay.com> wrote:
>>
>> Locally redefining as follows results in the expected behavior:
>
> The previous formulation was not very good. Actually it seems that the
> existing
> function is correct except that the list case should be wrapped in (seq …).
OK this was also wrong, because seq only matches a finite sequence. I couldn’t
find a way to match an arbitrary-length list with pcase, so here’s my final
attempt:
(defun org-entities--user-safe-p (v)
"Non-nil if V is a safe value for `org-entities-user'."
(cond
((not v) t)
((listp v)
(seq-every-p
(lambda (e)
(pcase e
(`(,(and (pred stringp)
(pred (string-match-p "\\`[a-zA-Z][a-zA-Z0-9]*\\'")))
,(pred stringp) ,(pred booleanp) ,(pred stringp)
,(pred stringp) ,(pred stringp) ,(pred stringp))
t)
(_ nil)))
v))))
This seems to handle all cases correctly, but again of course I leave the
details to the devs (is seq-every-p allowed? is there actually a way to do it
with just pcase?).
Thanks,
Aaron