CestDiego / nand2tetris.el

Major Mode for HDL files in nand2tetris.
42 stars 11 forks source link

void-variable nand2tetris-core-base-dir #8

Open andreas-roehler opened 6 years ago

andreas-roehler commented 6 years ago

Hi, after intalling this quite interesting package via package-manager, Emacs starts with the following error:

Debugger entered--Lisp error: (void-variable nand2tetris-core-base-dir) (expand-file-name nand2tetris-core-base-dir) (concat (expand-file-name nand2tetris-core-base-dir) ".\.hdl") (cons (concat (expand-file-name nand2tetris-core-base-dir) ".\.hdl") (quote (quote nand2tetris-mode))) (add-to-list (quote auto-mode-alist) (cons (concat (expand-file-name nand2tetris-core-base-dir) ".\.hdl") (quote (quote nand2tetris-mode)))) eval-buffer(#<buffer load-175805> nil "/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827/nand2tetris-autoloads.el" nil t) ; Reading at buffer position 957 load-with-code-conversion("/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827/nand2tetris-autoloads.el" "/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827/nand2tetris-autoloads.el" nil t) load("/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827/nand2tetris-autoloads" nil t) package--activate-autoloads-and-load-path([cl-struct-package-desc nand2tetris (20170306 1827) "Major mode for HDL files in the nand2tetris course" ((emacs (24))) nil nil "/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827" ((:keywords "nand2tetris" "hdl") (:url . "http://www.github.com/CestDiego/nand2tetris.el/")) nil]) package--load-files-for-activation([cl-struct-package-desc nand2tetris (20170306 1827) "Major mode for HDL files in the nand2tetris course" ((emacs (24))) nil nil "/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827" ((:keywords "nand2tetris" "hdl") (:url . "http://www.github.com/CestDiego/nand2tetris.el/")) nil] nil) package-activate-1([cl-struct-package-desc nand2tetris (20170306 1827) "Major mode for HDL files in the nand2tetris course" ((emacs (24))) nil nil "/home/MyName/.emacs.d/elpa/nand2tetris-20170306.1827" ((:keywords "nand2tetris" "hdl") (:url . "http://www.github.com/CestDiego/nand2tetris.el/")) nil] nil deps) package-activate(nand2tetris) package-initialize() eval-buffer(#<buffer load-39633> nil "/home/MyName/.gnu-emacs25" nil t) ; Reading at buffer position 723 load-with-code-conversion("/home/MyName/.gnu-emacs25" "/home/MyName/.gnu-emacs25" nil nil) load("/home/MyName/.gnu-emacs25") (cond ((string-match "^23" emacs-version) (load (expand-file-name "~/.gnu-emacs23-all-cvs")) (setq custom-file (expand-file-name "~/.gnu-emacs23-cvs-custom"))) ((string-match "^24" emacs-version) (load (expand-file-name "~/.gnu-emacs24")) (setq custom-file (expand-file-name "~/.gnu-emacs24-custom"))) ((string-match "^25" emacs-version) (load (expand-file-name "~/.gnu-emacs25")) (setq custom-file (expand-file-name "~/.gnu-emacs25-custom")))) eval-buffer(#<buffer load*> nil "/home/MyName/.emacs" nil t) ; Reading at buffer position 866 load-with-code-conversion("/home/MyName/.emacs" "/home/MyName/.emacs" t t) load("~/.emacs" t t)

[0 "\205\266

CestDiego commented 6 years ago

That's weird because it should be defined as a default here: https://github.com/CestDiego/nand2tetris.el/blob/9c5161c840f30f01647c188699dacba5e51b3b44/nand2tetris-core.el#L39-L41

I'll try to take a look at this. Thanks for submitting this.

ghost commented 5 years ago

Hi, Diego.

I have this similar situation here. In my .emacs file:

(use-package nand2tetris)
(setq nand2tetris-core-base-dir "~/nand2tetris")

But after running commandemacs --debug-init, I have:

Debugger entered--Lisp error: (void-variable nand2tetris-core-base-dir) (expand-file-name nand2tetris-core-base-dir) (concat (expand-file-name nand2tetris-core-base-dir) ".\.hdl") (cons (concat (expand-file-name nand2tetris-core-base-dir) ".\.hdl") ''nand2tetris-mode) (add-to-list 'auto-mode-alist (cons (concat (expand-file-name nand2tetris-core-base-dir) ".\.hdl") ''nand2tetris-mode)) eval-buffer(#<buffer load-711529> nil "/home/dengl3/.emacs.d/elpa/nand2tetris-20171201.1813/nand2tetris-autoloads.el" nil t) ; Reading at buffer position 958 load-with-code-conversion("/home/dengl3/.emacs.d/elpa/nand2tetris-20171201.1813/nand2tetris-autoloads.el" "/home/dengl3/.emacs.d/elpa/nand2tetris-20171201.1813/nand2tetris-autoloads.el" n$ load("/home/dengl3/.emacs.d/elpa/nand2tetris-20171201.1813/nand2tetris-autoloads" nil t) package--activate-autoloads-and-load-path(#s(package-desc :name nand2tetris :version (20171201 1813) :summary "Major mode for HDL files in the nand2tetris course" :reqs ((emacs (24))) :ki$ package--load-files-for-activation(#s(package-desc :name nand2tetris :version (20171201 1813) :summary "Major mode for HDL files in the nand2tetris course" :reqs ((emacs (24))) :kind nil $ package-activate-1(#s(package-desc :name nand2tetris :version (20171201 1813) :summary "Major mode for HDL files in the nand2tetris course" :reqs ((emacs (24))) :kind nil :archive nil :di$ package-activate(nand2tetris) package-initialize() eval-buffer(#<buffer load*> nil "/home/dengl3/.emacs.d/init.el" nil t) ; Reading at buffer position 419 load-with-code-conversion("/home/dengl3/.emacs.d/init.el" "/home/dengl3/.emacs.d/init.el" t t) load("/home/dengl3/.emacs.d/init" t t)

f(compiled-function () #<bytecode 0x25816d>)()

command-line() normal-top-level()

I tried to wrap the require 'nand2tetris-core inside a eval-and-compile in the file elpa\nand2tetris-20171201.1813\nand2tetris.el and re-run emacs --debug-init. The result is still the same.

If you have time, please take a look at this problem :-)

ghost commented 5 years ago

I think this void variable thing is caused by:

;;;###autoload
(add-to-list 'auto-mode-alist
             `(,(concat (expand-file-name nand2tetris-core-base-dir) "\.*\\.hdl")
               . 'nand2tetris-mode))

in nand2tetris.el. When the magic comment autoload is used, the code block below it will be copied to the nand2tetris-autoloads.el file. And it seems like this file will be processed before the nand2tetris.el in the emacs initialization. Currently, my suggestion is removing the nand2tetris-core-base-dir in add-to-list in your ~/.emacs.d/elpa/nand2tetris-20171201.1813/nand2tetris.el and then run M-x update-file-autoloads.

This modification will make emacs enable nand2tetris mode for every *.hdl file.

And if you just want a simple solution with syntax highlighting and indentation, I have an advice for you: https://github.com/Juan-Cortez3/emacs-nand2tetris @andreas-roehler