From: Eric M. L. <er...@si...> - 2003-05-06 11:27:26
|
>>> "Berndl, Klaus" <kla...@sd...> seems to think that: >>>Anyway, I didn't even realize that that was in there. I've read the >>>documentation, but I must have missed that step. Maybe it should happen >>>automatically the first time you start ECB. Is there any reason to NOT byte >>>compile the package? > [ ... ] > >>Here are several reasons I do not byte compile things: > >>1) Lazyness > >This reason is that one i understand best (no ironic!) :-) >But for this see answer to 5... > >>2) So it works in Emacs and XEmacs from one install area. > >If i have understood right the original poster thinks if there are >any reasons to byte-compile packages AFTER installation...but maybe i'm >wrong... > >>3) Work around byte compiler bugs > >Maybe...do not know... I have some image manipulation macros that cannot be byte compiled under XEmacs, as the bodies of those functions disappear. >>4) So you can debug with symbols > >Do not understand this...could you please explain this a little >bit more...AFAIK i can use edebug also very well with byte-compiled >elisp-code. Sometimes semantic will do this: Invalid Function: 1 but I have no idea where it is coming from. I then run with `debug-on-error' set to t. In this case, byte compilation makes the insides of functions illegible so I don't know how it got there. With the code loaded, I can often see and fix the given problem w/out starting edebug. >>5) So you can modify it regularly and not worry about forgetting to >> byte compile it again. > > >The following code prevents you to forget this because it autom. >byte-compiles if necessary. > >(BTW: IMHO such options like >mode-specific-after-save-buffer-hooks or any better mechanism >should be included in Emacs so a user can fast and easy specify >that changing his elisp-files causes autom. re-byte-compiling >at save time.) You should suggest it to the Emacs and XEmacs maintainers. They would probably respond that a making `after-save-hook' buffer-local and adding to it in the major-mode hook would be a better approach. That would cut down on looping during a save. >(defvar mode-specific-after-save-buffer-hooks nil > "Alist (MAJOR-MODE . HOOK) of after-save-buffer hooks >specific to major modes.") > >(defun run-mode-specific-after-save-buffer-hooks () > "Run hooks in `mode-specific-after-save-buffer-hooks' that match the >current buffer's major mode. To be put in `after-save-buffer-hooks'." > (let ((hooks mode-specific-after-save-buffer-hooks)) > (while hooks > (let ((hook (car hooks))) > (if (eq (car hook) major-mode) > (funcall (cdr hook)))) > (setq hooks (cdr hooks))))) > >(add-hook 'after-save-hook 'run-mode-specific-after-save-buffer-hooks) > >(defvar byte-compile-not-compile-regexp > "\\(\\.emacs\\)\\|\\(\\.gnus\\)\\|\\(subdirs\\.el\\)\\|\\(\\.custom\\.el\\)") > >(defun byte-compile-buffer () > "byte-compiles the current-buffer if it is an elisp-buffer" > (when (and (eq major-mode 'emacs-lisp-mode) > (not (string-match byte-compile-not-compile-regexp (buffer-name)))) > (require 'advice) > (ad-deactivate-all) > (unwind-protect > (emacs-lisp-byte-compile) > (ad-activate-all)))) > >(setq mode-specific-after-save-buffer-hooks > '((emacs-lisp-mode . byte-compile-buffer))) [ ... ] Nifty idea. I'd be worried about this being pretty slow. Perhaps an idle timer and quit-hook could help. Eric -- Eric Ludlam: za...@gn..., er...@si... Home: http://www.ludlam.net Siege: www.siege-engine.com Emacs: http://cedet.sourceforge.net GNU: www.gnu.org |