sachac / subed

subed is a subtitle editor for Emacs
177 stars 16 forks source link

Debugger entered--Lisp error: (void-variable subed--init-alist) #31

Closed twlz0ne closed 3 years ago

twlz0ne commented 3 years ago

Expected Behavior

No error occurs at startup.

Actual Behavior

void-variable subed--init-alist occurs at startup.

Extra details

Debugger entered--Lisp error: (void-variable subed--init-alist) ``` Debug on Error enabled globally Package cl is deprecated Debugger entered--Lisp error: (void-variable subed--init-alist) (let ((--dolist-tail-- subed--init-alist)) (while --dolist-tail-- (let ((item (car --dolist-tail--))) (let ((file-ext-regex (car item))) (add-to-list 'auto-mode-alist (cons (concat "\\." file-ext-regex "\\'") 'subed-mode))) (setq --dolist-tail-- (cdr --dolist-tail--))))) eval-buffer(# nil "/Users/*/.emacs.d/elpa/subed-20201228.50..." nil t) ; Reading at buffer position 954 load-with-code-conversion("/Users/*/.emacs.d/elpa/subed-20201228.50..." "/Users/*/.emacs.d/elpa/subed-20201228.50..." nil t) load("/Users/*/.emacs.d/elpa/subed-20201228.50..." nil t) package--activate-autoloads-and-load-path(#s(package-desc :name subed :version (20201228 505) :summary "A major mode for editing subtitles" :reqs ((emacs (25 1))) :kind nil :archive nil :dir "/Users/*/.emacs.d/elpa/subed-20201228.50..." :extras ((:url . "https://github.com/rndusr/subed") (:keywords "convenience" "files" "hypermedia" "multimedia")) :signed nil)) package--load-files-for-activation(#s(package-desc :name subed :version (20201228 505) :summary "A major mode for editing subtitles" :reqs ((emacs (25 1))) :kind nil :archive nil :dir "/Users/*/.emacs.d/elpa/subed-20201228.50..." :extras ((:url . "https://github.com/rndusr/subed") (:keywords "convenience" "files" "hypermedia" "multimedia")) :signed nil) nil) package-activate-1(#s(package-desc :name subed :version (20201228 505) :summary "A major mode for editing subtitles" :reqs ((emacs (25 1))) :kind nil :archive nil :dir "/Users/*/.emacs.d/elpa/subed-20201228.50..." :extras ((:url . "https://github.com/rndusr/subed") (:keywords "convenience" "files" "hypermedia" "multimedia")) :signed nil) nil deps) package-activate(subed) package--activate-all() package-activate-all() package-initialize() (progn (toggle-debug-on-error) (setq user-emacs-directory "~/.emacs.d/") (setq package-user-dir (expand-file-name "elpa/" user-emacs-directory)) (package-initialize)) eval((progn (toggle-debug-on-error) (setq user-emacs-directory "~/.emacs.d/") (setq package-user-dir (expand-file-name "elpa/" user-emacs-directory)) (package-initialize)) t) command-line-1(("--eval" "\n(progn\n (toggle-debug-on-error)\n (setq user-ema...")) command-line() normal-top-level() ```

Steps to reproduce

⋊>  ls ~/.emacs.d/elpa/subed-20201228.505/
subed-autoloads.el  subed-common.elc  subed-config.elc  subed-debug.elc  subed-mpv.elc  subed-srt.el   subed-vtt.el   subed.el
subed-common.el     subed-config.el   subed-debug.el    subed-mpv.el     subed-pkg.el   subed-srt.elc  subed-vtt.elc  subed.elc

⋊>  emacs -nw -Q --eval "
     (progn
       (toggle-debug-on-error)
       (setq user-emacs-directory \"~/.emacs.d/\")
       (setq package-user-dir (expand-file-name \"elpa/\" user-emacs-directory))
       (package-initialize))
     " --batch

Environment

rndusr commented 3 years ago

⋊> emacs -nw -Q --eval " (progn (toggle-debug-on-error) (setq user-emacs-directory \"~/.emacs.d/\") (setq package-user-dir (expand-file-name \"elpa/\" user-emacs-directory)) (package-initialize)) " --batch

That prints "Debug on Error enabled globally" and exits with 0.

twlz0ne commented 3 years ago

That prints "Debug on Error enabled globally" and exits with 0.

It's strange.

The error on my computer is caused by the following code in subed-autoloads.el:

(dolist (item subed--init-alist) (let ((file-ext-regex (car item))) (add-to-list 'auto-mode-alist (cons (concat "\\." file-ext-regex "\\'") 'subed-mode))))

When I moved the definition of subed--init-alist from subed-config.el to subed.el, then remake autoloads, the error dispear:

- (defvar subed--init-alist '(("srt" . subed-srt--init)
-                             ("vtt" . subed-vtt--init))
-   "Alist that maps file extensions to format-specific init functions.")
+ ;;;###autoload
+ (defvar subed--init-alist '(("srt" . subed-srt--init)
+                             ("vtt" . subed-vtt--init))
+   "Alist that maps file extensions to format-specific init functions.")
...

;;;###autoload
(dolist (item subed--init-alist)
  (let ((file-ext-regex (car item)))
    (add-to-list 'auto-mode-alist (cons (concat "\\." file-ext-regex "\\'")
                                        'subed-mode))))
+ (defvar subed--init-alist '(("srt" . subed-srt--init) ("vtt" . subed-vtt--init)) "\
+ Alist that maps file extensions to format-specific init functions.")
...
(dolist (item subed--init-alist) (let ((file-ext-regex (car item))) (add-to-list 'auto-mode-alist (cons (concat "\\." file-ext-regex "\\'") 'subed-mode))))
rndusr commented 3 years ago

Where did you get subed-autoloads.el? It's not part of the repo.

twlz0ne commented 3 years ago

Where did you get subed-autoloads.el? It's not part of the repo.

Now I understand why there is no error occurs on your computer, because you used the source code directly, that makes autoload not take effect.

I installed subed via quelpa:

(quelpa '(subed :fetcher github "rndusr/subed" :files "subed/*.el"))

It compiles the source into an ELPA compatible package, the subed-autoloads.el is thus created.

The little change I made above will ensure that the definition of subed--init-alist will also be added to subed-autoloads.el before the dolist statement: https://github.com/twlz0ne/subed/commit/73ad0a5497bfef64a2a9e8e8a9a49285ab9bd7e5

dalugm commented 3 years ago

Same problem here, I'm using borg to install this package which will also generate an autoload file when building.

twlz0ne's patch resolves this issue.

rndusr commented 3 years ago

I made a little change to ensure that the definition of subed--init-alist will also be added to subed-autoloads.el before the dolist statement: https://github.com/twlz0ne/subed/commit/73ad0a5497bfef64a2a9e8e8a9a49285ab9bd7e5

Thank you.