jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.42k stars 260 forks source link

Why "autoload" not supporting description when loading a command? #872

Open cwagner2046 opened 4 years ago

cwagner2046 commented 4 years ago

Hi!

I moved the following declaration:

(setq scheme-program-name "scheme48") (autoload 'run-scheme "cmuscheme48" "Run an inferior Scheme process." t)

into this use-package declaration:

(use-package cmuscheme48 :init (setq scheme-program-name "scheme48") (autoload 'run-scheme "cmuscheme48" "Run an inferior Scheme process." t))

When I start Emacs and execute "M-x apropos-command: run-scheme", Emacs does not display the description "Run an inferior Scheme process".

The use-package declaration has been processed without problem. Other means allow me to confirm that the "autoloading" did take place. Yet, the description displayed is not the correct one. (What is given is the description of the "run-scheme" command in "scheme.el" which cmuscheme48 replaces.)

Why is the description given in the autoload call within the use-package declaration not passed to Emacs? Thanks.

a13 commented 4 years ago
run-scheme is an interactive autoloaded compiled Lisp function in
‘cmuscheme.el’.

Why use cmuscheme48? the code looks very outdated, hadn't been touched for many years

skangas commented 2 years ago

To make things easier to test without cmuscheme48.el, I tried this with the builtin cmuscheme package, like so:

(use-package cmuscheme
  :init
  (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t))

Expanded (using M-x pp-macroexpand-last-sexp) this comes out to:

(progn
  (defvar use-package--warning0
    #'(lambda
    (keyword err)
    (let
        ((msg
          (format "%s/%s: %s" 'cmuscheme keyword
              (error-message-string err))))
      (display-warning 'use-package msg :error))))
  (condition-case-unless-debug err
      (progn
    (condition-case-unless-debug err
        (progn
          (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t))
      (error
       (funcall use-package--warning0 :init err)))
    (if
        (not
         (require 'cmuscheme nil t))
        (display-warning 'use-package
                 (format "Cannot load %s" 'cmuscheme)
                 :error)))
    (error
     (funcall use-package--warning0 :catch err))))

When stepping through this using edebug-eval-top-level-form, I can verify that the autoload is in fact evaluated. So I guess use-package is not at fault in that sense. But you are correct that the docstring is still the one from xscheme.el.

However, if I evaluate only this form in emacs -Q:

(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t)

I also see that the docstring is, in this case also, the one from xscheme.el. So putting it in a use-package declaration doesn't change anything, AFAICT.

I guess autoload doesn't overwrite docstrings in this case, or something? In that case, that looks more like a bug in autoload than a bug in use-package. Do you agree?

cwagner2046 commented 1 year ago

Hi, it seems you're conclusion is correct. --Christian

On Mon, 28 Nov 2022 at 19:45, Stefan Kangas @.***> wrote:

To make things easier to test without cmuscheme48.el, I tried this with the builtin cmuscheme package, like so:

(use-package cmuscheme :init (setq scheme-program-name "scheme48") (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t))

Expanded (using M-x pp-macroexpand-last-sexp) this comes out to:

(progn (defvar use-package--warning0

'(lambda

(keyword err) (let ((msg (format "%s/%s: %s" 'cmuscheme keyword (error-message-string err)))) (display-warning 'use-package msg :error)))) (condition-case-unless-debug err (progn (condition-case-unless-debug err (progn (setq scheme-program-name "scheme48") (autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t)) (error (funcall use-package--warning0 :init err))) (if (not (require 'cmuscheme nil t)) (display-warning 'use-package (format "Cannot load %s" 'cmuscheme) :error))) (error (funcall use-package--warning0 :catch err))))

When stepping through this using edebug-eval-top-level-form, I can verify that the autoload is in fact evaluated. So I guess use-package is not at fault in that sense. But you are correct that the docstring is still the one from xscheme.el.

However, if I evaluate only this form in emacs -Q:

(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t)

I also see that the docstring is in this case also the one from xscheme.el. So putting it in a use-package declaration doesn't change anything, AFAICT.

I guess autoload doesn't overwrite docstrings in this case, or something? In that case, that looks more like a bug in autoload than a bug in use-package. Do you agree?

— Reply to this email directly, view it on GitHub https://github.com/jwiegley/use-package/issues/872#issuecomment-1329662412, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3HXL362HE32AAOLAGYN53WKUDT3ANCNFSM4RP7DB7Q . You are receiving this because you authored the thread.Message ID: @.***>