2025-12-14 04:51:24 +11:00
|
|
|
;; -*- lexical-binding: t -*-
|
|
|
|
|
|
2026-03-20 22:04:25 +11:00
|
|
|
(use-package delsel
|
|
|
|
|
:ensure nil
|
|
|
|
|
:hook (elpaca-after-init . delete-selection-mode))
|
|
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
(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)))
|
2026-02-28 19:27:53 +11:00
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
(sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
|
2026-02-28 19:27:53 +11:00
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
;; 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")))
|
2026-02-28 19:27:53 +11:00
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
;; 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)))))
|
2026-02-22 23:29:18 +11:00
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
;; (use-package electric-pair
|
|
|
|
|
;; :ensure nil
|
|
|
|
|
;; :hook elpaca-after-init)
|
2025-12-14 04:51:24 +11:00
|
|
|
|
2025-12-27 16:41:42 +08:00
|
|
|
;; 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)))
|
2026-02-28 19:27:53 +11:00
|
|
|
|
2026-02-25 22:12:47 +11:00
|
|
|
(use-package abbrev
|
|
|
|
|
:diminish
|
|
|
|
|
:ensure nil
|
|
|
|
|
:config
|
|
|
|
|
(setq-default abbrev-mode t)
|
|
|
|
|
(setq abbrev-file-name (expand-file-name "abbrev.el" user-emacs-directory)))
|
2025-12-16 08:23:57 +11:00
|
|
|
|
2025-12-22 10:51:46 +11:00
|
|
|
(use-package autorevert
|
|
|
|
|
:ensure nil
|
|
|
|
|
:diminish
|
2026-02-25 22:12:47 +11:00
|
|
|
:hook (elpaca-after-init . global-auto-revert-mode))
|
2025-12-22 10:51:46 +11:00
|
|
|
|
2026-03-20 22:04:25 +11:00
|
|
|
(use-package goto-addr
|
|
|
|
|
:ensure nil
|
|
|
|
|
:hook ((text-mode . goto-address-mode)
|
|
|
|
|
(prog-mode . goto-address-prog-mode)))
|
|
|
|
|
|
2025-12-22 10:51:46 +11:00
|
|
|
(use-package multiple-cursors
|
|
|
|
|
:hook elpaca-after-init
|
2026-03-20 00:44:25 +11:00
|
|
|
:bind (("C-S-c C-S-c" . mc/edit-lines)
|
2025-12-22 10:51:46 +11:00
|
|
|
("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-<mouse-1>" . mc/add-cursor-on-click)
|
|
|
|
|
("C-S-<mouse-1>" . mc/add-cursor-on-click)
|
|
|
|
|
:map mc/keymap
|
2026-03-20 00:44:25 +11:00
|
|
|
("C-|" . mc/vertical-align-with-space)))
|
2025-12-22 10:51:46 +11:00
|
|
|
|
|
|
|
|
(use-package smart-region
|
|
|
|
|
:hook (after-init . smart-region-on))
|
2025-12-14 04:51:24 +11:00
|
|
|
|
2025-12-22 12:30:25 +11:00
|
|
|
(use-package mwim
|
|
|
|
|
:bind (([remap move-beginning-of-line] . mwim-beginning)
|
|
|
|
|
([remap move-end-of-line] . mwim-end)))
|
|
|
|
|
|
2025-12-23 08:23:35 +11:00
|
|
|
(use-package avy
|
|
|
|
|
:bind
|
2026-03-20 22:04:25 +11:00
|
|
|
(("C-'" . avy-goto-char-timer))
|
|
|
|
|
:config
|
|
|
|
|
(setq avy-all-windows nil
|
|
|
|
|
avy-all-windows-alt t
|
|
|
|
|
avy-background t
|
|
|
|
|
avy-style 'pre))
|
|
|
|
|
|
|
|
|
|
;; Kill text between cursor and char
|
|
|
|
|
(use-package avy-zap
|
|
|
|
|
:bind (("M-z" . avy-zap-to-char-dwim)
|
|
|
|
|
("M-Z" . avy-zap-up-to-char-dwim)))
|
|
|
|
|
|
|
|
|
|
(use-package ace-pinyin
|
|
|
|
|
:diminish
|
|
|
|
|
:hook (elpaca-after-init . ace-pinyin-global-mode))
|
|
|
|
|
|
|
|
|
|
;; show number of matches
|
|
|
|
|
(use-package anzu
|
|
|
|
|
:diminish
|
|
|
|
|
:bind (([remap query-replace] . anzu-query-replace)
|
|
|
|
|
([remap query-replace-regexp] . anzu-query-replace-regexp)
|
|
|
|
|
:map isearch-mode-map
|
|
|
|
|
([remap isearch-query-replace] . anzu-isearch-query-replace)
|
|
|
|
|
([remap isearch-query-replace-regexp] . anzu-isearch-query-replace-regexp))
|
|
|
|
|
:hook (elpaca-after-init . global-anzu-mode))
|
|
|
|
|
|
|
|
|
|
;; Goto last change
|
|
|
|
|
(use-package goto-chg
|
|
|
|
|
:bind ("C-," . goto-last-change))
|
2025-12-23 08:23:35 +11:00
|
|
|
|
|
|
|
|
;; Treat undo history as a tree
|
|
|
|
|
(use-package vundo
|
|
|
|
|
:bind ("C-x u" . vundo)
|
|
|
|
|
:config (setq vundo-glyph-alist vundo-unicode-symbols))
|
|
|
|
|
|
2026-02-28 19:27:53 +11:00
|
|
|
;; Remember undo history
|
|
|
|
|
(use-package undo-fu-session
|
|
|
|
|
:hook (elpaca-after-init . undo-fu-session-global-mode))
|
|
|
|
|
|
2026-02-21 08:47:38 +11:00
|
|
|
(use-package olivetti
|
|
|
|
|
:hook org-mode
|
|
|
|
|
:custom
|
|
|
|
|
(olivetti-style 'fancy)
|
2026-02-22 05:24:39 +11:00
|
|
|
(olivetti-margin-width 5)
|
|
|
|
|
(olivetti-body-width 90))
|
2026-02-21 08:47:38 +11:00
|
|
|
|
2025-12-14 04:51:24 +11:00
|
|
|
(provide 'init-edit)
|