From 55870458e63cf973b85ae2479d25b96ab66cbd10 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 29 Jul 2018 19:14:50 +0200 Subject: [PATCH] Byte-compile mode-line segment :eval forms Byte-compiled function calls are ~10% faster than evalling quoted forms. --- modules/ui/modeline/autoload/settings.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/ui/modeline/autoload/settings.el b/modules/ui/modeline/autoload/settings.el index 2a27d6764..6adb01b46 100644 --- a/modules/ui/modeline/autoload/settings.el +++ b/modules/ui/modeline/autoload/settings.el @@ -23,14 +23,15 @@ keep them left and right aligned respectively." body) (macroexp-progn (if (not (keywordp (car rest))) - `((defvar-local ,name nil ,docstring) - (setq-default - ,name - ,(if (or (stringp (car rest)) - (memq (car (car-safe rest)) '(:eval :propertize))) - (car rest) - `(quote (:eval ,(macroexp-progn rest))))) - (put ',name 'risky-local-variable t)) + (append `((defvar-local ,name nil ,docstring) + (put ',name 'risky-local-variable t)) + (if (or (stringp (car rest)) + (memq (car (car-safe rest)) '(:eval :propertize))) + `((setq-default ,name ,(car rest))) + (let ((fn (intern (format "+modeline--%s" name)))) + `((fset ',fn (lambda () ,@rest)) + (byte-compile ',fn) + (setq-default ,name (quote (:eval (,fn)))))))) ;; isolate body (setq body rest) (while (keywordp (car body))