;; -*- lexical-binding: t -*- (use-package smartparens :diminish :hook (elpaca-after-init . smartparens-global-mode) ;; :hook (elpaca-after-init . smartparens-global-strict-mode) :init (sp-use-paredit-bindings) :config ;; Autopair quotes more conservatively; if I'm next to a word/before another ;; quote, I don't want to open a new pair or it would unbalance them. (let ((unless-list '(sp-point-before-word-p sp-point-after-word-p sp-point-before-same-p))) (sp-pair "'" nil :unless unless-list) (sp-pair "\"" nil :unless unless-list)) (dolist (brace '("(" "{" "[")) (sp-pair brace nil :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) ;; Don't autopair opening braces if before a word character or ;; other opening brace. The rationale: it interferes with manual ;; balancing of braces, and is odd form to have s-exps with no ;; whitespace in between, e.g. ()()(). Insert whitespace if ;; genuinely want to start a new form in the middle of a word. :unless '(sp-point-before-word-p sp-point-before-same-p))) (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) ;; Don't do square-bracket space-expansion where it doesn't make sense to (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode markdown-ts-mode gfm-mode) "[" nil :post-handlers '(:rem ("| " "SPC"))) ;; resolve conflict with hungry-delete (defadvice hungry-delete-backward (before sp-delete-pair-advice activate) (save-match-data (sp-delete-pair (ad-get-arg 0))))) ;; (use-package electric-pair ;; :ensure nil ;; :hook elpaca-after-init) ;; Hungry deletion (use-package hungry-delete :diminish :hook (elpaca-after-init . global-hungry-delete-mode) :init (setq hungry-delete-chars-to-skip " \t\f\v" hungry-delete-except-modes '(help-mode minibuffer-mode minibuffer-inactive-mode calc-mode))) (use-package abbrev :diminish :ensure nil :config (setq-default abbrev-mode t) (setq abbrev-file-name (expand-file-name "abbrev.el" user-emacs-directory))) (use-package autorevert :ensure nil :diminish :hook (elpaca-after-init . global-auto-revert-mode)) (use-package multiple-cursors :hook elpaca-after-init :bind (("C-c m" . multiple-cursors-hydra/body) ("C-S-c C-S-c" . mc/edit-lines) ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-<" . mc/mark-all-like-this) ("C-M->" . mc/skip-to-next-like-this) ("C-M-<" . mc/skip-to-previous-like-this) ("s-" . mc/add-cursor-on-click) ("C-S-" . mc/add-cursor-on-click) :map mc/keymap ("C-|" . mc/vertical-align-with-space)) :pretty-hydra ((:color amaranth :quit-key ("q" "C-g") :hint nil) ("Up" (("p" mc/mark-previous-like-this "prev") ("P" mc/skip-to-previous-like-this "skip") ("M-p" mc/unmark-previous-like-this "unmark") ("|" mc/vertical-align "align with input CHAR")) "Down" (("n" mc/mark-next-like-this "next") ("N" mc/skip-to-next-like-this "skip") ("M-n" mc/unmark-next-like-this "unmark")) "Misc" (("l" mc/edit-lines "edit lines" :exit t) ("a" mc/mark-all-like-this "mark all" :exit t) ("s" mc/mark-all-in-region-regexp "search" :exit t) ("" mc/add-cursor-on-click "click")) "% 2(mc/num-cursors) cursor%s(if (> (mc/num-cursors) 1) \"s\" \"\")" (("0" mc/insert-numbers "insert numbers" :exit t) ("A" mc/insert-letters "insert letters" :exit t))))) (use-package smart-region :hook (after-init . smart-region-on)) (use-package mwim :bind (([remap move-beginning-of-line] . mwim-beginning) ([remap move-end-of-line] . mwim-end))) (use-package avy :bind (("C-'" . avy-goto-char-timer))) ;; Treat undo history as a tree (use-package vundo :bind ("C-x u" . vundo) :config (setq vundo-glyph-alist vundo-unicode-symbols)) (use-package olivetti :hook org-mode :custom (olivetti-style 'fancy) (olivetti-margin-width 5) (olivetti-body-width 90)) (provide 'init-edit)