* [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/)]
@ 2023-12-12 11:40 Aaron Madlon-Kay
2023-12-12 12:01 ` Aaron Madlon-Kay
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Madlon-Kay @ 2023-12-12 11:40 UTC (permalink / raw)
To: emacs-orgmode
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.
------------------------------------------------------------------------
Local definitions for `org-entities-user` are not recognized as "safe"
even when they are in the correct format. For instance, including the
following local variables list in an org-mode file will still result in
Emacs prompting you to accept the value:
# Local Variables:
# org-entities-user: (("snowman" "[snowman]" nil "☃" "[snowman]" "[snowman]" "☃"))
# End:
Cause: The defcustom for `org-entities-user` has :safe set to the
function `org-entities--user-safe-p`. This function, however, appears to
be designed to validate a single entry of `org-entities-user`, rather
than the full value. Locally redefining as follows results in the
expected behavior:
(defun org-entities--user-safe-p (v)
"Non-nil if V is a safe value for `org-entities-user'."
(seq-every-p
(lambda (e) (pcase e
(`nil t)
(`(,(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))
The difference is that the current logic has been supplied as a lambda
to `seq-every-p`.
Thank you,
Aaron
Emacs : GNU Emacs 30.0.50 (build 1, x86_64-apple-darwin23.1.0, NS appkit-2487.20 Version 14.1.1 (Build 23B81))
of 2023-11-26
Package: Org mode version 9.6.11 (release_9.6.11 @ /Applications/MacPorts/Emacs.app/Contents/Resources/lisp/org/)
^ permalink raw reply [flat|nested] 6+ messages in thread
* 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/)]
2023-12-12 11:40 [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/)] Aaron Madlon-Kay
@ 2023-12-12 12:01 ` Aaron Madlon-Kay
2023-12-12 12:29 ` Aaron Madlon-Kay
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Madlon-Kay @ 2023-12-12 12:01 UTC (permalink / raw)
To: emacs-orgmode
> 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 …).
(defun org-entities--user-safe-p (v)
"Non-nil if V is a safe value for `org-entities-user'."
(pcase v
(`nil t)
((seq `(,(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)))
Regardless I leave the details to the developers.
-Aaron
^ permalink raw reply [flat|nested] 6+ messages in thread
* 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/)]
2023-12-12 12:01 ` Aaron Madlon-Kay
@ 2023-12-12 12:29 ` Aaron Madlon-Kay
2023-12-12 12:55 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Madlon-Kay @ 2023-12-12 12:29 UTC (permalink / raw)
To: emacs-orgmode
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-12-12 15:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12 11:40 [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/)] Aaron Madlon-Kay
2023-12-12 12:01 ` Aaron Madlon-Kay
2023-12-12 12:29 ` Aaron Madlon-Kay
2023-12-12 12:55 ` Ihor Radchenko
[not found] ` <98E48EEB-5E10-42ED-91D4-9369B6B98B20@madlon-kay.com>
[not found] ` <87y1dz5wxm.fsf@localhost>
2023-12-12 14:36 ` Aaron Madlon-Kay
2023-12-12 15:18 ` Ihor Radchenko
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).