yuuji / reloader.el
Created at Tue Oct 22 12:08:15 JST 2019
reloader.el
Raw
;;                                                                              
;; Reload init files (defaults to .emacs, .emacs.el, .emacs.d/init.el)          
;;                                                                              

(defvar reloader-default-init-files
  '("~/.emacs" "~/.emacs.el" "~/.emacs.d/init.el")
  "Default target files for reloading.                                          
C-u M-x reloader-reload causes prompt for loading file.")

(defun reloader-reload (arg)
  (interactive "P")
  (let ((files (if arg (list (read-file-name "Reload file: "))
                 reloader-default-init-files))
        f)
    (while files
      (setq f (car files))
      (and (stringp f)
           (file-readable-p f)
           (progn
             (message "Reloading %s" f)
             (load-file f)))
      (setq files (cdr files)))))


(define-key global-map "\C-cr" 'reloader-reload)
(provide 'reloader)