[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Little help with defcustom

From: Joost Kremers
Subject: Re: Little help with defcustom
Date: Mon, 09 Nov 2020 20:14:11 +0100
User-agent: mu4e 1.5.6; emacs 27.1.50

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 :error
                       "Invalid value: must be distinct from `todo-item-mark'"))
  :initialize 'custom-initialize-default
  :set 'todo-reset-prefix
  :group 'todo-display)

You could even test whether a field has the correct format.


Joost Kremers
Life has its moments

reply via email to

[Prev in Thread] Current Thread [Next in Thread]