theurgy/writing.el
2025-08-17 23:40:44 +08:00

91 lines
2.7 KiB
EmacsLisp

;;; writing.el --- Writing behavior configuration -*- lexical-binding: t -*-
;; This file is not part of GNU Emacs
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; commentary
;;; Code:
;; Save place in file
(save-place-mode 1)
;; Replace selection when pasting
(delete-selection-mode 1)
;; Enable auto-pairing for parens
(electric-pair-mode 1)
;; Enable narrowing
(put 'narrow-to-region 'disabled nil)
;;; Spell Checking
;; Use hunspell if available
(if (file-exists-p "/usr/bin/hunspell")
(progn
(eval-after-load "ispell"
'(progn
(setq ispell-program-name "hunspell"
ispell-dictionary "en_AU"
ispell-alternate-dictionary (file-truename (concat user-emacs-directory "en_AU.dict"))
ispell-local-dictionary-alist '(("en_AU" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_AU,en_AU-med") nil utf-8)))
(defun ispell-get-coding-system () 'utf-8)))
(eval-after-load "flyspell"
'(progn
(setq ispell-program-name "hunspell"
ispell-dictionary "en_AU"
ispell-alternate-dictionary (file-truename (concat user-emacs-directory "en_AU.dict"))
ispell-local-dictionary-alist '(("en_AU" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_AU,en_AU-med") nil utf-8)))
(defun ispell-get-coding-system () 'utf-8)))))
;; Visual undo tree
(use-package vundo
:straight (vundo :type git :host github :repo "casouri/vundo")
:config
;; Take less on-screen space.
(setq vundo-compact-display t)
:bind
(:map global-map
("C-x u" . vundo)))
;; Rainbow delimiters. Almost necessary for lisp.
(use-package rainbow-delimiters
:hook ((prog-mode . rainbow-delimiters-mode)))
;; Snippeting
(use-package yasnippet
;; This seems to be a necessity for working on the daemon
:hook ((server-after-make-frame . (lambda () (yas-global-mode 1))))
:config
(yas-global-mode 1)
(setq yas-snippet-dirs `(,(concat user-emacs-directory "snippets"))))
(use-package yasnippet-snippets
:after (yasnippet))
;; Indentation
(straight-use-package 'aggressive-indent-mode)
(global-aggressive-indent-mode 1)
(add-hook 'shell-mode-hook
#'(lambda () (aggressive-indent-mode 0)))
(provide 'writing)
;;; writing.el ends here