Functions to re-evaluate buffer/library with re-assigning `defvar` values.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 25 Aug 2016 20:30:31 +0300
changeset 1416 6f00eaa73a10
parent 1415 26553c2093b1
child 1417 920558cbf675
Functions to re-evaluate buffer/library with re-assigning `defvar` values.
.emacs-my
--- a/.emacs-my	Sat Aug 13 18:35:26 2016 +0300
+++ b/.emacs-my	Thu Aug 25 20:30:31 2016 +0300
@@ -81,6 +81,28 @@
     (setq debug-on-event lvl2)
     (setq debug-on-signal lvl2)))
 
+(defun my/eval-buffer ()
+  "Evaluate entire buffer with re-assigning values to `defvar' / `defcustom'.
+Useful during package development."
+  (interactive)
+  (save-excursion
+    (beginning-of-buffer)
+    (while (not (eobp))
+      (eval-defun nil)
+      (end-of-defun))))
+
+(defun my/load-library (library)
+  "Evaluate entire library with re-assigning values to `defvar' / `defcustom'.
+Useful during package development."
+  (interactive
+   (list (completing-read "Load library: "
+                          (apply-partially 'locate-file-completion-table
+                                           load-path
+                                           '("" ".el")))))
+  (with-temp-buffer
+    (insert-file-contents (locate-file library load-path '("" ".el")))
+    (my/eval-buffer)))
+
 (my-debug nil)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;