unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: 53153@debbugs.gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#53153: package-quickstart: unusual autoload form in selectrum gives byte-compilation warning
Date: Sun, 9 Jan 2022 22:46:59 -0600	[thread overview]
Message-ID: <CADwFkm=FBeSJdNb9tj+Cnj8_4K+bjHJPBkx1fntTgCvF-d2e-g@mail.gmail.com> (raw)

Severity: minor

I am seeing this warning whenever I install a package:

  Compiling file /home/skangas/.emacs.d/package-quickstart.el at Mon
Jan 10 05:33:47 2022
  package-quickstart.el:2060:2170: Warning: defcustom for ‘selectrum-mode’ fails
      to specify containing group

This is due to an odd hack in selectrum.el (available on MELPA or at
https://github.com/raxod502/selectrum):

  ;; You may ask why we copy the entire minor-mode definition into the
  ;; autoloads file, and autoload several private functions as well.
  ;; This is because enabling `selectrum-mode' does not actually require
  ;; any of the code in Selectrum. So, to improve startup time, we avoid
  ;; loading Selectrum when enabling `selectrum-mode'.

  ;;;###autoload
  (progn
    (define-minor-mode selectrum-mode

This unusual arrangement means that we end up with this interesting form
in package-quickstart.el (pretty-printed):

  (define-minor-mode selectrum-mode
    "Minor mode to use Selectrum for `completing-read'."
    :global t
    (if selectrum-mode (progn
                         (selectrum-mode -1)
                         (setq selectrum-mode t)
                         (setq selectrum--old-completing-read-function
(default-value 'completing-read-function))
                         (setq-default completing-read-function
#'selectrum-completing-read)
                         (setq selectrum--old-read-buffer-function
(default-value 'read-buffer-function))
                         (setq-default read-buffer-function
#'selectrum-read-buffer)
                         (setq selectrum--old-read-file-name-function
(default-value 'read-file-name-function))
                         (setq-default read-file-name-function
#'selectrum-read-file-name)
                         (setq
selectrum--old-completion-in-region-function (default-value

      'completion-in-region-function))
                         (when selectrum-complete-in-buffer
                           (setq-default completion-in-region-function
#'selectrum-completion-in-region))
                         (advice-add #'completing-read-multiple
:override #'selectrum-completing-read-multiple)
                         (advice-add 'dired-read-dir-and-switches :around

#'selectrum--fix-dired-read-dir-and-switches)
                         (advice-add 'read-library-name :override
#'selectrum-read-library-name)
                         (advice-add #'minibuffer-message :around
#'selectrum--fix-minibuffer-message)
                         (define-key minibuffer-local-map [remap
previous-matching-history-element]
                                     'selectrum-select-from-history))
      (when (equal (default-value 'completing-read-function)
#'selectrum-completing-read)
        (setq-default completing-read-function
selectrum--old-completing-read-function))
      (when (equal (default-value 'read-buffer-function)
#'selectrum-read-buffer)
        (setq-default read-buffer-function selectrum--old-read-buffer-function))
      (when (equal (default-value 'read-file-name-function)
#'selectrum-read-file-name)
        (setq-default read-file-name-function
selectrum--old-read-file-name-function))
      (when (equal (default-value 'completion-in-region-function)
#'selectrum-completion-in-region)
        (setq-default completion-in-region-function
selectrum--old-completion-in-region-function))
      (advice-remove #'completing-read-multiple
#'selectrum-completing-read-multiple)
      (advice-remove 'dired-read-dir-and-switches
#'selectrum--fix-dired-read-dir-and-switches)
      (advice-remove 'read-library-name #'selectrum-read-library-name)
      (advice-remove #'minibuffer-message #'selectrum--fix-minibuffer-message)
      (when (eq (lookup-key minibuffer-local-map [remap
previous-matching-history-element])
                #'selectrum-select-from-history)
        (define-key minibuffer-local-map [remap
previous-matching-history-element] nil))))

Now, I have two questions:

1. Does it make sense for Emacs to be complaining about a defcustom
   here?  AFAICT, there is no defcustom in the above form.  Do we care,
   or is this use case just unsupported?

2. I guess the other question is why `selectrum-mode' is not just in its
   own file, if startup speed is of the essence.  Maybe Stefan Monnier
   has something to add here.





             reply	other threads:[~2022-01-10  4:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10  4:46 Stefan Kangas [this message]
2022-01-13  9:11 ` bug#53153: package-quickstart: unusual autoload form in selectrum gives byte-compilation warning Lars Ingebrigtsen
2022-01-13 11:20   ` Stefan Kangas
2022-01-13 14:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-13 15:30   ` Stefan Kangas
2022-01-13 16:20   ` bug#53153: [External] : " Drew Adams

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkm=FBeSJdNb9tj+Cnj8_4K+bjHJPBkx1fntTgCvF-d2e-g@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=53153@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).