[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode dbbe488 265/385: abbrevs don't fire in co
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode dbbe488 265/385: abbrevs don't fire in comments / strings |
Date: |
Tue, 5 Oct 2021 23:59:44 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit dbbe4888487abb7473cd76e15f3fcc207869b190
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
abbrevs don't fire in comments / strings
---
haskell-tng-extra-abbrev.el | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/haskell-tng-extra-abbrev.el b/haskell-tng-extra-abbrev.el
index 285cd5e..e897cc7 100644
--- a/haskell-tng-extra-abbrev.el
+++ b/haskell-tng-extra-abbrev.el
@@ -14,22 +14,35 @@
(require 'haskell-tng-mode)
;; TODO a macro to easily define an abbrev and skeleton?
-;; TODO don't fire abbrevs in comments
(abbrev-table-put
haskell-tng-mode-abbrev-table
:regexp (rx (or bol space) ;; don't fire for \case
(submatch (+ (not space))) point))
+(defun haskell-tng--abbrev-expand-p ()
+ "abbrevs should not expand in strings and comments."
+ (not (nth 8 (syntax-ppss))))
+
(define-skeleton haskell-tng--skeleton-case-of
"case...of boilerplate"
nil "case " _ " of")
-
(define-abbrev
haskell-tng-mode-abbrev-table
"case" "" #'haskell-tng--skeleton-case-of
:system t
- :case-fixed t)
+ :case-fixed t
+ :enable-function #'haskell-tng--abbrev-expand-p)
+
+(define-skeleton haskell-tng--skeleton-if-then-else
+ "if...then...else boilerplate"
+ nil "if " _ " then else")
+(define-abbrev
+ haskell-tng-mode-abbrev-table
+ "if" "" #'haskell-tng--skeleton-if-then-else
+ :system t
+ :case-fixed t
+ :enable-function #'haskell-tng--abbrev-expand-p)
(add-hook
'haskell-tng-mode-hook
- [nongnu] elpa/haskell-tng-mode 232baf8 362/385: less import suggestions, (continued)
- [nongnu] elpa/haskell-tng-mode 232baf8 362/385: less import suggestions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ab53433 375/385: reprioritise, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2b9c6bf 369/385: support dev hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 68d1d7c 371/385: bump hsinspect, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6a31b59 101/385: document the plan for indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 9ec4841 104/385: meh indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ea46850 207/385: bugfix for compile vs runtime loading, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 63b1c8d 250/385: flip the default newline / comment behaviour, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 83458d6 253/385: reverting newline comment behaviour, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f59c9ee 259/385: fix indentation of short type signatures, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode dbbe488 265/385: abbrevs don't fire in comments / strings,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode f56bd2a 256/385: prefer optimised hsinspect builds, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e84970b 263/385: rename -contrib to -extra, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode af443a1 269/385: fix a name clash in the tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cce466c 271/385: hsinspect now has a compiler plugin, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d0cd9b9 252/385: documenting an annoying indentation bug, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode afbac7c 300/385: missing import, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7060573 286/385: moar work to do here, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 89db192 289/385: more thots, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode b46dbd1 305/385: refactoring of the cache for more reuse later, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ff76e07 304/385: cache the index command, ELPA Syncer, 2021/10/06