Refactor out map.el usage

After some profiling, it turns out map-put and map-delete are 5-7x
slower (more on Emacs 25) than delq, setf/alist-get and add-to-list for
small lists (under 250 items), which is exactly how I've been using
them.

The only caveat is alist-get's signature is different on Emacs 25, thus
a polyfill is necessary in core-lib.
This commit is contained in:
Henrik Lissner 2018-06-23 16:48:58 +02:00
parent f602a1f607
commit f6dc6ac74e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
29 changed files with 177 additions and 146 deletions

View file

@ -30,7 +30,8 @@ stored in `persp-save-dir'.")
;; particularly useful for the `+workspace/restart-emacs-then-restore' command.
(defun +workspaces-restore-last-session (&rest _)
(add-hook 'emacs-startup-hook #'+workspace/load-session 'append))
(map-put command-switch-alist "--restore" #'+workspaces-restore-last-session)
(add-to-list 'command-switch-alist (cons "--restore" #'+workspaces-restore-last-session))
;;
;; Plugins
@ -41,7 +42,9 @@ stored in `persp-save-dir'.")
:init
(defun +workspaces|init ()
;; Remove default buffer predicate so persp-mode can put in its own
(setq default-frame-alist (map-delete default-frame-alist 'buffer-predicate))
(setq default-frame-alist
(delq (assq 'buffer-predicate default-frame-alist)
default-frame-alist))
(add-hook 'after-make-frame-functions #'+workspaces|init-frame)
(require 'persp-mode)
(unless (daemonp)