Minor refactoring across the board

This commit is contained in:
Henrik Lissner 2021-05-23 21:48:38 -04:00
parent a8e57438dc
commit 3ba364ae10
12 changed files with 63 additions and 48 deletions

View file

@ -77,9 +77,10 @@ Detects evil visual mode as well."
"Return beginning position of selection.
Uses `evil-visual-beginning' if available."
(declare (side-effect-free t))
(if (bound-and-true-p evil-local-mode)
evil-visual-beginning
(region-beginning)))
(or (and (bound-and-true-p evil-local-mode)
(markerp evil-visual-beginning)
(marker-position evil-visual-beginning))
(region-beginning)))
;;;###autoload
(defun doom-region-end ()

View file

@ -14,7 +14,6 @@ one wants that.")
(defvar doom-autoloads-cached-vars
'(doom-modules
doom-disabled-packages
comp-deferred-compilation-deny-list
native-comp-deferred-compilation-deny-list
load-path
auto-mode-alist

View file

@ -68,7 +68,7 @@ list remains lean."
"git" "log" "--oneline" "--no-merges"
"-n" "26" end-ref (concat "^" (regexp-quote start-ref)))
(if success
(let* ((output (string-trim-right stdout))
(let* ((output (string-trim-right (or stdout "")))
(lines (split-string output "\n")))
(if (> (length lines) 25)
(concat (string-join (butlast lines 1) "\n") "\n[...]")

View file

@ -154,10 +154,19 @@ uses a straight or package.el command directly).")
(defun doom--ensure-core-packages (packages)
(doom-log "Installing core packages")
(dolist (package packages)
(let ((name (car package)))
(let* ((name (car package))
(repo (symbol-name name)))
(when-let (recipe (plist-get (cdr package) :recipe))
(straight-override-recipe (cons name recipe)))
(straight-use-package name))))
(straight-override-recipe (cons name recipe))
(when-let (local-repo (plist-get recipe :local-repo))
(setq repo local-repo)))
;; Only clone the package, don't build them. Straight hasn't been fully
;; configured by this point.
(straight-use-package name nil t)
;; In case the package hasn't been built yet.
(or (member (directory-file-name (straight--build-dir "straight"))
load-path)
(add-to-list 'load-path (directory-file-name (straight--repos-dir repo)))))))
(defun doom-initialize-core-packages (&optional force-p)
"Ensure `straight' is installed and was compiled with this version of Emacs."

View file

@ -414,8 +414,8 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; which users expect to control hl-line in Emacs.
(define-globalized-minor-mode global-hl-line-mode hl-line-mode
(lambda ()
(and (not hl-line-mode)
(cond ((null global-hl-line-modes) nil)
(and (cond (hl-line-mode nil)
((null global-hl-line-modes) nil)
((eq global-hl-line-modes t))
((eq (car global-hl-line-modes) 'not)
(not (derived-mode-p global-hl-line-modes)))

View file

@ -1,7 +1,10 @@
;;; completion/company/config.el -*- lexical-binding: t; -*-
(use-package! company
:commands company-complete-common company-manual-begin company-grab-line
:commands (company-complete-common
company-complete-common-or-cycle
company-manual-begin
company-grab-line)
:hook (doom-first-input . global-company-mode)
:init
(setq company-minimum-prefix-length 2
@ -37,6 +40,9 @@
company-dabbrev-ignore-case nil
company-dabbrev-downcase nil)
(when (featurep! +tng)
(add-hook 'global-company-mode-hook #'company-tng-mode))
:config
(when (featurep! :editor evil)
(add-hook 'company-mode-hook #'evil-normalize-keymaps)
@ -60,8 +66,6 @@
(add-hook 'after-change-major-mode-hook #'+company-init-backends-h 'append)
(when (featurep! +tng)
(company-tng-mode +1))
;; NOTE Fix #1335: ensure `company-emulation-alist' is the first item of
;; `emulation-mode-map-alists', thus higher priority than keymaps of

View file

@ -38,7 +38,8 @@ directives. By default, this only recognizes C directives.")
evil-mode-line-format 'nil
;; more vim-like behavior
evil-symbol-word-search t
;; cursor appearance
;; if the current state is obvious from the cursor's color/shape, then
;; we won't need superfluous indicators to do it instead.
evil-default-cursor '+evil-default-cursor-fn
evil-normal-state-cursor 'box
evil-emacs-state-cursor '(box +evil-emacs-cursor-fn)
@ -310,7 +311,7 @@ directives. By default, this only recognizes C directives.")
(use-package! evil-escape
:commands evil-escape
:after-call pre-command-hook
:hook (doom-first-input . evil-escape-mode)
:init
(setq evil-escape-excluded-states '(normal visual multiedit emacs motion)
evil-escape-excluded-major-modes '(neotree-mode treemacs-mode vterm-mode)
@ -318,15 +319,14 @@ directives. By default, this only recognizes C directives.")
evil-escape-delay 0.15)
(evil-define-key* '(insert replace visual operator) 'global "\C-g" #'evil-escape)
:config
;; no `evil-escape' in minibuffer, unless `evil-collection-setup-minibuffer'
;; is enabled, where we could be in insert mode in the minibuffer.
;; `evil-escape' in the minibuffer is more disruptive than helpful. That is,
;; unless we have `evil-collection-setup-minibuffer' enabled, in which case we
;; want the same behavior in insert mode as we do in normal buffers.
(add-hook! 'evil-escape-inhibit-functions
(defun +evil-inhibit-escape-in-minibuffer-fn ()
(and (minibufferp)
(or (not (bound-and-true-p evil-collection-setup-minibuffer))
(evil-normal-state-p)))))
;; so that evil-escape-mode-hook runs, and can be toggled by evil-mc
(evil-escape-mode +1))
(evil-normal-state-p))))))
(use-package! evil-exchange
@ -351,20 +351,16 @@ directives. By default, this only recognizes C directives.")
(use-package! evil-snipe
:commands (evil-snipe-mode
evil-snipe-override-mode
evil-snipe-local-mode
evil-snipe-override-local-mode)
:after-call pre-command-hook
:commands evil-snipe-local-mode evil-snipe-override-local-mode
:hook (doom-first-input . evil-snipe-override-mode)
:hook (doom-first-input . evil-snipe-mode)
:init
(setq evil-snipe-smart-case t
evil-snipe-scope 'line
evil-snipe-repeat-scope 'visible
evil-snipe-char-fold t)
:config
(pushnew! evil-snipe-disabled-modes 'Info-mode 'calc-mode 'treemacs-mode)
(evil-snipe-mode +1)
(evil-snipe-override-mode +1))
(pushnew! evil-snipe-disabled-modes 'Info-mode 'calc-mode 'treemacs-mode))
(use-package! evil-surround

View file

@ -1,18 +1,18 @@
;; -*- no-byte-compile: t; -*-
;;; editor/parinfer/packages.el
(when (and (not (featurep! +rust)) (featurep! :editor evil))
;; Parinfer uses `evil-define-key' without loading evil, so if evil is
;; installed *after* parinfer, parinfer will throw up void-function errors.
;; because evil-define-key (a macro) wasn't expanded at compile-time. So we
;; make sure evil is installed before parinfer...
(package! evil)
;; ...and that it can see `evil-define-key' if evil was installed in a
;; separate session:
(autoload 'evil-define-key "evil-core" nil nil 'macro))
(if (featurep! +rust)
(package! parinfer-rust-mode :pin "f130fa04ec75131686872f24a253d0a1d5522fa4")
(when (featurep! :editor evil)
;; Parinfer uses `evil-define-key' without loading evil, so if evil is
;; installed *after* parinfer, parinfer will throw up void-function errors.
;; because evil-define-key (a macro) wasn't expanded at compile-time. So we
;; make sure evil is installed before parinfer...
(package! evil)
;; ...and that it can see `evil-define-key' if evil was installed in a
;; separate session:
(autoload 'evil-define-key "evil-core" nil nil 'macro))
(package! parinfer
:recipe (:host github :repo "emacsattic/parinfer")
:pin "8659c99a9475ee34af683fdf8f272728c6bebb3a"))

View file

@ -2,5 +2,6 @@
;;; editor/rotate-text/packages.el
(package! rotate-text
:recipe (:host github :repo "debug-ito/rotate-text.el")
:recipe (:host github
:repo "debug-ito/rotate-text.el")
:pin "48f193697db996855aee1ad2bc99b38c6646fe76")

View file

@ -172,10 +172,12 @@ https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
(defun +emacs-lisp/buttercup-run-file ()
"Run all buttercup tests in the focused buffer."
(interactive)
(let ((load-path (append (list (doom-path (dir!) "..")
(or (doom-project-root)
default-directory))
load-path)))
(let ((load-path
(append (list (doom-path (dir!) "..")
(or (doom-project-root)
default-directory))
load-path))
(buttercup-suites nil))
(save-selected-window
(eval-buffer)
(buttercup-run))
@ -188,7 +190,8 @@ https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
(let* ((default-directory (doom-project-root))
(load-path (append (list (doom-path "test")
default-directory)
load-path)))
load-path))
(buttercup-suites nil))
(buttercup-run-discover)))
;;;###autoload

View file

@ -6,11 +6,9 @@
(use-package! doom-themes
:defer t
:init
(setq doom-theme 'doom-one)
;; improve integration w/ org-mode
(add-hook 'doom-load-theme-hook #'doom-themes-org-config)
:hook (doom-load-theme . doom-themes-org-config)
:init (setq doom-theme 'doom-one)
;; more Atom-esque file icons for neotree/treemacs
(when (featurep! :ui neotree)
(add-hook 'doom-load-theme-hook #'doom-themes-neotree-config)

View file

@ -14,7 +14,10 @@
# With a specific version of Emacs
#
# nix-shell --argstr emacs 26 # 26.3
# nix-shell --argstr emacs 26.3 # 26.3
# nix-shell --argstr emacs 27 # 27.1
# nix-shell --argstr emacs 27.1 # 27.1
# nix-shell --argstr emacs 27.2 # 27.2
# nix-shell --argstr emacs 28 # 28.0.50
# nix-shell --argstr emacs gcc # 28.0.50 + native-comp
# nix-shell --argstr emacs pgtk+gcc # 28.0.50 + pgtk + native-comp
@ -41,6 +44,7 @@
, doomlocaldir ? "$(pwd)/.local" }:
let emacsPkg = (if emacs == "26" then pkgs.emacs26
else if emacs == "26.3" then pkgs.emacs26
else if emacs == "27" then pkgs.emacs27-2
else if emacs == "27.1" then pkgs.emacs27
else if emacs == "27.2" then pkgs.emacs27-2