Macros now prefixed with @, instead of suffixed with !

This commit is contained in:
Henrik Lissner 2017-02-09 04:22:08 -05:00
parent ec694649db
commit 6c06aa0ce7
26 changed files with 265 additions and 247 deletions

View file

@ -111,18 +111,18 @@ fed to `doom/packages-delete'."
;;;###autoload
(defun doom-read-packages (&optional force-p nopackages)
"Parses your Emacs config to keep track of packages declared with `package!'
"Parses your Emacs config to keep track of packages declared with `@package'
in `doom-packages' and enabled modules in `doom-modules'."
(doom-initialize)
(when (or force-p (not doom-modules) (not doom-packages))
(setq doom-modules
(let (paths mode enabled-modules)
(--each (doom--scrape-sexps 'doom! (f-expand "init.el" doom-emacs-dir))
(--each (doom--scrape-sexps '@doom (f-expand "init.el" doom-emacs-dir))
(dolist (module it)
(cond ((keywordp module)
(setq mode module))
((not mode)
(error "Malformed doom! call: no namespace for %s" module))
(error "Malformed @doom call: no namespace for %s" module))
(t
(push (cons mode module) enabled-modules)))))
enabled-modules))
@ -131,8 +131,8 @@ in `doom-packages' and enabled modules in `doom-modules'."
(setq package-pinned-packages nil
doom-packages nil)
(mapc (lambda (pkg) (cl-pushnew pkg doom-packages :key 'car))
(-map (lambda (args)
(plist! args &delete
(-map (lambda (mplist)
(@mplist mplist &delete
:preface :ensure :requires :no-require :bind :bind* :bind-keymap
:bind-keymap* :interpreter :mode :commands :defines :functions
:defer :init :after :demand :config :diminish :delight))
@ -141,7 +141,7 @@ in `doom-packages' and enabled modules in `doom-modules'."
(-flatten-n
1 (mapcar (lambda (file)
(when (f-exists-p file)
(doom--scrape-sexps 'package! file)))
(doom--scrape-sexps '@package file)))
(append (f-glob "core*.el" doom-core-dir)
(--map (doom-module-path (car it) (cdr it) "packages.el")
doom-modules)))))))

View file

@ -15,9 +15,9 @@
be a lambda or symbol.")
;;;###autoload
(defmacro def-setting! (keyword arglist &optional docstring &rest forms)
(defmacro @def-setting (keyword arglist &optional docstring &rest forms)
"Define a setting macro. Like `defmacro', this should return a form to be
executed when called with `set!'. FORMS are not evaluated until `set!' calls it."
executed when called with `@set'. FORMS are not evaluated until `@set' calls it."
(declare (indent defun) (doc-string 3))
(unless (keywordp keyword)
(error "Not a valid property name: %s" keyword))
@ -37,13 +37,13 @@ executed when called with `set!'. FORMS are not evaluated until `set!' calls it.
(byte-compile sym)))))
;;;###autoload
(defmacro set! (keyword &rest values)
"Set an option defined by `def-setting!'. Skip if doesn't exist."
(defmacro @set (keyword &rest values)
"Set an option defined by `@def-setting'. Skip if doesn't exist."
(declare (indent defun))
(unless values
(error "Empty set! for %s" keyword))
(error "Empty @set for %s" keyword))
(cond ((not values)
(error "Empty set! for %s" keyword))
(error "Empty @set for %s" keyword))
((not (assq keyword doom-settings))
(when doom-debug-mode
(warn "No setting found for %s" keyword)))

View file

@ -74,10 +74,10 @@
recentf-max-saved-items 250
recentf-auto-cleanup 600
recentf-filename-handlers '(abbreviate-file-name))
(quiet! (recentf-mode 1))
(@quiet (recentf-mode 1))
;; Ediff
(add-hook! ediff-load
(@add-hook ediff-load
(setq ediff-diff-options "-w"
ediff-split-window-function 'split-window-horizontally
ediff-window-setup-function 'ediff-setup-windows-plain)) ; no extra frames
@ -93,15 +93,15 @@
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
;; specify their own formatting rules.
(package! editorconfig :demand t
(@package editorconfig :demand t
:mode ("\\.?editorconfig$" . editorconfig-conf-mode)
:config (editorconfig-mode +1)
;; Show whitespace in tabs indentation mode
(add-hook! 'editorconfig-custom-hooks
(@add-hook 'editorconfig-custom-hooks
(if indent-tabs-mode (whitespace-mode +1))))
;; Auto-close delimiters and blocks as you type
(package! smartparens :demand t
(@package smartparens :demand t
:init
(setq sp-autowrap-region nil ; let evil-surround handle this
sp-highlight-pair-overlay nil
@ -137,59 +137,66 @@
;; Autoloaded Plugins
;;
(package! ace-link :commands (ace-link-help ace-link-org))
(@package ace-link :commands (ace-link-help ace-link-org))
(package! ace-window
(@package ace-window
:commands ace-window
:config (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
aw-scope 'frame
aw-background t))
(package! avy
(@package avy
:commands (avy-goto-char-2 avy-goto-line)
:config (setq avy-all-windows nil
avy-background t))
(package! command-log-mode
:commands (clm/command-log-buffer command-log-mode global-command-log-mode)
:config (setq command-log-mode-is-global t))
(@package command-log-mode
:commands (command-log-mode global-command-log-mode)
:config
(@set :popup "*command-log*" :size 40 :align 'right :noselect t)
(setq command-log-mode-auto-show t
command-log-mode-open-log-turns-on-mode t))
(package! emr
(@package emr
:commands (emr-show-refactor-menu emr-declare-command)
:config (emr-initialize)
(define-key popup-menu-keymap [escape] 'keyboard-quit))
(package! expand-region :commands (er/expand-region er/contract-region er/mark-symbol er/mark-word))
(@package expand-region :commands (er/expand-region er/contract-region er/mark-symbol er/mark-word))
(package! goto-last-change :commands goto-last-change)
(@package goto-last-change :commands goto-last-change)
(package! help-fns+ ; Improved help commands
(@package help-fns+ ; Improved help commands
:commands (describe-buffer describe-command describe-file
describe-keymap describe-option describe-option-of-type))
(package! imenu-anywhere
(@package imenu-anywhere
:commands (ido-imenu-anywhere ivy-imenu-anywhere helm-imenu-anywhere))
(package! imenu-list :commands imenu-list-minor-mode)
(@package imenu-list :commands imenu-list-minor-mode)
(package! pcre2el :commands rxt-quote-pcre)
(@package pcre2el :commands rxt-quote-pcre)
(package! rotate-text
(@package rotate-text
:recipe (:fetcher github :repo "debug-ito/rotate-text.el")
:commands (rotate-text rotate-text-backward)
:config (push '("true" "false") rotate-text-words))
(package! smart-forward
(@package smart-forward
:commands (smart-up smart-down smart-backward smart-forward))
(package! smex :commands smex)
(@package smex
:commands (smex smex-major-mode-commands)
:config
(setq smex-save-file (concat doom-cache-dir "/smex-items"))
(smex-initialize))
(package! swiper :commands (swiper swiper-all))
(@package swiper :commands (swiper swiper-all))
(package! wgrep
(@package wgrep
:commands (wgrep-setup wgrep-change-to-wgrep-mode)
:config
(set! :popup "^\\*ivy-occur counsel-ag" :size 25 :select t :regexp t)
(@set :popup "^\\*ivy-occur counsel-ag" :size 25 :select t :regexp t)
(setq wgrep-auto-save-buffer t)
(advice-add 'wgrep-abort-changes :after 'doom/popup-close)
(advice-add 'wgrep-finish-edit :after 'doom/popup-close))

View file

@ -4,8 +4,8 @@
(require 's)
(require 'f)
(defvar __DIR__ nil "The directory of the currently loaded file (set by `load!')")
(defvar __FILE__ nil "The full path of the currently loaded file (set by `load!')")
(defvar __DIR__ nil "The directory of the currently loaded file (set by `@load')")
(defvar __FILE__ nil "The full path of the currently loaded file (set by `@load')")
(defun __DIR__ ()
"Get the full path to the current file's parent folder."
@ -26,15 +26,15 @@
byte-compile-current-file)
(error "__FILE__ is unset")))
(package! anaphora
(@package anaphora
:commands (awhen aif acond awhile))
(package! async
(@package async
:commands (async-start
async-start-process
async-byte-recompile-directory))
(package! persistent-soft
(@package persistent-soft
:preface (defvar pcache-directory (concat doom-cache-dir "pcache/"))
:commands (persistent-soft-exists-p
persistent-soft-fetch
@ -46,12 +46,12 @@
;; Library
;;
(defmacro λ! (&rest body)
(defmacro @λ (&rest body)
"A shortcut for inline interactive lambdas."
(declare (doc-string 1))
`(lambda () (interactive) ,@body))
(defmacro after! (feature &rest forms)
(defmacro @after (feature &rest forms)
"A smart wrapper around `with-eval-after-load'. Supresses warnings during
compilation."
(declare (indent defun) (debug t))
@ -64,14 +64,22 @@ compilation."
'with-no-warnings)
(with-eval-after-load ',feature ,@forms)))
(defmacro quiet! (&rest forms)
"Run FORMS without making any noise (no messages)."
`(cl-letf (((symbol-function 'load-file) (lambda (file) (load file nil t)))
(defmacro @quiet (&rest forms)
"Run FORMS without making any noise."
`(progn
(fset 'doom--old-write-region-fn (symbol-function 'write-region))
(cl-letf ((standard-output (lambda (&rest _)))
((symbol-function 'load-file) (lambda (file) (load file nil t)))
((symbol-function 'message) (lambda (&rest _)))
(inhibit-message t))
,@forms))
((symbol-function 'write-region)
(lambda (start end filename &optional append visit lockname mustbenew)
(unless visit (setq visit 'no-message))
(doom--old-write-region-fn start end filename append visit lockname mustbenew)))
(inhibit-message t)
(save-silently t))
,@forms)))
(defmacro add-hook! (hook &rest func-or-forms)
(defmacro @add-hook (hook &rest func-or-forms)
"A convenience macro for `add-hook'.
HOOK can be one hook or a list of hooks. If the hook(s) are not quoted, -hook is
@ -82,14 +90,14 @@ will be wrapped in a lambda. A list of symbols will expand into a series of
add-hook calls.
Examples:
(add-hook! 'some-mode-hook 'enable-something)
(add-hook! some-mode '(enable-something and-another))
(add-hook! '(one-mode-hook second-mode-hook) 'enable-something)
(add-hook! (one-mode second-mode) 'enable-something)
(add-hook! (one-mode second-mode) (setq v 5) (setq a 2))"
(@add-hook 'some-mode-hook 'enable-something)
(@add-hook some-mode '(enable-something and-another))
(@add-hook '(one-mode-hook second-mode-hook) 'enable-something)
(@add-hook (one-mode second-mode) 'enable-something)
(@add-hook (one-mode second-mode) (setq v 5) (setq a 2))"
(declare (indent defun) (debug t))
(unless func-or-forms
(error "add-hook!: FUNC-OR-FORMS is empty"))
(error "@add-hook: FUNC-OR-FORMS is empty"))
(let* ((val (car func-or-forms))
(quoted-p (eq (car-safe hook) 'quote))
(hook (if quoted-p (cadr hook) hook))
@ -107,7 +115,7 @@ Examples:
(-list hook)))))
funcs))))
(defmacro associate! (mode &rest plist)
(defmacro @associate (mode &rest plist)
"Associate a major or minor mode to certain patterns and project files."
(declare (indent 1))
(unless noninteractive
@ -118,7 +126,7 @@ Examples:
(pred (plist-get plist :when)))
(cond ((or files in pred)
(when (and files (not (or (listp files) (stringp files))))
(user-error "associate! :files expects a string or list of strings"))
(user-error "@associate :files expects a string or list of strings"))
(let ((hook-name (intern (format "doom--init-mode-%s" mode))))
(macroexp-progn
(list `(defun ,hook-name ()
@ -138,10 +146,10 @@ Examples:
(match
`(add-to-list ',(if minor 'doom-auto-minor-mode-alist 'auto-mode-alist)
(cons ,match ',mode)))
(t (user-error "associate! invalid rules for mode [%s] (in %s) (match %s) (files %s)"
(t (user-error "@associate invalid rules for mode [%s] (in %s) (match %s) (files %s)"
mode in match files))))))
;; Register keywords for proper indentation (see `map!')
;; Register keywords for proper indentation (see `@map')
(put ':prefix 'lisp-indent-function 'defun)
(put ':map 'lisp-indent-function 'defun)
(put ':map* 'lisp-indent-function 'defun)
@ -151,7 +159,7 @@ Examples:
(put ':leader 'lisp-indent-function 'defun)
(put ':localleader 'lisp-indent-function 'defun)
(defmacro map! (&rest rest)
(defmacro @map (&rest rest)
"A nightmare of a key-binding macro that will use `evil-define-key*',
`define-key', `local-set-key' and `global-set-key' depending on context and
plist key flags. It was designed to make binding multiple keys more concise,
@ -193,7 +201,7 @@ Conditional keybinds
(:unless [CONDITION] [...])
Example
(map! :map magit-mode-map
(@map :map magit-mode-map
:m \"C-r\" 'do-something ; assign C-r in motion state
:nv \"q\" 'magit-mode-quit-window ; assign to 'q' in normal and visual states
\"C-x C-r\" 'a-global-keybind
@ -217,7 +225,7 @@ Example
(cond
;; it's a sub expr
((listp key)
(push (macroexpand `(map! ,@key)) forms))
(push `(@map ,@key) forms))
;; it's a flag
((keywordp key)
@ -229,10 +237,10 @@ Example
(pcase key
(:prefix (setq prefix (concat prefix (kbd (pop rest)))))
(:map (setq keymaps (-list (pop rest))))
(:unset `(,(macroexpand `(map! ,(kbd (pop rest))))))
(:after (prog1 `((after! ,(pop rest) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
(:when (prog1 `((if ,(pop rest) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
(:unless (prog1 `((if (not ,(pop rest)) ,(macroexpand `(map! ,@rest)))) (setq rest '())))
(:unset `((@map ,(kbd (pop rest)))))
(:after (prog1 `((@after ,(pop rest) (@map ,@rest))) (setq rest '())))
(:when (prog1 `((if ,(pop rest) (@map ,@rest))) (setq rest '())))
(:unless (prog1 `((if (not ,(pop rest)) (@map ,@rest))) (setq rest '())))
(otherwise ; might be a state prefix
(mapc (lambda (letter)
(cond ((assoc letter state-map)

View file

@ -76,7 +76,7 @@ if you have byte-compiled your configuration (as intended).")
(autoload 'use-package "use-package" nil nil 'macro)
(advice-add 'package-delete :after 'doom*package-delete)
(defmacro doom! (&rest packages)
(defmacro @doom (&rest packages)
"DOOM Emacs bootstrap macro. List the modules to load. Benefits from
byte-compilation."
(let (mode)
@ -84,7 +84,7 @@ byte-compilation."
(cond ((keywordp p)
(setq mode p))
((not mode)
(error "No namespace specified on `doom!' for %s" p))
(error "No namespace specified on `@doom' for %s" p))
((eq p '*)
(let ((mode-name (substring (symbol-name mode) 1)))
(--map (setq doom-modules (append doom-modules (list (cons mode (f-base it)))))
@ -93,7 +93,7 @@ byte-compilation."
(setq doom-modules (append doom-modules (list (cons mode p))))))))
(unless noninteractive
`(let (file-name-handler-alist)
,@(mapcar (lambda (pkg) `(load! ,(car pkg) ,(cdr pkg)))
,@(mapcar (lambda (pkg) `(@load ,(car pkg) ,(cdr pkg)))
doom-modules)
(when (display-graphic-p)
@ -159,22 +159,22 @@ avoided to speed up startup."
(defvar __PACKAGE__ nil "The name of the current package.")
(defalias 'use-package! 'use-package
(defalias '@use-package 'use-package
"A `use-package' alias. It exists so DOOM configs adhere to the naming
conventions of DOOM emacs. Note that packages are deferred by default.
By DOOM conventions, using this instead of `package!' means you are configuring
a package regardless of whether it's installed or not, while `package!' is used
By DOOM conventions, using this instead of `@package' means you are configuring
a package regardless of whether it's installed or not, while `@package' is used
to declare how to install/setup a package.")
(defmacro package! (name &rest plist)
(defmacro @package (name &rest plist)
"Declares a package. This does not load nor install them explicitly.
If used in `doom-core-dir', this is a wrapper for `use-package!' (all packages
If used in `doom-core-dir', this is a wrapper for `@use-package' (all packages
are deferred by default), and takes the same arguments as `use-package'.
If used outside of `doom-core-dir' (i.e. in packages.el files within modules),
this macro serves a purely declarative purpose and doesn't call `use-package!'.
this macro serves a purely declarative purpose and doesn't call `@use-package'.
These calls are parsed by `doom-read-packages' to build `doom-packages'.
Adds a few custom properties in either case:
@ -190,20 +190,20 @@ Adds a few custom properties in either case:
(mapc (lambda (key) (setq plist (use-package-plist-delete plist key)))
'(:recipe :pin :needs))
`(let ((__PACKAGE__ ',name))
(use-package! ,name ,@plist)))
(@use-package ,name ,@plist)))
(defmacro load! (module &optional submodule file)
(defmacro @load (module &optional submodule file)
"Load a module from `doom-modules-dir' when both MODULE and SUBMODULE is
provided (both symbols). If FILE is non-nil, append it to the resulting path. If
SUBMODULE is nil, MODULE is loaded relative to the current file (see `__DIR__').
When SUBMODULE is nil, FILE isn't used.
Examples:
(load! :lang emacs-lisp)
(@load :lang emacs-lisp)
Loads modules/lang/emacs-lisp/FILE.el (defaults to config.el).
(load! +local-module)
(@load +local-module)
Loads +local-module.el relative to `__DIR__' or `doom-core-dir'."
(let (path file)
@ -243,7 +243,7 @@ Examples:
(defun doom/reload ()
"Reload `load-path', `doom-modules' and `doom-packages' by
reinitializing doom and parsing config files for `package!' and `doom!' calls.
reinitializing doom and parsing config files for `@package' and `@doom' calls.
There are few reasons to use this."
(interactive)
(doom-initialize t)

View file

@ -36,7 +36,7 @@
map)
"Active keymap in popup windows.")
(def-setting! :popup (&rest rules)
(@def-setting :popup (&rest rules)
"Prepend a new popup rule to `shackle-rules'."
(if (not (-all-p 'listp rules))
`(cl-pushnew ',rules shackle-rules :key 'car :test 'equal)
@ -59,7 +59,7 @@
;; Bootstrap
;;
(package! shackle :demand t
(@package shackle :demand t
:init
(setq shackle-default-alignment 'below
shackle-select-reused-windows t)
@ -70,7 +70,7 @@
;;; Baseline popup-window rules
;; :noesc and :modeline are custom settings and are not part of shackle. See
;; `doom*popup-init' and `doom-popup-buffer' for how they're used.
(set! :popup
(@set :popup
'("^ ?\\*doom:.+\\*$" :size 40 :modeline t :regexp t)
'("^ ?\\*doom .+\\*$" :size 30 :noselect t :regexp t)
'("^\\*.+-Profiler-Report .+\\*$" :size 0.3 :regexp t)
@ -183,7 +183,7 @@ prevent popups from messaging up the UI (or vice versa)."
;; Hacks
;;
(after! evil
(@after evil
(let ((map doom-popup-mode-map))
(define-key map [remap evil-window-delete] 'doom/popup-close)
(define-key map [remap evil-window-move-very-bottom] 'ignore)
@ -257,12 +257,12 @@ the command buffer."
(advice-add 'windmove-find-other-window :override 'doom*ignore-window-parameters-in-popups))
;; (after! magit
;; (@after magit
;; ;; Don't open files (from magit) within the magit popup
;; (advice-add 'magit-display-file-buffer-traditional :around 'doom*popups-save))
(after! neotree
(@after neotree
(defun doom*popups-save-neotree (orig-fun &rest args)
"Prevents messing up the neotree buffer on window changes."
(let ((neo-p (and (featurep 'neotree) (neo-global--window-exists-p))))
@ -289,7 +289,7 @@ the command buffer."
(advice-add 'evil-window-move-far-right :around 'doom*popups-save-neotree))
(add-hook! org-load
(@add-hook org-load
;; Ensures org-src-edit yields control of its buffer to shackle.
(defun doom*org-src-switch-to-buffer (buffer context) (pop-to-buffer buffer))
(advice-add 'org-src-switch-to-buffer :override 'doom*org-src-switch-to-buffer)
@ -321,8 +321,8 @@ the command buffer."
(setq org-agenda-archives-mode nil
org-agenda-buffer nil))))
(after! org-agenda
(after! evil
(@after org-agenda
(@after evil
(evil-define-key* 'motion org-agenda-mode-map
[escape] 'doom/popup-org-agenda-quit
(kbd "ESC") 'doom/popup-org-agenda-quit))
@ -332,8 +332,8 @@ the command buffer."
(define-key map "Q" 'doom/popup-org-agenda-quit))))
(after! repl-toggle
(add-hook! doom-popup-close
(@after repl-toggle
(@add-hook doom-popup-close
(setq rtog/--last-buffer nil)))
(provide 'core-popups)

View file

@ -4,7 +4,7 @@
;; tools for digging through project files and exposing an API I can use to make
;; other plugins/features project-aware.
(package! projectile :demand t
(@package projectile :demand t
:init
(setq projectile-cache-file (concat doom-cache-dir "/projectile.cache")
projectile-completion-system 'ivy

View file

@ -45,8 +45,8 @@
;; show typed keystrokes in minibuffer
(setq echo-keystrokes 0.02)
;; ...but hide them while isearch is active
(add-hook! isearch-mode (setq echo-keystrokes 0))
(add-hook! isearch-mode-end (setq echo-keystrokes 0.02))
(@add-hook isearch-mode (setq echo-keystrokes 0))
(@add-hook isearch-mode-end (setq echo-keystrokes 0.02))
;; A minor mode for toggling the mode-line
(defvar doom--hidden-modeline-format nil
@ -90,7 +90,7 @@ disabled.")
(foreground-color . ,doom-ui-default-foreground))
default-frame-alist))
;; no fringe in the minibuffer
(add-hook! (emacs-startup minibuffer-setup)
(@add-hook (emacs-startup minibuffer-setup)
(set-window-fringes (minibuffer-window) 0 0 nil)))
@ -101,7 +101,7 @@ disabled.")
;; I modified the built-in `hideshow' package to enable itself when needed. A
;; better, more vim-like code-folding plugin would be the `origami' plugin, but
;; until certain breaking bugs are fixed in it, I won't switch over.
(use-package! hideshow ; built-in
(@use-package hideshow ; built-in
:commands (hs-minor-mode hs-toggle-hiding hs-already-hidden-p)
:init
(defun doom*autoload-hideshow ()
@ -110,7 +110,7 @@ disabled.")
(advice-add 'evil-toggle-fold :before 'doom*autoload-hideshow))
;; Show uninterrupted indentation markers with some whitespace voodoo.
(package! highlight-indent-guides
(@package highlight-indent-guides
:commands highlight-indent-guides-mode
:config
(setq highlight-indent-guides-method 'character)
@ -152,7 +152,7 @@ file."
(set-buffer-modified-p nil))
nil)
(add-hook! highlight-indent-guides-mode
(@add-hook highlight-indent-guides-mode
(if highlight-indent-guides-mode
(progn
(doom|inject-trailing-whitespace)
@ -161,44 +161,44 @@ file."
(delete-trailing-whitespace))))
;; Some modes don't adequately highlight numbers, therefore...
(package! highlight-numbers :commands highlight-numbers-mode)
(@package highlight-numbers :commands highlight-numbers-mode)
;; Line highlighting
(use-package! hl-line ; built-in
:config
(@use-package hl-line ; built-in
:init
;; stickiness doesn't play nice with emacs 25+
(setq hl-line-sticky-flag nil
global-hl-line-sticky-flag nil))
;; Line number column. A faster (or equivalent, in the worst case) line number
;; plugin than the built-in `linum'.
(package! nlinum
(@package nlinum
:commands nlinum-mode
:preface (defvar nlinum-format "%4d ")
:init
(add-hook!
(@add-hook
(markdown-mode prog-mode scss-mode web-mode conf-mode groovy-mode
nxml-mode snippet-mode php-mode)
'nlinum-mode)
:config
;; Optimization: calculate line number column width beforehand
(add-hook! nlinum-mode
(@add-hook nlinum-mode
(setq nlinum--width (length (save-excursion (goto-char (point-max))
(format-mode-line "%l")))))
;; Disable nlinum explicitly before making a frame, otherwise nlinum throws
;; linum face errors that prevent the frame from spawning.
(add-hook! '(before-make-frame-hook after-make-frame-functions)
(@add-hook '(before-make-frame-hook after-make-frame-functions)
(nlinum-mode -1)))
;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk
;; languages like Lisp.
(package! rainbow-delimiters
(@package rainbow-delimiters
:commands rainbow-delimiters-mode
:config (setq rainbow-delimiters-max-face-count 3)
:init
(add-hook! (emacs-lisp-mode lisp-mode js-mode css-mode c-mode-common)
(@add-hook (emacs-lisp-mode lisp-mode js-mode css-mode c-mode-common)
'rainbow-delimiters-mode))
(provide 'core-ui)

View file

@ -5,12 +5,12 @@
;; strives to make Emacs a much better vim than vim was.
(defvar +evil-leader ","
"The <leader> key, used by the `map!' macro for :leader bindings.")
"The <leader> key, used by the `@map' macro for :leader bindings.")
(defvar +evil-localleader "\\"
"The <localleader> key, used by the `map!' macro for :localleader bindings.")
"The <localleader> key, used by the `@map' macro for :localleader bindings.")
(def-setting! :evil-state (&rest mode-state-list)
(@def-setting :evil-state (&rest mode-state-list)
"Set the initialize STATE of MODE using `evil-set-initial-state'."
(if (-all-p 'listp mode-state-list)
(macroexp-progn
@ -29,7 +29,7 @@
;; evil-mode
;;
(use-package! evil :demand t
(@use-package evil :demand t
:init
(setq evil-want-C-u-scroll t
evil-want-visual-char-semi-exclusive t
@ -45,7 +45,7 @@
evil-insert-skip-empty-lines t)
:config
(set! :popup
(@set :popup
'("*evil-registers*" :size 0.3)
'("*Command Line*" :size 8))
@ -76,7 +76,7 @@
(Man-mode . emacs)
(grep-mode . emacs))))
(defsubst +evil--textobj! (key inner-fn &optional outer-fn)
(defsubst +evil--textobj (key inner-fn &optional outer-fn)
"Define a text object."
(define-key evil-inner-text-objects-map key inner-fn)
(define-key evil-outer-text-objects-map key (or outer-fn inner-fn)))
@ -145,19 +145,19 @@
;; Plugins
;;
(use-package! evil-args
(@use-package evil-args
:commands (evil-inner-arg evil-outer-arg
evil-forward-arg evil-backward-arg
evil-jump-out-args)
:init (+evil--textobj! "a" 'evil-inner-arg 'evil-outer-arg))
:init (+evil--textobj "a" 'evil-inner-arg 'evil-outer-arg))
(use-package! evil-commentary
(@use-package evil-commentary
:commands (evil-commentary evil-commentary-yank evil-commentary-line)
:config (evil-commentary-mode 1))
(use-package! evil-easymotion
(@use-package evil-easymotion
:defer 1
:config
(defvar +evil--snipe-repeat-fn)
@ -183,7 +183,7 @@
(evil-snipe-enable-incremental-highlight)))))
(use-package! evil-embrace
(@use-package evil-embrace
:after evil-surround
:config
(setq evil-embrace-show-help-p nil)
@ -229,15 +229,15 @@
;; Add extra pairs
(add-hook 'LaTeX-mode-hook 'embrace-LaTeX-mode-hook)
(add-hook 'org-mode-hook 'embrace-org-mode-hook)
(add-hook! emacs-lisp-mode
(@add-hook emacs-lisp-mode
(embrace-add-pair ?\` "`" "'"))
(add-hook! (emacs-lisp-mode lisp-mode)
(@add-hook (emacs-lisp-mode lisp-mode)
(embrace-add-pair-regexp ?f "([^ ]+ " ")" '+evil--embrace-elisp-fn))
(add-hook! (org-mode latex-mode)
(@add-hook (org-mode latex-mode)
(embrace-add-pair-regexp ?l "\\[a-z]+{" "}" '+evil--embrace-latex)))
(use-package! evil-escape
(@use-package evil-escape
:commands evil-escape-mode
:init
(defun +evil|escape-disable () (evil-escape-mode -1))
@ -252,7 +252,7 @@
evil-escape-delay 0.25))
(use-package! evil-exchange
(@use-package evil-exchange
:commands evil-exchange
:config
(defun +evil*exchange-off ()
@ -260,7 +260,7 @@
(advice-add 'evil-force-normal-state :after '+evil*exchange-off))
(use-package! evil-indent-plus
(@use-package evil-indent-plus
:commands (evil-indent-plus-i-indent
evil-indent-plus-a-indent
evil-indent-plus-i-indent-up
@ -268,16 +268,16 @@
evil-indent-plus-i-indent-up-down
evil-indent-plus-a-indent-up-down)
:init
(+evil--textobj! "i" 'evil-indent-plus-i-indent 'evil-indent-plus-a-indent)
(+evil--textobj! "I" 'evil-indent-plus-i-indent-up 'evil-indent-plus-a-indent-up)
(+evil--textobj! "J" 'evil-indent-plus-i-indent-up-down 'evil-indent-plus-a-indent-up-down))
(+evil--textobj "i" 'evil-indent-plus-i-indent 'evil-indent-plus-a-indent)
(+evil--textobj "I" 'evil-indent-plus-i-indent-up 'evil-indent-plus-a-indent-up)
(+evil--textobj "J" 'evil-indent-plus-i-indent-up-down 'evil-indent-plus-a-indent-up-down))
(use-package! evil-matchit
(@use-package evil-matchit
:commands (evilmi-jump-items evilmi-text-object global-evil-matchit-mode)
:config (global-evil-matchit-mode 1)
:init
(+evil--textobj! "%" 'evilmi-text-object)
(+evil--textobj "%" 'evilmi-text-object)
(defun +evil/matchit-or-toggle-fold ()
"If on a fold-able element, toggle the fold (`hs-toggle-hiding'). Otherwise,
@ -288,7 +288,7 @@ if on a delimiter, jump to the matching one (`evilmi-jump-items')."
(call-interactively 'evilmi-jump-items))))
(use-package! evil-multiedit
(@use-package evil-multiedit
:commands (evil-multiedit-match-all
evil-multiedit-match-and-next
evil-multiedit-match-and-prev
@ -302,20 +302,20 @@ if on a delimiter, jump to the matching one (`evilmi-jump-items')."
:config (evil-multiedit-default-keybinds))
(use-package! evil-textobj-anyblock
(@use-package evil-textobj-anyblock
:commands (evil-numbers/inc-at-pt evil-numbers/dec-at-pt)
:init
(+evil--textobj! "B" 'evil-textobj-anyblock-inner-block 'evil-textobj-anyblock-a-block))
(+evil--textobj "B" 'evil-textobj-anyblock-inner-block 'evil-textobj-anyblock-a-block))
(use-package! evil-search-highlight-persist :demand t
(@use-package evil-search-highlight-persist :demand t
:commands (evil-textobj-anyblock-inner-block evil-textobj-anyblock-a-block)
:config
(global-evil-search-highlight-persist t)
(advice-add 'evil-force-normal-state :after 'evil-search-highlight-persist-remove-all))
(use-package! evil-snipe :demand t
(@use-package evil-snipe :demand t
:init
(setq evil-snipe-smart-case t
evil-snipe-repeat-keys nil ; using space to repeat
@ -331,12 +331,12 @@ if on a delimiter, jump to the matching one (`evilmi-jump-items')."
(evil-snipe-mode 1)
(evil-snipe-override-mode 1)
;; Switch to evil-easymotion/avy after first snipe
(map! :map evil-snipe-parent-transient-map
"C-;" (λ! (require 'evil-easymotion)
(@map :map evil-snipe-parent-transient-map
"C-;" (@λ (require 'evil-easymotion)
(call-interactively +evil--snipe-repeat-fn))))
(use-package! evil-surround
(@use-package evil-surround
:commands (global-evil-surround-mode
evil-surround-edit
evil-Surround-edit
@ -344,7 +344,7 @@ if on a delimiter, jump to the matching one (`evilmi-jump-items')."
:config (global-evil-surround-mode 1))
(use-package! evil-visualstar
(@use-package evil-visualstar
:commands (global-evil-visualstar-mode
evil-visualstar/begin-search
evil-visualstar/begin-search-forward
@ -353,7 +353,7 @@ if on a delimiter, jump to the matching one (`evilmi-jump-items')."
;; A side-panel for browsing my project files. Inspired by vim's NERDTree.
(use-package! neotree
(@use-package neotree
:commands (neotree-show
neotree-hide
neotree-toggle
@ -384,13 +384,13 @@ if on a delimiter, jump to the matching one (`evilmi-jump-items')."
"^#.*#$"))
:config
(set! :evil-state 'neotree-mode 'motion)
(@set :evil-state 'neotree-mode 'motion)
;; Adding keybindings to `neotree-mode-map' wouldn't work for me (they get
;; overridden when the neotree buffer is spawned). So we bind them in a hook.
(add-hook 'neo-after-create-hook '+evil|neotree-init-keymap)
(defun +evil|neotree-init-keymap (&rest _)
(map! :Lm "\\\\" 'evil-window-prev
(@map :Lm "\\\\" 'evil-window-prev
:Lm "RET" 'neotree-enter
:Lm "<return>" 'neotree-enter
:Lm "ESC ESC" 'neotree-hide

View file

@ -1,20 +1,20 @@
;; -*- no-byte-compile: t; -*-
;;; feature/evil/packages.el
(package! evil)
(package! evil-args)
(package! evil-commentary)
(package! evil-easymotion)
(package! evil-embrace)
(package! evil-escape)
(package! evil-exchange)
(package! evil-indent-plus)
(package! evil-matchit)
(package! evil-multiedit)
(package! evil-numbers)
(package! evil-textobj-anyblock)
(package! evil-search-highlight-persist)
(package! evil-snipe)
(package! evil-surround)
(package! evil-visualstar)
(package! neotree)
(@package evil)
(@package evil-args)
(@package evil-commentary)
(@package evil-easymotion)
(@package evil-embrace)
(@package evil-escape)
(@package evil-exchange)
(@package evil-indent-plus)
(@package evil-matchit)
(@package evil-multiedit)
(@package evil-numbers)
(@package evil-textobj-anyblock)
(@package evil-search-highlight-persist)
(@package evil-snipe)
(@package evil-surround)
(@package evil-visualstar)
(@package neotree)

View file

@ -1,43 +1,43 @@
;;; feature/version-control/+git.el
(use-package! gitconfig-mode
(@use-package gitconfig-mode
:mode "/\\.?git/?config$"
:mode "/\\.gitmodules$"
:init (add-hook 'gitconfig-mode-hook 'flyspell-mode))
(use-package! gitignore-mode
(@use-package gitignore-mode
:mode "/\\.?git/?config$"
:mode "/\\.gitmodules$")
(use-package! git-gutter-fringe
(@use-package git-gutter-fringe
:commands git-gutter-mode
:init (add-hook! (text-mode prog-mode conf-mode) 'git-gutter-mode)
:init (@add-hook (text-mode prog-mode conf-mode) 'git-gutter-mode)
:config
(set! :popup "^\\*git-gutter.+\\*$" :regexp t :size 15 :noselect t)
(@set :popup "^\\*git-gutter.+\\*$" :regexp t :size 15 :noselect t)
;; Update git-gutter on focus (in case I was using git externally)
(add-hook 'focus-in-hook 'git-gutter:update-all-windows)
(after! evil
(@after evil
;; Refreshing git-gutter on ESC
(advice-add 'evil-force-normal-state :after 'git-gutter)))
(use-package! browse-at-remote
(@use-package browse-at-remote
:commands (browse-at-remote/browse browse-at-remote/get-url))
(use-package! magit
(@use-package magit
:commands magit-status
:config
(set! :popup "^\\*magit.+" :regexp t)
(after! evil-snipe
(@set :popup "^\\*magit.+" :regexp t)
(@after evil-snipe
;; evil-snipe conflicts with magit
(add-hook 'magit-mode-hook 'turn-off-evil-snipe-override-mode)))
(use-package! evil-magit
(@use-package evil-magit
:when (featurep 'evil)
:after magit)

View file

@ -1,20 +1,20 @@
;;; feature/version-control/config.el
(provide '+version-control)
(load! +git)
;; (load! +hg)
(@load +git)
;; (@load +hg)
(after! vc-annotate
(set! :popup
(@after vc-annotate
(@set :popup
'("*vc-diff*" :size 15 :noselect t)
'("*vc-change-log*" :size 15 :select t)
'(vc-annotate-mode :same t))
(set! :evil-state
(@set :evil-state
'(vc-annotate-mode normal)
'(vc-git-log-view-mode normal))
(map! :map vc-annotate-mode-map
(@map :map vc-annotate-mode-map
:n "q" 'kill-this-buffer
:n "d" 'vc-annotate-show-diff-revision-at-line
:n "D" 'vc-annotate-show-changeset-diff-revision-at-line

View file

@ -5,11 +5,11 @@
;; n/a
;;; +git
(package! browse-at-remote)
(package! evil-magit :needs evil)
(package! git-gutter-fringe)
(package! gitconfig-mode)
(package! gitignore-mode)
(package! magit)
(@package browse-at-remote)
(@package evil-magit :needs evil)
(@package git-gutter-fringe)
(@package gitconfig-mode)
(@package gitignore-mode)
(@package magit)
;;; TODO +hg

View file

@ -389,7 +389,7 @@ the workspace and move to the next."
;;;###autoload (autoload '+workspace:switch-next "feature/workspaces/autoload" nil t)
;;;###autoload (autoload '+workspace:switch-previous "feature/workspaces/autoload" nil t)
(after! evil
(@after evil
(evil-define-command +workspace:save-session (&optional name)
"Ex wrapper around `+workspace/save-session'."
(interactive "<a>") (+workspace/save-session name))

View file

@ -4,7 +4,7 @@
;; file-based session persistence. The switch from workgroups2 was motivated by
;; performance. Workgroups2 wasn't entirely stable either.
(use-package! persp-mode :demand t
(@use-package persp-mode :demand t
:init
(setq persp-autokill-buffer-on-remove 'kill-weak
persp-nil-name "main"
@ -15,6 +15,8 @@
persp-switch-to-added-buffer nil)
:config
(@add-hook emacs-startup (persp-mode 1))
;; Ensure unreal/popup buffers aren't saved
(push (lambda (buf) (doom-popup-p (get-buffer-window buf)))
persp-filter-save-buffers-functions)
@ -43,7 +45,7 @@
(when plist (doom-popup--init window plist)))))
(advice-add 'persp-load-state-from-file :after '+workspaces*reinit-popups))
(after! ivy
(@after ivy
(defun +workspaces|ivy-ignore-non-persp-buffers (b)
(when persp-mode
(let ((persp (get-current-persp)))

View file

@ -1,5 +1,5 @@
;; -*- no-byte-compile: t; -*-
;;; feature/workspaces/packages.el
(package! persp-mode)
(@package persp-mode)

View file

@ -1,12 +1,13 @@
;;; lang/emacs-lisp/config.el
(provide '+emacs-lisp)
(use-package! elisp-mode
(@use-package elisp-mode
:mode ("/Cask$" . emacs-lisp-mode)
:init
(add-hook! emacs-lisp-mode '(highlight-quoted-mode auto-compile-on-save-mode +emacs-lisp|hook))
(@add-hook emacs-lisp-mode '(highlight-quoted-mode auto-compile-on-save-mode +emacs-lisp|hook))
:config
(map! :map emacs-lisp-mode-map
(@map :map emacs-lisp-mode-map
:m "gd" '+emacs-lisp/find-function
:leader :m "gd" '+emacs-lisp/find-function-other-window)
@ -37,8 +38,8 @@
(push i imenu-generic-expression))))
(after! debug ;; elisp debugging
(map! :map debugger-mode-map
(@after debug ;; elisp debugging
(@map :map debugger-mode-map
:n "RET" 'debug-help-follow
:n "n" 'debugger-step-through
:n "c" 'debugger-continue))
@ -48,17 +49,17 @@
;; Plugins
;;
(use-package! auto-compile
(@use-package auto-compile
:commands auto-compile-on-save-mode
:config
(setq auto-compile-display-buffer nil
auto-compile-use-mode-line nil))
(use-package! highlight-quoted
(@use-package highlight-quoted
:commands highlight-quoted-mode)
(use-package! slime
(@use-package slime
:config (setq inferior-lisp-program "clisp"))

View file

@ -1,6 +1,6 @@
;; -*- no-byte-compile: t; -*-
;;; lang/emacs-lisp/packages.el
(package! auto-compile)
(package! highlight-quoted)
(package! slime)
(@package auto-compile)
(@package highlight-quoted)
(@package slime)

View file

@ -169,7 +169,7 @@
:match "/screeps/.+$"
:modes (nodejs-project-mode))
(add-hook! screeps-project-mode
(@add-hook screeps-project-mode
(when (eq major-mode 'js2-mode)
(add-to-list 'flycheck-disabled-checkers 'javascript-jshint)
(setq js2-additional-externs (append '("_") screeps-objects screeps-constants))))

View file

@ -1,7 +1,7 @@
;; lang/javascript/config.el
(provide '+javascript)
(use-package! js2-mode
(@use-package js2-mode
:mode "\\.js$"
:interpreter "node"
:init
@ -10,17 +10,17 @@
js2-mode-show-parse-errors nil)
:config
(add-hook! '(tern-mode flycheck-mode highlight-indent-guides-mode))
(@add-hook '(tern-mode flycheck-mode highlight-indent-guides-mode))
;; Only way to conform switch-case indentation to editorconfig's config
(add-hook! (setq js-switch-indent-offset js-indent-level))
(@add-hook (setq js-switch-indent-offset js-indent-level))
(map! :map js2-mode-map :localleader :nv ";" 'doom/append-semicolon)
(@map :map js2-mode-map :localleader :nv ";" 'doom/append-semicolon)
(set! :repl nodejs-repl)
(set! :company-backends tern)
(set! :electric-chars ?\} ?\) ?.)
(set! :electric-words "||" "&&")
(set! :emr
(@set :repl nodejs-repl)
(@set :company-backends tern)
(@set :electric-chars ?\} ?\) ?.)
(@set :electric-words "||" "&&")
(@set :emr
(:v js2r-extract-function "extract function")
(:v js2r-extract-method "extract method")
(:v js2r-introduce-parameter "introduce parameter")
@ -48,13 +48,13 @@
(:n js2r-forward-slurp "forward slurp")
(:n js2r-forward-barf "forward barf")))
(use-package! js2-refactor :after emr)
(@use-package js2-refactor :after emr)
(use-package! company-tern :commands company-tern :after tern)
(@use-package company-tern :commands company-tern :after tern)
(use-package! jsx-mode :mode "\\.jsx$")
(@use-package jsx-mode :mode "\\.jsx$")
(use-package! coffee-mode
(@use-package coffee-mode
:mode "\\.coffee$"
:init (setq coffee-indent-like-python-mode t))

View file

@ -1,10 +1,10 @@
;; -*- no-byte-compile: t; -*-
;;; lang/javascript/packages.el
(package! coffee-mode)
(package! company-tern :needs +company)
(package! js2-mode)
(package! js2-refactor)
(package! jsx-mode)
(package! tern)
(@package coffee-mode)
(@package company-tern :needs +company)
(@package js2-mode)
(@package js2-refactor)
(@package jsx-mode)
(@package tern)

View file

@ -15,7 +15,7 @@
(message "Running: %s" command)
(shell-command command)))
(defmacro +macos--open-with! (id &optional app dir)
(defmacro +macos@open-with (id &optional app dir)
`(defun ,(intern (format "+macos/%s" id)) ()
(interactive)
(+macos-open-with ,app ,dir)))
@ -27,22 +27,22 @@
(browse-url buffer-file-name))
;;;###autoload (autoload '+macos/open-in-default-program "os/macos/autoload" nil t)
(+macos--open-with! open-in-default-program)
(+macos@open-with open-in-default-program)
;;;###autoload (autoload '+macos/reveal-in-finder "os/macos/autoload" nil t)
(+macos--open-with! reveal-in-finder "Finder" default-directory)
(+macos@open-with reveal-in-finder "Finder" default-directory)
;;;###autoload (autoload '+macos/reveal-project-in-finder "os/macos/autoload" nil t)
(+macos--open-with! reveal-project-in-finder "Finder" (doom-project-root))
(+macos@open-with reveal-project-in-finder "Finder" (doom-project-root))
;;;###autoload (autoload '+macos/send-to-transmit "os/macos/autoload" nil t)
(+macos--open-with! send-to-transmit "Transmit")
(+macos@open-with send-to-transmit "Transmit")
;;;###autoload (autoload '+macos/send-cwd-to-transmit "os/macos/autoload" nil t)
(+macos--open-with! send-cwd-to-transmit "Transmit" default-directory)
(+macos@open-with send-cwd-to-transmit "Transmit" default-directory)
;;;###autoload (autoload '+macos/send-to-launchbar "os/macos/autoload" nil t)
(+macos--open-with! send-to-launchbar "LaunchBar")
(+macos@open-with send-to-launchbar "LaunchBar")
;;;###autoload (autoload '+macos/send-project-to-launchbar "os/macos/autoload" nil t)
(+macos--open-with! send-project-to-launchbar "LaunchBar" (doom-project-root))
(+macos@open-with send-project-to-launchbar "LaunchBar" (doom-project-root))

View file

@ -28,7 +28,7 @@
(require 'osx-clipboard)
(osx-clipboard-mode +1)))
(after! evil
(@after evil
;; On OSX, stop copying each visual state move to the clipboard:
;; https://bitbucket.org/lyro/evil/issue/336/osx-visual-state-copies-the-region-on
;; Most of this code grokked from:

View file

@ -1,5 +1,5 @@
;; -*- no-byte-compile: t; -*-
;;; os/macos/packages.el
(package! exec-path-from-shell)
(package! osx-clipboard)
(@package exec-path-from-shell)
(@package osx-clipboard)

View file

@ -38,24 +38,10 @@
(window-divider-mode +1)
;; Causes a flash around the cursor when it moves across a "large" distance.
;; Usually between windows, or across files. This makes it easier to keep track
;; where your cursor is, which I find helpful on my 30" 2560x1600 display.
(use-package! beacon :demand t
:config
(beacon-mode +1)
(setq beacon-color (let ((bg (face-attribute 'highlight :background nil t)))
(if (eq bg 'unspecified)
(face-attribute 'highlight :foreground nil t)
bg))
beacon-blink-when-buffer-changes t
beacon-blink-when-point-moves-vertically 10))
;; Apply the doom-one theme from `doom-themes' for full compatibility; gives
;; Emacs a look inspired by Dark One in Atom.
;; <https://github.com/hlissner/emacs-doom-theme>
(use-package! doom-themes :demand t
(@use-package doom-themes :demand t
:load-path "~/work/plugins/emacs-doom-theme"
:config
(load-theme +doom-theme t)
@ -77,8 +63,22 @@
(require 'doom-nlinum))
;; Causes a flash around the cursor when it moves across a "large" distance.
;; Usually between windows, or across files. This makes it easier to keep track
;; where your cursor is, which I find helpful on my 30" 2560x1600 display.
(@use-package beacon :demand t
:config
(beacon-mode +1)
(setq beacon-color (let ((bg (face-attribute 'highlight :background nil t)))
(if (eq bg 'unspecified)
(face-attribute 'highlight :foreground nil t)
bg))
beacon-blink-when-buffer-changes t
beacon-blink-when-point-moves-vertically 10))
;; Nicer folded overlays that stand out a bit more
(after! hideshow
(@after hideshow
(defface doom-folded-face '((t (:foreground "#555" :background "#888")))
"Face to hightlight `hideshow' overlays."
:group 'hideshow)
@ -90,7 +90,7 @@
;; Show diffs with subtle lines in the fringe
(after! git-gutter-fringe
(@after git-gutter-fringe
;; places the git gutter outside the margins.
(setq-default fringes-outside-margins t)
;; thin fringe bitmaps

View file

@ -1,6 +1,6 @@
;; -*- no-byte-compile: t; -*-
;;; ui/doom/packages.el
(package! beacon)
(package! doom-themes)
(@package beacon)
(@package doom-themes)