On Sun, Sep 28, 2025 at 10:12 AM Ihor Radchenko <[email protected]> wrote:

> > Do you have an example of a defcustom that does that? I tried looking at
> > the docs for defcustom and didn't see an obvious way to do that. I also
> > couldn't find an example in the codebase that seemed to do any
> validation.
>
> `org-property-separators'. Also see restricted-sexp customization type
> described in 15.4.2 Composite Types section of Elisp manual.
>

I think I have most of the patch fixed up based on the other feedback, but
I'm having some difficulty with customization. I think I have the
customization correct, but I can't figure out how to test that validation
operates on any values. I don't see anything in the current unit tests for
`org-property-separators' to reject bad values or otherwise validate
values. Here's what I currently have for `org-priority-highest`:

(defcustom org-priority-highest ?A
  "The highest priority of TODO items.

A character like ?A, ?B, etc., or a numeric value like 1, 2, etc.

The default is the character ?A, which is 65 as a numeric value.

If you set `org-priority-highest' to a numeric value inferior to
65, Org assumes you want to use digits for the priority cookie.
If you set it to >=65, Org assumes you want to use alphabetical
characters.

In both cases, the value of `org-priority-highest' must be
smaller than `org-priority-lowest': for example, if \"A\" is the
highest priority, it is smaller than the lowest \"C\" priority:
65 < 67."
  :group 'org-priorities
  :type '(restricted-sexp
          :match-alternatives (;; Choice 1: Integer from 0 to 65
                               (lambda (val)
                                 (and (integerp val)
                                      (<= 0 val 64)))
                               ;; Choice 2: Uppercase character A-Z (which
is also an integer)
                               (lambda (val)
                                 (and (integerp val)
                                      (<= ?A val ?Z))))))

This does validate things if I use the customize interface, but is there a
way to do it programmatically so that I can unit test it? I found
`customize-set-value' and `customize-set-variable' but neither of those
seem like the right function.

Thanks,

Derek

-- 
+---------------------------------------------------------------+
| Derek Chen-Becker                                             |
| GPG Key available at https://keybase.io/dchenbecker and       |
| https://pgp.mit.edu/pks/lookup?search=derek%40chen-becker.org |
| Fngrprnt: EB8A 6480 F0A3 C8EB C1E7  7F42 AFC5 AFEE 96E4 6ACC  |
+---------------------------------------------------------------+

Reply via email to