diff options
Diffstat (limited to '.config/emacs/modules/mm-editing.el')
-rw-r--r-- | .config/emacs/modules/mm-editing.el | 133 |
1 files changed, 85 insertions, 48 deletions
diff --git a/.config/emacs/modules/mm-editing.el b/.config/emacs/modules/mm-editing.el index 50a31c9..540bae4 100644 --- a/.config/emacs/modules/mm-editing.el +++ b/.config/emacs/modules/mm-editing.el @@ -24,18 +24,20 @@ (dolist (command #'(align-region c-backslash-region comment-dwim - makefile-backslash-region)) + makefile-backslash-region + sh-backslash-region)) (advice-add command :around #'mm-editing-force-space-indentation)) ;;; Recenter The Screen When Jumping -(dolist (command #'(backward-page - backward-paragraph - forward-page - forward-paragraph - pop-global-mark)) - (advice-add command :around #'mm-do-and-center)) +(mm-comment + (dolist (command #'(backward-page + backward-paragraph + forward-page + forward-paragraph + pop-global-mark)) + (advice-add command :around #'mm-do-and-center))) ;;; Indentation Settings @@ -45,7 +47,8 @@ indent-tabs-mode (not mm-humanwave-p)) (defvar mm-editing-indentation-settings-alist - '((c-mode . (:extras c-basic-offset)) + '((awk-ts-mode . (:extras awk-ts-mode-indent-level)) + (c-mode . (:extras c-basic-offset)) (c-ts-mode . (:extras c-ts-mode-indent-offset)) (css-mode . (:extras css-indent-offset)) (emacs-lisp-mode . (:width 8 :spaces t)) ; GNU code uses 8-column tabs @@ -64,7 +67,10 @@ (sgml-mode . (:extras sgml-basic-offset)) (sh-mode . (:extras sh-basic-offset)) (tex-mode . (:width 2)) - (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level))) + (typescript-ts-mode . (:extras typescript-ts-mode-indent-offset)) + (vimscript-ts-mode . (:extras vimscript-ts-mode-indent-level)) + (vue-ts-mode . (:extras (typescript-ts-mode-indent-offset + vue-ts-mode-indent-offset)))) "Alist of indentation settings. Each pair in this alist is of the form (MODE . SETTINGS) where MODE specifies the mode for which the given SETTINGS should apply. @@ -122,18 +128,22 @@ those should be listed in `mm-editing-indentation-settings'." ;;; Code Commenting -(defun mm-c-comment-no-leading-stars () +(defun mm-c-comment-no-continue () (setq-local comment-continue " ")) +(defun mm-mhtml-comment-no-continue () + (setq-local comment-continue " ")) + (use-package newcomment :custom (comment-style 'multi-line) :config (dolist (mode '(c-mode c++-mode)) - (add-hook (mm-mode-to-hook mode) #'mm-c-comment-no-leading-stars) + (add-hook (mm-mode-to-hook mode) #'mm-c-comment-no-continue) (when-let ((ts-mode (mm-mode-to-ts-mode mode)) ((fboundp ts-mode))) - (add-hook (mm-mode-to-hook ts-mode) #'mm-c-comment-no-leading-stars)))) + (add-hook (mm-mode-to-hook ts-mode) #'mm-c-comment-no-continue))) + (add-hook 'mhtml-mode #'mm-mhtml-comment-no-continue)) ;;; Multiple Cursors @@ -150,7 +160,6 @@ region are marked, otherwise all matches in the buffer are marked." (or (use-region-end) (point-max)) (read-string (format-prompt ,(concat "Match " noun) nil)))) - (require 'multiple-cursors) (if (string-empty-p ,noun-symbol) (message "Command aborted") (catch 'mm--no-match @@ -177,47 +186,52 @@ region are marked, otherwise all matches in the buffer are marked." (mm--define-mc-marking-command mm-mark-all-in-region-regexp re-search-forward "regexp") -(defun mm-silent-mc-load (args) - "Advice to `load' to force it to be silent. The `multiple-cursors' -package loads an `.mc-lists.el' file without passing `:nomessage' which -causes messages to be sent in the minibuffer and *Messages* buffer. This -forces that to not happen." - (when (and (boundp 'mc/list-file) - (string= (car args) mc/list-file)) - (pcase (length args) - (1 (setq args (list (car args) nil :nomessage))) - (2 (add-to-list 'args :nomessage :append)) - (_ (setf (caddr args) :nomessage))) - (advice-remove #'load #'mm-silent-mc-load)) - args) +(mm-comment + (defun mm-silent-mc-load (args) + "Advice to `load' to force it to be silent. +The `multiple-cursors' package loads an `.mc-lists.el' file without +passing `:nomessage' which causes messages to be sent in the minibuffer +and *Messages* buffer. This forces that to not happen." + (when (and (boundp 'mc/list-file) + (string= (file-truename (car args)) + (file-truename mc/list-file))) + (pcase (length args) + (1 (setq args (list (car args) nil :nomessage))) + (2 (add-to-list 'args :nomessage :append)) + (_ (setf (caddr args) :nomessage))) + (advice-remove #'load #'mm-silent-mc-load)) + args)) (use-package multiple-cursors :ensure t - :defer 2 + :demand t :bind (("C->" . #'mc/mark-next-like-this) ("C-<" . #'mc/mark-previous-like-this) ("C-M-<" . #'mc/mark-all-like-this-dwim) ("C-M->" . #'mc/edit-lines) - ("C-$" . #'mm-mark-all-in-region) + :map search-map + ("$" . #'mm-mark-all-in-region) ("M-$" . #'mm-mark-all-in-region-regexp)) + :commands ( mm-mark-all-in-region mm-mark-all-in-region-regexp + mm-add-cursor-to-next-thing mm-transpose-cursor-regions) :init - (advice-add #'load :filter-args #'mm-silent-mc-load) + (mm-comment + (advice-add #'load :filter-args #'mm-silent-mc-load) + (with-eval-after-load 'multiple-cursors-core + (dolist (command #'(backward-delete-char + capitalize-dwim + delete-backward-char + delete-forward-char + downcase-dwim + upcase-dwim)) + (add-to-list 'mc/cmds-to-run-for-all command)) + (dolist (command #'(helpful-callable + helpful-key + helpful-symbol + helpful-variable)) + (add-to-list 'mc/cmds-to-run-once command)))) (with-eval-after-load 'multiple-cursors-core - (dolist (command #'(backward-delete-char - capitalize-dwim - delete-backward-char - delete-forward-char - downcase-dwim - upcase-dwim)) - (add-to-list 'mc/cmds-to-run-for-all command)) - (dolist (command #'(helpful-callable - helpful-key - helpful-symbol - helpful-variable)) - (add-to-list 'mc/cmds-to-run-once command)) - (add-to-list 'mc/unsupported-minor-modes #'corfu-mode)) - :config - (keymap-unset mc/keymap "<return>" :remove)) + (keymap-unset mc/keymap "<return>" :remove))) ;;; Increment Numbers @@ -304,11 +318,33 @@ is as described by `emmet-expand-line'." (emmet-self-closing-tag-style "")) +;;; Number Formatting + +(use-package number-format-mode + :commands ( number-format-buffer number-format-region + number-unformat-buffer number-unformat-region + number-format-mode)) + + ;;; Additional Major Modes -(use-package csv-mode :ensure t) -(use-package git-modes :ensure t) -(use-package sed-mode :ensure t) +(use-package awk-ts-mode :ensure t) +(use-package git-modes :ensure t) +(use-package po-mode :ensure t) +(use-package sed-mode :ensure t) + +(use-package csv-mode + :ensure t + :custom + (csv-align-style 'auto) + (csv-align-padding 2)) + +(use-package xcompose-mode + :vc ( :url "https://git.thomasvoss.com/xcompose-mode" + :branch "master" + :rev :newest + :vc-backend Git) + :ensure t) ;;; Mode-Specific Configurations @@ -325,6 +361,7 @@ is as described by `emmet-expand-line'." ;;; Add Missing Extensions -(add-to-list 'auto-mode-alist '("\\.tmac\\'" . nroff-mode)) +(dolist (pattern '("\\.tmac\\'" "\\.mom\\'")) + (add-to-list 'auto-mode-alist (cons pattern 'nroff-mode))) (provide 'mm-editing)
\ No newline at end of file |