all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Dario Gjorgjevski <dario.gjorgjevski@gmail.com>, 35771@debbugs.gnu.org
Subject: bug#35771: [PATCH] Customization type of recentf-max-saved-items
Date: Fri, 17 May 2019 06:36:30 -0700 (PDT)	[thread overview]
Message-ID: <42941bba-e6b4-4a46-b56f-97ffcfc2117f@default> (raw)
In-Reply-To: <87pnohb79x.fsf@gmail.com>

> The customization type of recentf-max-saved-items is currently defined
> as integer, which does not include nil in its domain.  However, setting
> this variable to nil is supported in the code and also documented.
> 
> This patch changes the customization type to explicitly allow for the
> variable to be set to nil through the Customization interface and
> similar.  (Please note that I copied the type from save-place-limit in
> order to be consistent.)

(I'm looking at Emacs 26.2, so apologies if the Emacs 27
code has already fixed this.)

The code should also be changed to do one of the following:

1. Use `abs' when the variable value is used.

2. Use `restricted-sexp' in the defcustom :type, to require
   the value to be a non-negative (or possibly a positive?)
   integer (or nil).

I'm guessing there are additional places in Emacs code
where :type 'integer is used but a non-negative integer is
really needed/appropriate.  It would be good to improve
those :type specs as well.

(We might also want to consider adding `natnum' or
`nonnegative-integer', `positive-integer' and
`negative-integer' as possible :type values.)

But it is simple to use `restricted-sexp' to control such
things.  And not only would that improve the behavior for
users; it would also, by way of model, encourage users to
use `restricted-sexp' in their own code.

Emacs-Lisp code delivered with Emacs is not a great model
in this respect.  It rarely uses `restricted-sexp' - at
least it uses it much less than it could/should (IMHO).

More generally, the distributed Emacs code is pretty
"lazy" when it comes to providing defcustom definitions -
few :tag descriptions, overly general :type specs, etc.

E.g.,

(defcustom recentf-max-saved-items 20
  "Maximum number of recently used file names to save.
`nil' means save the whole list.
See command `recentf-save-list'."
  :group 'recentf
  :type '(choice 
          (restricted-sexp
           :tag "Save no more than this many file names"
           :match-alternatives
           ((lambda (x) (and (natnump x) (not (zerop x)))))
           :value ignore)
          (const :tag "Save all file names" nil)))





  parent reply	other threads:[~2019-05-17 13:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 12:22 bug#35771: [PATCH] Customization type of recentf-max-saved-items Dario Gjorgjevski
2019-05-17 13:13 ` Basil L. Contovounesios
2019-05-17 13:33   ` Eli Zaretskii
2019-05-17 14:14     ` Basil L. Contovounesios
2019-05-17 14:39       ` Eli Zaretskii
2019-05-19  9:15   ` Dario Gjorgjevski
2019-05-23  0:21     ` Basil L. Contovounesios
2019-05-17 13:36 ` Drew Adams [this message]
2019-05-17 14:17   ` Basil L. Contovounesios
2019-05-17 15:30     ` Drew Adams
2019-05-18 16:58       ` Basil L. Contovounesios
2019-05-18 23:10         ` Drew Adams
2019-05-19  2:52           ` Basil L. Contovounesios
2019-05-22  5:28             ` Eli Zaretskii
2019-05-23  0:24               ` Basil L. Contovounesios

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=42941bba-e6b4-4a46-b56f-97ffcfc2117f@default \
    --to=drew.adams@oracle.com \
    --cc=35771@debbugs.gnu.org \
    --cc=dario.gjorgjevski@gmail.com \
    /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.