vermiculus / sx.el

Stack Exchange for Emacs
http://stackapps.com/q/3950
709 stars 40 forks source link

Compiling creates ~/.emacs.d/.sx #308

Closed tarsius closed 8 years ago

tarsius commented 8 years ago

I am guessing that a call to sx-cache-get does it (by calling sx-cache--ensure-sx-cache-directory-exists) but could not find where that is called at compile time.

I would prefer if it didn't do that because I have changed the value to ~/.emacs.d/var/sx but that setting is not effective when I compile, so whenever I recompile all files in my ~/.emacs.d I have to then remove the empty ~/.emacs.d/.sx.

vermiculus commented 8 years ago

I'll take a look at this -- thanks for bringing it up.

vermiculus commented 8 years ago

I'm not having any luck reproducing this by just byte-compiling the *.el in the directory (top-level only). Can you put this form in sx-cache--ensure-sx-cache-directory-exists and compile?

(with-temp-buffer
  (insert (with-output-to-string (backtrace)))
  (write-file
   (expand-file-name
    (format "backtrace-%d"
            (setq *sx-temp* (1+ *sx-temp*)))
    sx-cache-directory)))

(obviously making sure *sx-temp* is set to 0 at the top level)

tarsius commented 8 years ago

I am currently refactoring my byte-compile and package management setup, and will get back to you once I have progressed a little further. Since you say this doesn't happen during byte-compilation for you, I suspect it happens when generating or loading autoloads. But I haven't looked into that yet. I probably should have waited a bit before opening this issue.

tarsius commented 8 years ago

This should be enough to reproduce the issue:

$ rm -rf bot resources test                                                            
$ emacs -Q --batch -L . -L ../markdown-mode --eval '(byte-recompile-directory "." 0 t)'

(Normally I use my own version of byte-recompile-directory which does not descend into test/ and other subdirectories, but I am using a built-in function here to demonstrate that it's not an issue in my code.)

That also complains about undefined functions:

sx-button.el:210:1:Warning: the following functions are not known to be
    defined: sx-open-link, sx-question-mode-hide-show-section, sx-comment,
    sx-accept, sx-answer

And using your debug statement (and (defvar *sx-cache* 0)):

$ emacs -Q --batch -L . -L ../markdown-mode --eval '(byte-recompile-directory "." 0 t)' --eval '(message "*sx-temp*: %s" *sx-temp*)'
...
Done (Total of 27 files compiled)
*sx-temp*: 1
vermiculus commented 8 years ago

Thanks. What does the backtrace say in sx-cache-directory?

tarsius commented 8 years ago

Ups. Here you go:

  backtrace()
  sx-cache--ensure-sx-cache-directory-exists()
  sx-cache-get(filter)
  (defvar sx--filter-alist (sx-cache-get (quote filter)) ("/home/jonas/.emacs.d/lib/sx/sx-filter.elc" . 503))
  require(sx-filter)
  byte-code("\300\301!\210\300\302!\210\300\303!\207" [require sx sx-filter sx-method] 2)
  require(sx-question)
  byte-code("\300\301!\210\300\302!\210\300\303!\210\304\305\306\307\310\302%\207" [require button sx sx-question custom-declare-face sx-custom-button ((((type x w32 ns) (class color)) :box (:line-width 3 :style released-button) :height 0.9 :background "lightgrey" :foreground "black")) "Face used on buttons such as \"Write an Answer\"." :group] 6)
  require(sx-button)
  apply(require sx-button)
  byte-compile-file-form-require((require (quote sx-button)))
  byte-compile-file-form((require (quote sx-button)))
  #[257 "\301\302\303\304\"!)\207" [byte-compile-current-form nil byte-compile-file-form byte-compile-preprocess t] 5 "

(fn FORM)"]((require (quote sx-button)))
  byte-compile-recurse-toplevel((require (quote sx-button)) #[257 "\301\302\303\304\"!)\207" [byte-compile-current-form nil byte-compile-file-form byte-compile-preprocess t] 5 "

(fn FORM)"])
  byte-compile-toplevel-file-form((require (quote sx-button)))
\2037\315\316!\210\317!\210)\210\202\320 \210d\321 \210\205Ur\20q\210\32!)\207" [byte-compile-current-file byte-compile--outbuffer byte-compile-unresolved-functions byte-compile-read-position byte-compile-last-position old-style-backquotes byte-compile-insert-header nil " 

" looking-at ";" 1 read byte-compile-warn "!! The file uses old-style backquotes !!
This functionality has been obsolete for more than 10 years already
and will be removed soon.  See (elisp)Backquote in the manual." byte-compile-toplevel-file-form byte-compile-flush-pending byte-compile-warn-about-unresolved-functions byte-compile-fix-header] 5 "

(fn INBUFFER)"](#<buffer  *Compiler Input*>)
  byte-compile-from-buffer(#<buffer  *Compiler Input*>)
  byte-compile-file("/home/jonas/.emacs.d/lib/sx/sx-babel.el" nil)
  byte-recompile-file("/home/jonas/.emacs.d/lib/sx/sx-babel.el" t 0)
  #[0 "\303\242\205\331\300\303\242@\240\210\311\312\300\242\"\210\313\300\242!\211\203\317\211@\314\300\242\"\315!\203Z\316\235\204\307\317H\320=\204\307\321!\204\307\301\242\203O\301\242\317=\204O\322\323\324Q!\203\307\303\211\242C\244\240\210\202\307\325\"\203\307\326!\203\307\325\327\"\204\307\330!\204\307\331!\230\204\307\332\302\301\242#\211\333=\203\223\304\211\242T\240\210\202\250\211\334=\203\242\306\211\242T\240\210\202\250\305\211\242T\240\210\210\204\264\311\312\300\242\"\210\310\242\300\242=\204\307\310\300\242\240\210\307\211\242T\240\210\210A\266\202\202\210\303\211\242A\240\210\202\207" [("/home/jonas/.emacs.d/lib/sx") (0) t (("/home/jonas/.emacs.d/lib/sx")) (1) (0) (1) (1) ("/home/jonas/.emacs.d/lib/sx") message "Checking %s..." directory-files expand-file-name file-directory-p ("RCS" "CVS") 0 46 file-symlink-p y-or-n-p "Check " "? " string-match file-readable-p "\\`\\.#" auto-save-file-name-p file-name-nondirectory byte-recompile-file no-byte-compile t emacs-lisp-file-regexp dir-locals-file noninteractive] 7]()
  byte-recompile-directory("." 0 t)
  eval((byte-recompile-directory "." 0 t))
  command-line-1(("-L" "." "-L" "../markdown-mode" "--eval" "(byte-recompile-directory \".\" 0 t)" "--eval" "(message \"*sx-temp*: %s\" *sx-temp*)"))
  command-line()
  normal-top-level()
vermiculus commented 8 years ago

Awesome! Try out that patch.

tarsius commented 8 years ago

That worked. Thanks!