From 356931d9e332e06ffcc1d23e2e47c94337292980 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 27 Sep 2020 21:56:52 +0100 Subject: (Emacs)+config for abbrevs Adds a macro to make abbrevs easier to insert --- Emacs/.config/emacs/config.org | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'Emacs/.config/emacs') diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org index 9f1f4af..8ade726 100644 --- a/Emacs/.config/emacs/config.org +++ b/Emacs/.config/emacs/config.org @@ -849,6 +849,46 @@ are for simple expressions wherein there is only one user input (say, getting today's time which only requires you asking for it). They provide a lot of inbuilt functionality and are quite useful. Skeletons, on the other hand, are for higher level insertions +*** Abbrevs +Just define a few abbrevs for various date-time operations. Also +define a macro that will assume a function for the expansion, helping +with abstracting a few things away. +#+begin_src emacs-lisp +(use-package abbrev + :straight nil + :hook + (prog-mode-hook . abbrev-mode) + (text-mode-hook . abbrev-mode) + :init + (defmacro +snippets/deff-abbrev (ABBREV-TABLE ABBREV EXPANSION) + "Wraps around define-abbrev to fill in some repeated stuff + when expansion is a function." + `(define-abbrev + ,ABBREV-TABLE + ,ABBREV + "" + (proc (insert ,EXPANSION)))) + :config + (+snippets/deff-abbrev + global-abbrev-table + "fdate" + (format-time-string "%Y-%m-%d" (current-time))) + + (+snippets/deff-abbrev + global-abbrev-table + "ftime" + (format-time-string "%H:%M:%S" (current-time))) + + (+snippets/deff-abbrev + text-mode-abbrev-table + "fday" + (format-time-string "%A" (current-time))) + + (+snippets/deff-abbrev + text-mode-abbrev-table + "fmonth" + (format-time-string "%B" (current-time)))) +#+end_src *** Yasnippet default :PROPERTIES: :header-args:emacs-lisp: :tangle no -- cgit v1.2.3-13-gbd6f