emacscollective / auto-compile

Automatically compile Emacs Lisp libraries
GNU General Public License v3.0
172 stars 16 forks source link

Problem with auto-compile and custom modeline. #3

Closed mpontus closed 11 years ago

mpontus commented 11 years ago

If symbol specified in auto-complete-mode-line does not exist in mode-line-format, next time auto-compile minor mode is enabled, errors will start occur inside several hooks. This will prevent user from saving the buffer or accessing the minibuffer.

Furthermore debugger doesn't show up at this level and error message lacks sufficient information to easily locate the source of a problem: "Error in post-command-hook (auto-compile-on-save-mode-check-buffers): (wrong-type-argument consp nil)".

In order to reproduce the error start emacs-live using default configuration and having foundation-pack enabled. Then evaluate (delq 'mode-line-modified mode-line-format) and try to open any emacs lisp file.

tarsius commented 11 years ago

As a quick fix set auto-compile-use-mode-line to nil /before/ loading auto-compile. Even better set it to a symbol that is part of your mode-line-format.

I was able to reproduce this error and will try to set the default value of auto-compile-use-mode-line based on what is actually in mode-line-format and also make sure no error occurs if that fails.

tarsius commented 11 years ago

Are you using powerline.el? What package removes mode-line-modified from mode-line-format?

mpontus commented 11 years ago

That's right, first time I experienced this issue I was trying on powerline. Shortly after I claimed it broken but until I installed following setup: http://amitp.blogspot.ru/2011/08/emacs-custom-mode-line.html Since this mode-line doesn't use default symbols to represent modification status, problem reminded of itself once again.

I'm very happy that I was able to finally get to it's roots. In case anyone as inexperienced as me will stumble upon this page looking for a solution, I will try to recall as many details as I can that allowed me to pass this challenge:

First I adopted snippet from this page: http://lists.gnu.org/archive/html/emacs-devel/2010-07/msg01416.html

(defadvice auto-compile-on-save-mode-check-buffers  (around intercept activate)
  (condition-case err
      ad-do-it
    ((debug error) (signal (car err) (cdr err)))))

Don't forget to turn off debug on error afterwards. I might be mistaken now but it took me several attempts to receive different error message. I remember that commenting out ad-do-it or redefining auto-compile-on-save-mode-check-buffers has brought me some success and name in subject changed to auto-compile-mode. It's also worth trying to edebug-on-entry.

Previous function did not allow me to peek at it's source, and occasional backtraces that somehow got into my Messages, were bytecode mostly. I might have got useful backtrace after instrumenting this function or had to trace it manually

From here on out I don't remember much details, only that at some point I was able to reproduce error by eval-ing from top level, it was the first time I received clean backtrace, that unquestionably pointed on the source of a trouble.

To sum up, I was trying things at random in conditions i did not understand, I wish I had made more elaborate notes, but right now my sluggish explanation is all I can recollect.

tarsius commented 11 years ago

The proper workaround for this particular error is to set auto-compile-use-mode-line to nil. The root cause is that this code ends up being run: ( push 'mode-line-auto-compile nil).

Sorry for all the troble this caused, it's a nasty bug. Next time ask sooner. I was able to get a backtrace with emacs --debug-init.

Will push a fix when i get back from work.

tarsius commented 11 years ago

Using advice, condition-case and entering debugger explicitly is a useful tip.

mpontus commented 11 years ago

I have just noticed an update pushed into emacs-live and I really appreciate your timely and quality work. I didn't mean to sound as if this experience was much trouble for me, it was fun and rewarding. I didn't try this logical approach you propose as I still lack in ability to match conditions to results. I'm looking forward to the day when I will personally find the best use for your code, so far I picked up a few patterns and they will stick with me for a while.