Delegate compile defuns to scripts

This commit is contained in:
Henrik Lissner 2015-06-20 22:23:58 +02:00
parent 3b79d71609
commit 53bd6efa54

View file

@ -1,41 +1,33 @@
;;; defuns-compile.el ;;; defuns-compile.el
(eval-when-compile (require 'f)) ;; (eval-when-compile (require 'core))
(defun narf--compile-important-dirs ()
(append (list narf-core-dir narf-contrib-dir)
(list (concat narf-modules-dir "lib/")
(concat narf-core-dir "lib/"))
(list narf-modules-dir narf-private-dir)))
;;;###autoload ;;;###autoload
(defun narf/is-compilable-p () (defun narf/is-compilable-p ()
(let ((file-name (buffer-file-name))) (let ((file-name (buffer-file-name)))
(--any? (f-child-of? file-name it) (narf--compile-important-dirs)))) ;; TODO Detect init.el and init-load-path.el
(--any? (f-child-of? file-name it)
(append (list narf-core-dir narf-contrib-dir)
(list (concat narf-modules-dir "lib/")
(concat narf-core-dir "lib/"))
(list narf-modules-dir narf-private-dir)))))
;;;###autoload (autoload 'narf:compile-el "defuns-compile" nil t) ;;;###autoload (autoload 'narf:compile-el "defuns-compile" nil t)
(evil-define-command narf:compile-el (&optional bang) (evil-define-command narf:compile-el (&optional bang)
:repeat nil :repeat nil
(interactive "<!>") (interactive "<!>")
(when (eq major-mode 'emacs-lisp-mode) (byte-recompile-file (f-expand "init.el" narf-emacs-dir) nil 0)
(byte-recompile-file (f-expand "core.el" narf-core-dir) t 0) (byte-recompile-file (f-expand "init-load-path.el" narf-emacs-dir) nil 0)
(byte-recompile-file (f-expand "core-vars.el" narf-core-dir) t 0) (byte-recompile-file (f-expand "core.el" narf-core-dir) t 0)
(byte-recompile-file (f-expand "core-defuns.el" narf-core-dir) t 0) (if (and (eq major-mode 'emacs-lisp-mode) (not bang))
(if (not bang) (byte-recompile-file (buffer-file-name) t 0)
(byte-recompile-file (buffer-file-name) t 0) (load (concat narf-script-dir "byte-compile.el"))))
(byte-recompile-file (f-expand "init-load-path.el" narf-emacs-dir) nil 0)
(byte-recompile-file (f-expand "init.el" narf-emacs-dir) nil 0)
(dolist (dir (narf--compile-important-dirs))
(byte-recompile-directory dir 0 nil)))))
;;;###autoload (autoload 'narf:compile-autoloads "defuns-compile" nil t) ;;;###autoload (autoload 'narf:compile-autoloads "defuns-compile" nil t)
(evil-define-command narf:compile-autoloads (&optional bang) (evil-define-command narf:compile-autoloads (&optional bang)
:repeat nil :repeat nil
(interactive "<!>") (interactive "<!>")
(defvar generated-autoload-file (expand-file-name "autoloads.el" narf-core-dir)) (load (concat narf-script-dir "generate-autoloads.el")))
(when (and bang (file-exists-p generated-autoload-file))
(delete-file generated-autoload-file))
(apply #'update-directory-autoloads (narf--compile-important-dirs)))
(provide 'defuns-compile) (provide 'defuns-compile)
;;; defuns-compile.el ends here ;;; defuns-compile.el ends here