abo-abo / oremacs

My Emacs config
https://oremacs.com/
296 stars 33 forks source link

concat: Symbol’s value as variable is void: whitespace-mode #14

Closed srustamo closed 7 years ago

srustamo commented 7 years ago

I get the subject error calling the hydra below.

(defhydra hydra-toggle (:color pink :hint nil)
  "
_a_ abbrev-mode:       %`abbrev-mode
_d_ debug-on-error:    %`debug-on-error
_f_ auto-fill-mode:    %`auto-fill-function
_h_ highlight          %`highlight-nonselected-windows
_t_ truncate-lines:    %`truncate-lines
_w_ whitespace-mode:   %`whitespace-mode
_l_ org link display:  %`org-descriptive-links
"
  ("a" abbrev-mode)
  ("d" toggle-debug-on-error)
  ("f" auto-fill-mode)
  ("h" (setq highlight-nonselected-windows (not highlight-nonselected-windows)))
  ("t" toggle-truncate-lines)
  ("w" whitespace-mode)
  ("l" org-toggle-link-display)
  ("q" nil "quit"))
srustamo commented 7 years ago

This is in keys.el file.

srustamo commented 7 years ago

Calling it after manually calling whitespace-mode does not give error.

abo-abo commented 7 years ago

Can't reproduce.

srustamo commented 7 years ago

I'm not using the config verbatim, so not surprised if it works for you. If something jumps to your mind as to the reason, I appreciate your sharing.

Trace.

Debugger entered--Lisp error: (void-variable whitespace-mode) (format "%s abbrev-mode: %S\n%s debug-on-error: %S\n%s auto-fill-mode: %S\n%s highlight %S\n%s truncate-lines: %S\n%s whitespace-mode: %S\n%s org link display: %S\n" #("a" 0 1 (face hydra-face-pink)) abbrev-mode #("d" 0 1 (face hydra-face-pink)) debug-on-error #("f" 0 1 (face hydra-face-pink)) auto-fill-function #("h" 0 1 (face hydra-face-pink)) highlight-nonselected-windows #("t" 0 1 (face hydra-face-pink)) truncate-lines #("w" 0 1 (face hydra-face-pink)) whitespace-mode #("l" 0 1 (face hydra-face-pink)) org-descriptive-links) (concat (format "%s abbrev-mode: %S\n%s debug-on-error: %S\n%s auto-fill-mode: %S\n%s highlight %S\n%s truncate-lines: %S\n%s whitespace-mode: %S\n%s org link display: %S\n" #("a" 0 1 (face hydra-face-pink)) abbrev-mode #("d" 0 1 (face hydra-face-pink)) debug-on-error #("f" 0 1 (face hydra-face-pink)) auto-fill-function #("h" 0 1 (face hydra-face-pink)) highlight-nonselected-windows #("t" 0 1 (face hydra-face-pink)) truncate-lines #("w" 0 1 (face hydra-face-pink)) whitespace-mode #("l" 0 1 (face hydra-face-pink)) org-descriptive-links) #("[q]: quit." 1 2 (face hydra-face-blue))) eval((concat (format "%s abbrev-mode: %S\n%s debug-on-error: %S\n%s auto-fill-mode: %S\n%s highlight %S\n%s truncate-lines: %S\n%s whitespace-mode: %S\n%s org link display: %S\n" #("a" 0 1 (face hydra-face-pink)) abbrev-mode #("d" 0 1 (face hydra-face-pink)) debug-on-error #("f" 0 1 (face hydra-face-pink)) auto-fill-function #("h" 0 1 (face hydra-face-pink)) highlight-nonselected-windows #("t" 0 1 (face hydra-face-pink)) truncate-lines #("w" 0 1 (face hydra-face-pink)) whitespace-mode #("l" 0 1 (face hydra-face-pink)) org-descriptive-links) #("[q]: quit." 1 2 (face hydra-face-blue)))) hydra-show-hint((concat (format "%s abbrev-mode: %S\n%s debug-on-error: %S\n%s auto-fill-mode: %S\n%s highlight %S\n%s truncate-lines: %S\n%s whitespace-mode: %S\n%s org link display: %S\n" #("a" 0 1 (face hydra-face-pink)) abbrev-mode #("d" 0 1 (face hydra-face-pink)) debug-on-error #("f" 0 1 (face hydra-face-pink)) auto-fill-function #("h" 0 1 (face hydra-face-pink)) highlight-nonselected-windows #("t" 0 1 (face hydra-face-pink)) truncate-lines #("w" 0 1 (face hydra-face-pink)) whitespace-mode #("l" 0 1 (face hydra-face-pink)) org-descriptive-links) #("[q]: quit." 1 2 (face hydra-face-blue))) hydra-toggle) hydra-toggle/body() funcall-interactively(hydra-toggle/body) call-interactively(hydra-toggle/body nil nil) command-execute(hydra-toggle/body)

abo-abo commented 7 years ago

whitespace-mode is both a symbol and a function defined in whitespace.el. Possibly, only the function is autoloaded, resulting in the symbol being undefined. In any case, a simple (require 'whitespace) before defhydra should fix it.

srustamo commented 7 years ago

Thanks. I try to follow your way of reducing the use of require. I greped your repo for whitespace-mode. You only define it in keys.el.

I wonder why you don't see this error.

-- mode: ag; default-directory: "~/GitHub/abo-abo/oremacs/" -- Ag started at Tue Mar 28 19:24:20

ag --literal --nogroup --line-number --column --color --color-match 30\;43 --color-path 1\;32 --nogroup --skip-vcs-ignores --numbers --smart-case --follow --stats -- whitespace-mode . keys.el:252:5:w whitespace-mode: %`whitespace-mode keys.el:260:8: ("w" whitespace-mode) 3 matches 1 files contained matches 172 files searched 271739 bytes searched 0.012638 seconds

Ag finished at Tue Mar 28 19:24:20

abo-abo commented 7 years ago

Thanks. I try to follow your way of reducing the use of require.

I was actually suggesting to increase it. Your error happens because the whitespace-mode symbol isn't defined. If you use (require 'whitespace), the symbol will become defined. Just use it before defhydra, not after.

srustamo commented 7 years ago

I was actually suggesting to increase it

I meant the overall philosophy of this config - autoload/hook stuff to reduce load time.

Thanks for your help. I'm still curious why you don't see this error in your config.