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

@ -12,7 +12,7 @@
;; Like persistent-soft, caches assume a 2-tier structure, where all caches are ;; Like persistent-soft, caches assume a 2-tier structure, where all caches are
;; namespaced by location. ;; namespaced by location.
(defvar doom-cache-alists () (defvar doom-cache-alists '(t)
"An alist of alists, containing lists of variables for the doom cache library "An alist of alists, containing lists of variables for the doom cache library
to persist across Emacs sessions.") to persist across Emacs sessions.")
@ -24,7 +24,7 @@ name under `pcache-directory' (by default a subdirectory under
(defun doom|save-persistent-cache () (defun doom|save-persistent-cache ()
"Hook to run when an Emacs session is killed. Saves all persisted variables "Hook to run when an Emacs session is killed. Saves all persisted variables
listed in `doom-cache-alists' to files." listed in `doom-cache-alists' to files."
(dolist (alist doom-cache-alists) (dolist (alist (butlast doom-cache-alists 1))
(cl-loop with key = (car alist) (cl-loop with key = (car alist)
for var in (cdr alist) for var in (cdr alist)
if (symbol-value var) if (symbol-value var)
@ -54,7 +54,7 @@ Warning: this is incompatible with buffer-local variables."
(dolist (var variables) (dolist (var variables)
(when (doom-cache-exists var location) (when (doom-cache-exists var location)
(set var (doom-cache-get var location)))) (set var (doom-cache-get var location))))
(map-put doom-cache-alists location (setf (alist-get location doom-cache-alists)
(append variables (cdr (assq location doom-cache-alists))))) (append variables (cdr (assq location doom-cache-alists)))))
;;;###autoload ;;;###autoload
@ -63,10 +63,11 @@ Warning: this is incompatible with buffer-local variables."
`doom-cache-alists', thus preventing them from being saved between sessions. `doom-cache-alists', thus preventing them from being saved between sessions.
Does not affect the actual variables themselves or their values." Does not affect the actual variables themselves or their values."
(if variables (if variables
(map-put doom-cache-alists location (setf (alist-get location doom-cache-alists)
(cl-set-difference (cdr (assq location doom-cache-alists)) (cl-set-difference (cdr (assq location doom-cache-alists))
variables)) variables))
(map-delete doom-cache-alists location))) (delq (assq location doom-cache-alists)
doom-cache-alists)))
;;;###autoload ;;;###autoload
(defun doom-cache-get (key &optional location) (defun doom-cache-get (key &optional location)

View file

@ -345,7 +345,7 @@ example; the package name can be omitted)."
(package-install name)) (package-install name))
(if (not (package-installed-p name)) (if (not (package-installed-p name))
(doom--delete-package-files name) (doom--delete-package-files name)
(map-put doom-packages name plist) (setf (alist-get name alist) plist)
name))) name)))
;;;###autoload ;;;###autoload
@ -388,9 +388,10 @@ package.el as appropriate."
(unless (package-installed-p name) (unless (package-installed-p name)
(user-error "%s isn't installed" name)) (user-error "%s isn't installed" name))
(let ((inhibit-message (not doom-debug-mode)) (let ((inhibit-message (not doom-debug-mode))
(spec (assq name quelpa-cache))
quelpa-p) quelpa-p)
(when (assq name quelpa-cache) (when spec
(setq quelpa-cache (map-delete quelpa-cache name)) (setq quelpa-cache (delq spec quelpa-cache))
(quelpa-save-cache) (quelpa-save-cache)
(setq quelpa-p t)) (setq quelpa-p t))
(package-delete (cadr (assq name package-alist)) force-p) (package-delete (cadr (assq name package-alist)) force-p)
@ -439,11 +440,11 @@ calls."
"Update `quelpa-cache' upon a successful `package-delete'." "Update `quelpa-cache' upon a successful `package-delete'."
(doom-initialize-packages) (doom-initialize-packages)
(let ((name (package-desc-name desc))) (let ((name (package-desc-name desc)))
(when (and (not (package-installed-p name)) (unless (package-installed-p name)
(assq name quelpa-cache)) (when-let* ((spec (assq name quelpa-cache)))
(setq quelpa-cache (map-delete quelpa-cache name)) (setq quelpa-cache (delq spec quelpa-cache))
(quelpa-save-cache) (quelpa-save-cache)
(doom--delete-package-files name)))) (doom--delete-package-files name)))))
;; ;;

View file

@ -78,8 +78,8 @@ BODY will be run when this dispatcher is called."
(append (append
(when aliases (when aliases
`((dolist (alias ',aliases) `((dolist (alias ',aliases)
(map-put doom--dispatch-alias-alist alias ',cmd)))) (setf (alist-get alias doom--dispatch-alias-alist) ',cmd))))
`((map-put doom--dispatch-command-alist ',cmd `((setf (alist-get ',cmd doom--dispatch-command-alist)
(list :desc ,docstring (list :desc ,docstring
:body (lambda (args) ,form)))))))) :body (lambda (args) ,form))))))))

View file

@ -3,7 +3,6 @@
;; Built in packages we use a lot of ;; Built in packages we use a lot of
(require 'subr-x) (require 'subr-x)
(require 'cl-lib) (require 'cl-lib)
(require 'map)
(eval-and-compile (eval-and-compile
(unless EMACS26+ (unless EMACS26+
@ -11,7 +10,23 @@
;; if-let and when-let are deprecated in Emacs 26+ in favor of their ;; if-let and when-let are deprecated in Emacs 26+ in favor of their
;; if-let* variants, so we alias them for 25 users. ;; if-let* variants, so we alias them for 25 users.
(defalias 'if-let* #'if-let) (defalias 'if-let* #'if-let)
(defalias 'when-let* #'when-let)))) (defalias 'when-let* #'when-let)
;; `alist-get' doesn't have its 5th argument before Emacs 26
(defun doom*alist-get (key alist &optional default remove testfn)
"Return the value associated with KEY in ALIST.
If KEY is not found in ALIST, return DEFAULT.
Use TESTFN to lookup in the alist if non-nil. Otherwise, use `assq'.
This is a generalized variable suitable for use with `setf'.
When using it to set a value, optional argument REMOVE non-nil
means to remove KEY from ALIST if the new value is `eql' to DEFAULT."
(ignore remove) ;;Silence byte-compiler.
(let ((x (if (not testfn)
(assq key alist)
(assoc key alist testfn))))
(if x (cdr x) default)))
(advice-add #'alist-get :override #'doom*alist-get))))
;; ;;
@ -402,7 +417,7 @@ The available conditions are:
collect `(add-hook ',hook #',hook-name)) collect `(add-hook ',hook #',hook-name))
`((add-hook 'after-change-major-mode-hook #',hook-name)))))) `((add-hook 'after-change-major-mode-hook #',hook-name))))))
(match (match
`(map-put doom-auto-minor-mode-alist ,match ',mode)) `(add-to-list 'doom-auto-minor-mode-alist '(,match . ,mode)))
((user-error "Invalid `associate!' rules for mode [%s] (:modes %s :match %s :files %s :when %s)" ((user-error "Invalid `associate!' rules for mode [%s] (:modes %s :match %s :files %s :when %s)"
mode modes match files when))))) mode modes match files when)))))

View file

@ -35,8 +35,6 @@ A warning will be put out if these deprecated modules are used.")
session of Dooming. Will noop if used more than once, unless FORCE-P is session of Dooming. Will noop if used more than once, unless FORCE-P is
non-nil." non-nil."
(when (or force-p (not doom-init-modules-p)) (when (or force-p (not doom-init-modules-p))
;; Set `doom-init-modules-p' early, so `doom-pre-init-hook' won't infinitely
;; recurse by accident if any of them need `doom-initialize-modules'.
(setq doom-init-modules-p t) (setq doom-init-modules-p t)
(when doom-private-dir (when doom-private-dir
(condition-case e (condition-case e
@ -184,7 +182,7 @@ non-nil, return paths of possible modules, activated or otherwise."
;; ;;
;; This will load X on the first invokation of `find-file-hook' (then it will ;; This will load X on the first invokation of `find-file-hook' (then it will
;; remove itself from the hook/function). ;; remove itself from the hook/function).
(defvar doom--deferred-packages-alist ()) (defvar doom--deferred-packages-alist '(t))
(after! use-package-core (after! use-package-core
(add-to-list 'use-package-deferring-keywords :after-call nil #'eq) (add-to-list 'use-package-deferring-keywords :after-call nil #'eq)
(setq use-package-keywords (setq use-package-keywords
@ -208,15 +206,19 @@ non-nil, return paths of possible modules, activated or otherwise."
(if (functionp hook) (if (functionp hook)
(advice-remove hook #',fn) (advice-remove hook #',fn)
(remove-hook hook #',fn))) (remove-hook hook #',fn)))
(map-delete doom--deferred-packages-alist ',name) (delq (assq ',name doom--deferred-packages-alist)
doom--deferred-packages-alist)
(fmakunbound ',fn)))) (fmakunbound ',fn))))
(cl-loop for hook in hooks (let (forms)
collect (if (functionp hook) (dolist (hook hooks forms)
(push (if (functionp hook)
`(advice-add #',hook :before #',fn) `(advice-add #',hook :before #',fn)
`(add-hook ',hook #',fn))) `(add-hook ',hook #',fn))
`((map-put doom--deferred-packages-alist forms)))
',name `((unless (assq ',name doom--deferred-packages-alist)
'(,@hooks ,@(cdr (assq name doom--deferred-packages-alist))))) (push '(,name) doom--deferred-packages-alist))
(nconc (assq ',name doom--deferred-packages-alist)
'(,@hooks)))
(use-package-process-keywords name rest state)))))) (use-package-process-keywords name rest state))))))

View file

@ -222,8 +222,8 @@ elsewhere."
doom-private-dir) doom-private-dir)
(setq plist (plist-put plist :private t))) (setq plist (plist-put plist :private t)))
`(progn `(progn
,(if pkg-pin `(map-put package-pinned-packages ',name ,pkg-pin)) ,(if pkg-pin `(setf (alist-get ',name package-pinned-packages) ,pkg-pin))
(map-put doom-packages ',name ',plist) (setf (alist-get ',name doom-packages) ',plist)
(not (memq ',name doom-disabled-packages))))) (not (memq ',name doom-disabled-packages)))))
(defmacro packages! (&rest packages) (defmacro packages! (&rest packages)

View file

@ -67,7 +67,9 @@ Also see `doom-before-switch-buffer-hook'.")
enable-recursive-minibuffers nil enable-recursive-minibuffers nil
frame-inhibit-implied-resize t frame-inhibit-implied-resize t
;; remove continuation arrow on right fringe ;; remove continuation arrow on right fringe
fringe-indicator-alist (map-delete fringe-indicator-alist 'continuation) fringe-indicator-alist
(delq (assq 'continuation fringe-indicator-alist)
fringe-indicator-alist)
highlight-nonselected-windows nil highlight-nonselected-windows nil
image-animate-loop t image-animate-loop t
indicate-buffer-boundaries nil indicate-buffer-boundaries nil
@ -126,13 +128,13 @@ Also see `doom-before-switch-buffer-hook'.")
(format "%s modeline segment" name)))) (format "%s modeline segment" name))))
(cond ((and (symbolp (car body)) (cond ((and (symbolp (car body))
(not (cdr body))) (not (cdr body)))
(map-put doom--modeline-var-alist name (car body)) (add-to-list 'doom--modeline-var-alist (cons name (car body)))
`(map-put doom--modeline-var-alist ',name ',(car body))) `(add-to-list 'doom--modeline-var-alist (cons ',name ',(car body))))
(t (t
(map-put doom--modeline-fn-alist name sym) (add-to-list 'doom--modeline-fn-alist (cons name sym))
`(progn `(progn
(fset ',sym (lambda () ,docstring ,@body)) (fset ',sym (lambda () ,docstring ,@body))
(map-put doom--modeline-fn-alist ',name ',sym) (add-to-list 'doom--modeline-fn-alist (cons ',name ',sym))
,(unless (bound-and-true-p byte-compile-current-file) ,(unless (bound-and-true-p byte-compile-current-file)
`(let (byte-compile-warnings) `(let (byte-compile-warnings)
(byte-compile #',sym)))))))) (byte-compile #',sym))))))))
@ -549,7 +551,7 @@ frame's window-system, the theme will be reloaded.")
(custom-set-faces (custom-set-faces
(when (fontp doom-font) (when (fontp doom-font)
(let ((xlfd (font-xlfd-name doom-font))) (let ((xlfd (font-xlfd-name doom-font)))
(map-put default-frame-alist 'font xlfd) (add-to-list 'default-frame-alist (cons 'font xlfd))
`(fixed-pitch ((t (:font ,xlfd)))))) `(fixed-pitch ((t (:font ,xlfd))))))
(when (fontp doom-variable-pitch-font) (when (fontp doom-variable-pitch-font)
`(variable-pitch ((t (:font ,(font-xlfd-name doom-variable-pitch-font)))))) `(variable-pitch ((t (:font ,(font-xlfd-name doom-variable-pitch-font))))))
@ -712,7 +714,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(defun doom|init-ui () (defun doom|init-ui ()
"Initialize Doom's user interface by applying all its advice and hooks." "Initialize Doom's user interface by applying all its advice and hooks."
;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers. ;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers.
(map-put default-frame-alist 'buffer-predicate #'doom-buffer-frame-predicate) (add-to-list 'default-frame-alist (cons 'buffer-predicate #'doom-buffer-frame-predicate))
;; Switch to `doom-fallback-buffer' if on last real buffer ;; Switch to `doom-fallback-buffer' if on last real buffer
(advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe) (advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe)
;; Don't kill the fallback buffer ;; Don't kill the fallback buffer

View file

@ -12,16 +12,17 @@
(defun +email--mark-seen (docid msg target) (defun +email--mark-seen (docid msg target)
(mu4e~proc-move docid (mu4e~mark-check-target target) "+S-u-N")) (mu4e~proc-move docid (mu4e~mark-check-target target) "+S-u-N"))
(map-delete mu4e-marks 'delete) (delq (assq 'delete mu4e-marks) mu4e-marks)
(map-put mu4e-marks 'trash (setf (alist-get 'trash mu4e-marks)
(list :char '("d" . "") (list :char '("d" . "")
:prompt "dtrash" :prompt "dtrash"
:dyn-target (lambda (_target msg) (mu4e-get-trash-folder msg)) :dyn-target (lambda (_target msg) (mu4e-get-trash-folder msg))
:action #'+email--mark-seen)) :action #'+email--mark-seen)
;; Refile will be my "archive" function. ;; Refile will be my "archive" function.
(map-put mu4e-marks 'refile (alist-get 'refile mu4e-marks)
(list :char '("r" . "") :prompt "refile" (list :char '("d" . "")
:show-target (lambda (_target) "archive") :prompt "dtrash"
:dyn-target (lambda (_target msg) (mu4e-get-trash-folder msg))
:action #'+email--mark-seen)) :action #'+email--mark-seen))
;; This hook correctly modifies gmail flags on emails when they are marked. ;; This hook correctly modifies gmail flags on emails when they are marked.

View file

@ -28,7 +28,7 @@
:config :config
(helm-mode +1) (helm-mode +1)
;; helm is too heavy for find-file-at-point ;; helm is too heavy for find-file-at-point
(map-put helm-completing-read-handlers-alist 'find-file-at-point nil)) (add-to-list 'helm-completing-read-handlers-alist (cons #'find-file-at-point nil)))
(def-package! helm (def-package! helm

View file

@ -191,6 +191,7 @@ immediately runs it on the current candidate (ending the ivy session)."
(internal-border-width . 10))) (internal-border-width . 10)))
;; ... let's do it manually ;; ... let's do it manually
(unless (assq 'ivy-posframe-display-at-frame-bottom-left ivy-display-functions-props)
(dolist (fn (list 'ivy-posframe-display-at-frame-bottom-left (dolist (fn (list 'ivy-posframe-display-at-frame-bottom-left
'ivy-posframe-display-at-frame-center 'ivy-posframe-display-at-frame-center
'ivy-posframe-display-at-point 'ivy-posframe-display-at-point
@ -199,13 +200,12 @@ immediately runs it on the current candidate (ending the ivy session)."
'ivy-posframe-display-at-window-bottom-left 'ivy-posframe-display-at-window-bottom-left
'ivy-posframe-display-at-window-center 'ivy-posframe-display-at-window-center
'+ivy-display-at-frame-center-near-bottom)) '+ivy-display-at-frame-center-near-bottom))
(map-put ivy-display-functions-props fn '(:cleanup ivy-posframe-cleanup))) (push (cons fn '(:cleanup ivy-posframe-cleanup)) ivy-display-functions-props))
(push '(t . +ivy-display-at-frame-center-near-bottom) ivy-display-functions-props))
(map-put ivy-display-functions-alist 't '+ivy-display-at-frame-center-near-bottom)
;; posframe doesn't work well with async sources ;; posframe doesn't work well with async sources
(dolist (fn '(swiper counsel-rg counsel-ag counsel-pt counsel-grep counsel-git-grep)) (dolist (fn '(swiper counsel-rg counsel-ag counsel-pt counsel-grep counsel-git-grep))
(map-put ivy-display-functions-alist fn nil))) (setf (alist-get fn ivy-display-functions-alist) nil)))
(def-package! flx (def-package! flx

View file

@ -7,7 +7,8 @@
(signal 'wrong-number-of-arguments (list 'even (length aliases)))) (signal 'wrong-number-of-arguments (list 'even (length aliases))))
(after! eshell (after! eshell
(while aliases (while aliases
(map-put +eshell-aliases (pop aliases) (list (pop aliases)))) (setf (alist-get (pop aliases) +eshell-aliases nil nil #'equal)
(pop aliases)))
(when (boundp 'eshell-command-aliases-list) (when (boundp 'eshell-command-aliases-list)
(if +eshell--default-aliases (if +eshell--default-aliases
(setq eshell-command-aliases-list (setq eshell-command-aliases-list

View file

@ -231,8 +231,8 @@ variable for an explanation of the defaults (in comments). See
(cons (format "(%s " (or (read-string "(") "")) ")")) (cons (format "(%s " (or (read-string "(") "")) ")"))
;; Add escaped-sequence support to embrace ;; Add escaped-sequence support to embrace
(map-put (default-value 'embrace--pairs-list) (setf (alist-get ?\\ (default-value 'embrace--pairs-list))
?\\ (make-embrace-pair-struct (make-embrace-pair-struct
:key ?\\ :key ?\\
:read-function #'+evil--embrace-escaped :read-function #'+evil--embrace-escaped
:left-regexp "\\[[{(]" :left-regexp "\\[[{(]"
@ -332,8 +332,7 @@ the new algorithm is confusing, like in python or ruby."
;; Add custom commands to whitelisted commands ;; Add custom commands to whitelisted commands
(dolist (fn '(doom/backward-to-bol-or-indent doom/forward-to-last-non-comment-or-eol (dolist (fn '(doom/backward-to-bol-or-indent doom/forward-to-last-non-comment-or-eol
doom/backward-kill-to-bol-and-indent)) doom/backward-kill-to-bol-and-indent))
(map-put evil-mc-custom-known-commands (add-to-list 'evil-mc-custom-known-commands `(,fn (:default . evil-mc-execute-default-call))))
fn '((:default . evil-mc-execute-default-call))))
;; Activate evil-mc cursors upon switching to insert mode ;; Activate evil-mc cursors upon switching to insert mode
(defun +evil-mc|resume-cursors () (setq evil-mc-frozen nil)) (defun +evil-mc|resume-cursors () (setq evil-mc-frozen nil))

View file

@ -2,7 +2,9 @@
(defun +file-templates--set (pred plist) (defun +file-templates--set (pred plist)
(if (null (car-safe plist)) (if (null (car-safe plist))
(setq +file-templates-alist (map-delete +file-templates-alist pred)) (setq +file-templates-alist
(delq (assoc pred +file-templates-alist)
+file-templates-alist))
(push `(,pred ,@plist) +file-templates-alist))) (push `(,pred ,@plist) +file-templates-alist)))
;;;###autodef ;;;###autodef

View file

@ -9,7 +9,7 @@ DOCSET (a string).
See `devdocs-alist' for the defaults. " See `devdocs-alist' for the defaults. "
(after! (:when (boundp 'devdocs-alist)) (after! (:when (boundp 'devdocs-alist))
(dolist (mode (doom-enlist modes)) (dolist (mode (doom-enlist modes))
(map-put devdocs-alist mode docset)))) (setf (alist-get mode devdocs-alist) docset))))
;;;###autoload ;;;###autoload
(def-setting! :devdocs (modes docset) (def-setting! :devdocs (modes docset)

View file

@ -72,7 +72,7 @@ properties:
"Search on: " "Search on: "
(mapcar #'car +lookup-provider-url-alist) (mapcar #'car +lookup-provider-url-alist)
nil t))) nil t)))
(map-put +lookup--last-provider key provider) (setf (alist-get +lookup--last-provider key) provider)
provider)))) provider))))
(defun +lookup--symbol-or-region (&optional initial) (defun +lookup--symbol-or-region (&optional initial)
@ -318,7 +318,9 @@ for the provider."
(user-error "The search query is empty")) (user-error "The search query is empty"))
(funcall +lookup-open-url-fn (format url (url-encode-url search)))) (funcall +lookup-open-url-fn (format url (url-encode-url search))))
(error (error
(map-delete +lookup--last-provider major-mode) (setq +lookup--last-provider
(delq (assq major-mode +lookup--last-provider)
+lookup--last-provider))
(signal (car e) (cdr e))))) (signal (car e) (cdr e)))))
;;;###autoload ;;;###autoload

View file

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

View file

@ -1,4 +1,4 @@
;;; lang/assembly/autoload.el -*- lexical-binding: t; -*- ;;; lang/assembly/autoload.el -*- lexical-binding: t; -*-
;;;###autoload ;;;###autoload
(map-put auto-mode-alist "\\.hax\\'" 'haxor-mode) (add-to-list 'auto-mode-alist '("\\.hax\\'" . haxor-mode))

View file

@ -83,8 +83,9 @@ compilation database is present in the project.")
+cc|fontify-constants)) +cc|fontify-constants))
;; Custom style, based off of linux ;; Custom style, based off of linux
(map-put c-style-alist "doom" (unless (assoc "doom" c-style-alist)
`((c-basic-offset . ,tab-width) (push '("doom"
(c-basic-offset . ,tab-width)
(c-comment-only-line-offset . 0) (c-comment-only-line-offset . 0)
(c-hanging-braces-alist (brace-list-open) (c-hanging-braces-alist (brace-list-open)
(brace-entry-open) (brace-entry-open)
@ -111,7 +112,8 @@ compilation database is present in the project.")
;; another level ;; another level
(access-label . -) (access-label . -)
(inclass +cc-c++-lineup-inclass +) (inclass +cc-c++-lineup-inclass +)
(label . 0)))) (label . 0)))
c-style-alist))
;;; Keybindings ;;; Keybindings
;; Disable electric keys because it interferes with smartparens and custom ;; Disable electric keys because it interferes with smartparens and custom

View file

@ -1,6 +1,7 @@
;;; lang/csharp/config.el -*- lexical-binding: t; -*- ;;; lang/csharp/config.el -*- lexical-binding: t; -*-
(map-put auto-mode-alist '"\\.shader$" 'dshader-mode) ; unity shaders ;; unity shaders
(add-to-list 'auto-mode-alist '("\\.shader$" . shader-mode))
(def-package! omnisharp (def-package! omnisharp

View file

@ -1,10 +1,10 @@
;;; lang/data/config.el -*- lexical-binding: t; -*- ;;; lang/data/config.el -*- lexical-binding: t; -*-
;; Built in plugins ;; Built in plugins
(dolist (spec '(("/sxhkdrc\\'" . conf-mode) (unless after-init-time
("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode) (push '("/sxhkdrc\\'" . conf-mode) auto-mode-alist)
("\\.plist\\'" . nxml-mode))) (push '("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode) auto-mode-alist)
(map-put auto-mode-alist (car spec) (cdr spec))) (push '("\\.plist\\'" . nxml-mode) auto-mode-alist))
(after! nxml-mode (after! nxml-mode
(set-company-backend! 'nxml-mode '(company-nxml company-yasnippet))) (set-company-backend! 'nxml-mode '(company-nxml company-yasnippet)))

View file

@ -5,7 +5,7 @@
"/rebar\\.config\\(?:\\.script\\)?$" "/rebar\\.config\\(?:\\.script\\)?$"
;; erlang configs ;; erlang configs
"/\\(?:app\\|sys\\)\\.config$")) "/\\(?:app\\|sys\\)\\.config$"))
(map-put auto-mode-alist regexp 'erlang-mode)) (add-to-list 'auto-mode-alist (cons regexp 'erlang-mode)))
(def-package! flycheck-rebar3 (def-package! flycheck-rebar3

View file

@ -31,7 +31,7 @@
("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode)) ("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode))
:init :init
(unless (featurep! :lang julia) (unless (featurep! :lang julia)
(map-put auto-mode-alist "\\.jl\'" 'ess-julia-mode)) (add-to-list 'auto-mode-alist '("\\.jl\\'" . ess-julia-mode)))
:config :config
(add-hook 'ess-mode-hook #'doom|enable-line-numbers) (add-hook 'ess-mode-hook #'doom|enable-line-numbers)
(setq ess-offset-continued 'straight (setq ess-offset-continued 'straight

View file

@ -66,7 +66,7 @@
magic-mode-regexp-match-limit t) magic-mode-regexp-match-limit t)
(progn (goto-char (match-beginning 1)) (progn (goto-char (match-beginning 1))
(not (sp-point-in-string-or-comment))))) (not (sp-point-in-string-or-comment)))))
(map-put magic-mode-alist #'+javascript-jsx-file-p 'rjsx-mode) (add-to-list 'magic-mode-alist '(+javascript-jsx-file-p . rjsx-mode))
:config :config
(set-electric! 'rjsx-mode :chars '(?\} ?\) ?. ?>)) (set-electric! 'rjsx-mode :chars '(?\} ?\) ?. ?>))
(add-hook! 'rjsx-mode-hook (add-hook! 'rjsx-mode-hook

View file

@ -75,33 +75,30 @@
(setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s") (setcar (cdr (assoc "Check" TeX-command-list)) "chktex -v6 %s")
;; Set a custom item indentation ;; Set a custom item indentation
(dolist (env '("itemize" "enumerate" "description")) (dolist (env '("itemize" "enumerate" "description"))
(map-put LaTeX-indent-environment-list (add-to-list 'LaTeX-indent-environment-list `(,env +latex/LaTeX-indent-item)))
env '(+latex/LaTeX-indent-item)))
;; ;;
;; Use Okular if the user says so. ;; Use Okular if the user says so.
(when (featurep! +okular) (when (featurep! +okular)
;; Configure Okular as viewer. Including a bug fix ;; Configure Okular as viewer. Including a bug fix
;; (https://bugs.kde.org/show_bug.cgi?id=373855) ;; (https://bugs.kde.org/show_bug.cgi?id=373855)
(map-put TeX-view-program-list (add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a"))))
"Okular" '(("okular --unique file:%o" (mode-io-correlate "#src:%n%a")))) (add-to-list 'TeX-view-program-selection '(output-pdf "Okular")))
(map-put TeX-view-program-list 'output-pdf '("Okular")))
;; Or Skim ;; Or Skim
(when (featurep! +skim) (when (featurep! +skim)
(map-put TeX-view-program-list (add-to-list 'TeX-view-program-list '("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b"))
"Skim" '("/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")) (add-to-list 'TeX-view-program-selection 'output-pdf '("Skim")))
(map-put TeX-view-program-selection 'output-pdf '("Skim")))
;; Or Zathura ;; Or Zathura
(when (featurep! +zathura) (when (featurep! +zathura)
(map-put TeX-view-program-selection 'output-pdf '("Zathura"))) (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura")))
;; Or PDF-tools, but only if the module is also loaded ;; Or PDF-tools, but only if the module is also loaded
(when (and (featurep! :tools pdf) (when (and (featurep! :tools pdf)
(featurep! +pdf-tools)) (featurep! +pdf-tools))
(map-put TeX-view-program-list "PDF Tools" '("TeX-pdf-tools-sync-view")) (add-to-list 'TeX-view-program-list ("PDF Tools" "TeX-pdf-tools-sync-view"))
(map-put TeX-view-program-selection 'output-pdf '("PDF Tools")) (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
;; Enable auto reverting the PDF document with PDF Tools ;; Enable auto reverting the PDF document with PDF Tools
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))) (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)))
@ -124,8 +121,8 @@
:init :init
(setq latex-preview-pane-multifile-mode 'auctex) (setq latex-preview-pane-multifile-mode 'auctex)
:config :config
(map-put TeX-view-program-list "preview-pane" '(latex-preview-pane-mode)) (add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode))
(map-put TeX-view-program-selection 'output-pdf '("preview-pane")) (add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane"))
(define-key! doc-view-mode-map (define-key! doc-view-mode-map
(kbd "ESC") #'delete-window (kbd "ESC") #'delete-window
"q" #'delete-window "q" #'delete-window

View file

@ -36,7 +36,7 @@ string). Stops at the first function to return non-nil.")
(or (cdr (assq lang +org-babel-mode-alist)) (or (cdr (assq lang +org-babel-mode-alist))
lang))) lang)))
nil t))) nil t)))
(map-put org-babel-load-languages lang t)) (add-to-list 'org-babel-load-languages (cons lang t)))
t))) t)))
(advice-add #'org-babel-confirm-evaluate :around #'+org*babel-lazy-load-library) (advice-add #'org-babel-confirm-evaluate :around #'+org*babel-lazy-load-library)

View file

@ -341,7 +341,7 @@ between the two."
(defun +org|setup-hacks () (defun +org|setup-hacks ()
"Getting org to behave." "Getting org to behave."
;; Don't open separate windows ;; Don't open separate windows
(map-put org-link-frame-setup 'file #'find-file) (setf (alist-get 'file org-link-frame-setup) #'find-file)
;; Let OS decide what to do with files when opened ;; Let OS decide what to do with files when opened
(setq org-file-apps (setq org-file-apps
`(("pdf" . default) `(("pdf" . default)

View file

@ -22,8 +22,8 @@
(setq sh-indent-after-continuation 'always) (setq sh-indent-after-continuation 'always)
;; recognize function names with dashes in them ;; recognize function names with dashes in them
(map-put sh-imenu-generic-expression (add-to-list 'sh-imenu-generic-expression
'sh '((nil "^\\s-*function\\s-+\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*\\(?:()\\)?" 1) '(sh (nil "^\\s-*function\\s-+\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*\\(?:()\\)?" 1)
(nil "^\\s-*\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*()" 1))) (nil "^\\s-*\\([[:alpha:]_-][[:alnum:]_-]*\\)\\s-*()" 1)))
;; `sh-set-shell' is chatty about setting up indentation rules ;; `sh-set-shell' is chatty about setting up indentation rules

View file

@ -21,11 +21,12 @@
:after-call (doom-before-switch-buffer after-find-file) :after-call (doom-before-switch-buffer after-find-file)
:config :config
;; Register missing indent variables ;; Register missing indent variables
(unless (assq 'mips-mode editorconfig-indentation-alist)
(setq editorconfig-indentation-alist (setq editorconfig-indentation-alist
(append '((mips-mode mips-tab-width) (append '((mips-mode mips-tab-width)
(haxor-mode haxor-tab-width) (haxor-mode haxor-tab-width)
(nasm-mode nasm-basic-offset)) (nasm-mode nasm-basic-offset))
editorconfig-indentation-alist)) editorconfig-indentation-alist)))
(defun doom*editorconfig-smart-detection (orig-fn &rest args) (defun doom*editorconfig-smart-detection (orig-fn &rest args)
"Retrieve the properties for the current file. If it doesn't have an "Retrieve the properties for the current file. If it doesn't have an
@ -51,7 +52,8 @@ extension, try to guess one."
;; editorconfig to ignore indentation there. I prefer dynamic indentation ;; editorconfig to ignore indentation there. I prefer dynamic indentation
;; support built into Emacs. ;; support built into Emacs.
(dolist (mode '(emacs-lisp-mode lisp-mode)) (dolist (mode '(emacs-lisp-mode lisp-mode))
(map-delete editorconfig-indentation-alist mode)) (delq (assq mode editorconfig-indentation-alist)
editorconfig-indentation-alist))
;; ;;
(editorconfig-mode +1)) (editorconfig-mode +1))

View file

@ -70,8 +70,8 @@ adjustment.")
window--sides-inhibit-check nil) window--sides-inhibit-check nil)
(+popup|cleanup-rules) (+popup|cleanup-rules)
(dolist (prop +popup-window-parameters) (dolist (prop +popup-window-parameters)
(setq window-persistent-parameters (delq (assq prop window-persistent-parameters)
(map-delete window-persistent-parameters prop)))))) window-persistent-parameters)))))
(define-minor-mode +popup-buffer-mode (define-minor-mode +popup-buffer-mode
"Minor mode for individual popup windows. "Minor mode for individual popup windows.