From 0f22bb9729868e190bb716166c544c5d76147f85 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 10 Dec 2020 20:52:52 -0800 Subject: [PATCH] Add abbrevs to C, Java, and C# modes --- oni-c.el | 10 ++++++++-- oni-csharp/oni-csharp.el | 6 +++++- oni-java.el | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/oni-c.el b/oni-c.el index cfa360d..bbe37c2 100644 --- a/oni-c.el +++ b/oni-c.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2020.0907.143822 +;; Version: 2020.1210.205244 ;; Package-Requires: (oni-flycheck oni-fci) ;; This program is free software; you can redistribute it and/or modify @@ -26,13 +26,16 @@ ;;; Code: +(require 'cc-mode) + (defun oni-c--auto-fill-mode () "Enable ‘auto-fill-mode’ only for comments." (setq-local comment-auto-fill-only-comments t) (auto-fill-mode)) -(add-hook 'c-mode-hook 'electric-pair-local-mode) +(add-hook 'c-mode-hook 'abbrev-mode) (add-hook 'c-mode-hook 'electric-indent-local-mode) +(add-hook 'c-mode-hook 'electric-pair-local-mode) (add-hook 'c-mode-hook 'flycheck-mode) (add-hook 'c-mode-hook 'oni-c--auto-fill-mode) @@ -41,6 +44,9 @@ 'display-fill-column-indicator-mode 'fci-mode)) +(define-abbrev c-mode-abbrev-table "and" "&&") +(define-abbrev c-mode-abbrev-table "or" "||") + ;;;###autoload(with-eval-after-load 'cc-mode (require 'oni-c)) (provide 'oni-c) diff --git a/oni-csharp/oni-csharp.el b/oni-csharp/oni-csharp.el index 370c256..13bc1cc 100644 --- a/oni-csharp/oni-csharp.el +++ b/oni-csharp/oni-csharp.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2020.0907.151110 +;; Version: 2020.1210.205218 ;; Package-Requires: (csharp-mode oni-company oni-flycheck oni-yasnippet oni-hydra oni-fci oni-lsp smartparens) ;; This program is free software; you can redistribute it and/or modify @@ -142,6 +142,7 @@ _cs_: Solution "Set style rules according to personal (or recommended) preference." (setf (alist-get 'arglist-intro c-offsets-alist) '+)) +(add-hook 'csharp-mode-hook 'abbrev-mode) (add-hook 'csharp-mode-hook 'company-mode) (add-hook 'csharp-mode-hook 'electric-indent-local-mode) (add-hook 'csharp-mode-hook 'flycheck-mode) @@ -158,6 +159,9 @@ _cs_: Solution (define-key csharp-mode-map (kbd "C-c SPC") 'oni-csharp-hydra/body) +(define-abbrev csharp-mode-abbrev-table "and" "&&") +(define-abbrev csharp-mode-abbrev-table "or" "||") + ;;;###autoload (add-to-list 'auto-mode-alist '("\\.xaml\\'" . nxml-mode)) diff --git a/oni-java.el b/oni-java.el index ec62205..e1a995f 100644 --- a/oni-java.el +++ b/oni-java.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2020.1030.182339 +;; Version: 2020.1210.205100 ;; Package-Requires: (oni-fci oni-data-dir oni-lsp oni-hydra lsp-java) ;; This program is free software; you can redistribute it and/or modify @@ -69,6 +69,7 @@ (add-hook 'java-mode-hook #'oni-java-enable-buffer-formatting) (add-hook 'java-mode-hook #'oni-java-only-fill-comments) +(add-hook 'java-mode-hook 'abbrev-mode) (add-hook 'java-mode-hook 'auto-fill-mode) (add-hook 'java-mode-hook 'electric-indent-local-mode) (add-hook 'java-mode-hook 'electric-pair-local-mode) @@ -82,6 +83,9 @@ (define-key java-mode-map (kbd "C-c r") 'java-refactor-hydra/body) (define-key java-mode-map (kbd "C-c d") 'java-documentation-hydra/body) +(define-abbrev java-mode-abbrev-table "and" "&&") +(define-abbrev java-mode-abbrev-table "or" "||") + (add-to-list 'auto-insert-alist '("\\.java\\'" () "public class "