bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#53153: package-quickstart: unusual autoload form in selectrum gives


From: Stefan Kangas
Subject: bug#53153: package-quickstart: unusual autoload form in selectrum gives byte-compilation warning
Date: Sun, 9 Jan 2022 22:46:59 -0600

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 via email to

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