From: Joost Kremers <joostkremers@fastmail.fm>
To: help-gnu-emacs@gnu.org
Subject: Re: Little help with defcustom
Date: Mon, 09 Nov 2020 20:14:11 +0100 [thread overview]
Message-ID: <871rh2mjgc.fsf@fastmail.fm> (raw)
In-Reply-To: <X6lvyNpsMCujxR1k@protected.rcdrun.com>
On Mon, Nov 09 2020, Jean Louis wrote:
> :type '(repeat
> (list :tag "Dynamical User Sets"
> (string :tag " Server")
> (string :tag "Set name")
> (string :tag " Node ID"))))
[...]
> I see that to achieve best formatting I have to pad with spaces those
> strings. Is there maybe better way?
Not that I know of, no. I never bother, but it would be nice to be able to align
the fields.
> Is there a way to make sure that field is not empty?
Honestly, I don't know. The Elisp manual says there's a `:validate' keyword that
can be used to provide a function for validating the input. I've never used it,
but here's an example from the Emacs sources (`lisp/calendar/todo.el`):
```
(defcustom todo-prefix ""
"String prefixed to todo items for visual distinction."
:type '(string :validate
(lambda (widget)
(when (string= (widget-value widget) todo-item-mark)
(widget-put
widget :error
(format-message
"Invalid value: must be distinct from `todo-item-mark'"))
widget)))
:initialize 'custom-initialize-default
:set 'todo-reset-prefix
:group 'todo-display)
```
You could even test whether a field has the correct format.
HTH
--
Joost Kremers
Life has its moments
next prev parent reply other threads:[~2020-11-09 19:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 9:12 Little help with defcustom Jean Louis
2020-11-09 13:41 ` Joost Kremers
2020-11-09 16:35 ` Jean Louis
2020-11-09 19:14 ` Joost Kremers [this message]
2020-11-09 20:31 ` Jean Louis
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871rh2mjgc.fsf@fastmail.fm \
--to=joostkremers@fastmail.fm \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.