summaryrefslogtreecommitdiffstats
path: root/.config/emacs/early-init.el
diff options
context:
space:
mode:
Diffstat (limited to '.config/emacs/early-init.el')
-rw-r--r--.config/emacs/early-init.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/.config/emacs/early-init.el b/.config/emacs/early-init.el
new file mode 100644
index 0000000..056d4dc
--- /dev/null
+++ b/.config/emacs/early-init.el
@@ -0,0 +1,33 @@
+(defvar my/default-file-name-handler-alist file-name-handler-alist)
+
+(defun my/set-max-gc-cons-threshold ()
+ (setq gc-cons-threshold most-positive-fixnum)) ; 2^61 bytes
+(defun my/set-default-gc-cons-threshold ()
+ (run-at-time 1 nil
+ (lambda () (setq gc-cons-threshold 16777216)))) ; 16 Mb
+
+(defun my/erase-file-name-handler-alist ()
+ (setq file-name-handler-alist nil))
+(defun my/restore-file-name-handler-alist ()
+ (setq file-name-handler-alist my/default-file-name-handler-alist))
+
+(my/set-max-gc-cons-threshold)
+(my/erase-file-name-handler-alist)
+(add-hook 'emacs-startup-hook 'my/set-default-gc-cons-threshold)
+(add-hook 'emacs-startup-hook 'my/restore-file-name-handler-alist)
+
+(defun my/ad-timestamp-message (FORMAT-STRING &rest args)
+ "Advice to run before `message' that prepends a timestamp to each message.
+Activate this advice with:
+ (advice-add 'message :before 'my/ad-timestamp-message)
+Deactivate this advice with:
+ (advice-remove 'message 'my/ad-timestamp-message)"
+ (if message-log-max
+ (let ((deactivate-mark nil)
+ (inhibit-read-only t))
+ (with-current-buffer "*Messages*"
+ (goto-char (point-max))
+ (if (not (bolp))
+ (newline))
+ (insert (format-time-string "[%F %T.%3N] "))))))
+(advice-add 'message :before 'my/ad-timestamp-message)