[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-mode 9186f45d52 11/24: Add interactive command to
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-mode 9186f45d52 11/24: Add interactive command to insert a LANGUAGE pragma |
Date: |
Tue, 1 Nov 2022 22:58:52 -0400 (EDT) |
branch: elpa/haskell-mode
commit 9186f45d520621f95136163020cefc192e235d7a
Author: Tikhon Jelvis <tikhon@jelv.is>
Commit: Tikhon Jelvis <tikhon@jelv.is>
Add interactive command to insert a LANGUAGE pragma
I need to manually add `{-# LANUGAGE _ #-}` pragmas to the top of my
modules pretty often, so I wrote a function to do this. I've been using it for
a few days and found it really convenient, and other people liked the idea when
I mentioned it on Twitter.
Called interactively it uses `haskell-ghc-supported-extensions` for
completions which means less typing and no more errors like using
`RecordWildcards` instead of `RecordWildCards`.
I bound it to `C-c C-e` on my own setup, but not sure whether it makes
sense to include a keybinding for it by default.
---
haskell-commands.el | 10 ++++++++++
tests/haskell-mode-tests.el | 9 +++++++++
2 files changed, 19 insertions(+)
diff --git a/haskell-commands.el b/haskell-commands.el
index fba236d47e..89f02e5991 100644
--- a/haskell-commands.el
+++ b/haskell-commands.el
@@ -36,6 +36,7 @@
(require 'haskell-utils)
(require 'highlight-uses-mode)
(require 'haskell-cabal)
+(require 'haskell-ghc-support)
(defcustom haskell-mode-stylish-haskell-path "stylish-haskell"
"Path to `stylish-haskell' executable."
@@ -935,5 +936,14 @@ newlines and extra whitespace in signature before
insertion."
(insert sig "\n")
(indent-to col)))))
+(defun haskell-mode-add-language-pragma (extension)
+ "Insert a {-# LANGUAGE _ #-} pragma at the top of the current
+buffer for the given extension."
+ (interactive
+ (list (completing-read "Extension: " haskell-ghc-supported-extensions)))
+ (save-excursion
+ (beginning-of-buffer)
+ (insert (format "{-# LANGUAGE %s #-}\n" extension))))
+
(provide 'haskell-commands)
;;; haskell-commands.el ends here
diff --git a/tests/haskell-mode-tests.el b/tests/haskell-mode-tests.el
index d31fe55704..e6c9264f36 100644
--- a/tests/haskell-mode-tests.el
+++ b/tests/haskell-mode-tests.el
@@ -666,4 +666,13 @@ moves over sexps."
(goto-char (point-min))
(should (looking-at-p "main = return ()")))))))
+(ert-deftest haskell-mode-add-language-pragma-with-existing-text ()
+ (with-temp-buffer
+ (haskell-mode)
+ (insert "module Main where\n")
+ (end-of-buffer)
+ (haskell-mode-add-language-pragma "ViewPatterns")
+ (should (string= (buffer-string)
+ "{-# LANGUAGE ViewPatterns #-}\nmodule Main where\n"))))
+
(provide 'haskell-mode-tests)
- [nongnu] elpa/haskell-mode f13b6db78b 07/24: Merge pull request #1771 from amesgen/add-capi, (continued)
- [nongnu] elpa/haskell-mode f13b6db78b 07/24: Merge pull request #1771 from amesgen/add-capi, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 952af0ed21 12/24: typos, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode fe3a8046aa 20/24: Merge pull request #1778 from cydparser/ghc-9.2.2-support, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 8d9b271e9c 15/24: Fix minor typo, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode d0e8ca71d2 19/24: Add GHC 9.2.2 extensions and options, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 8402caa341 05/24: Remove inconsistent docstring, point users at the source of truth, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode b2427232ab 02/24: Fix compilation command to handle whitespace in file path, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode a8f23d8fa1 06/24: Add `capi` calling convention, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 5750f74d89 09/24: Merge pull request #1773 from minad/reduce-autoloads, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode b1505b727b 10/24: Merge pull request #1645 from juliapath/pragmas-are-no-paragraphs, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 9186f45d52 11/24: Add interactive command to insert a LANGUAGE pragma,
ELPA Syncer <=
- [nongnu] elpa/haskell-mode 19922b81ed 14/24: Fix code based on suggestions, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode cb573c8db5 16/24: Merge pull request #1774 from TikhonJelvis/add-language-pragma-command, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode f53827f074 17/24: Add Emacs 28.1 to CI matrix, update install-nix-action, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 4ec2aa32b1 18/24: Fix emacs version in CI, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 5a9f8072c7 21/24: Reformat docstring to satisfy Emacs 28.1 byte compiler, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 4010de30ec 22/24: The emacs upstream will raise an error now when `otherwise` or `t`, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode f988332a3d 23/24: Add Emacs 28.2 to CI, cut down matrix a little, ELPA Syncer, 2022/11/01
- [nongnu] elpa/haskell-mode 90503413f4 24/24: Merge pull request #1784 from VitalyAnkh/fix_cl_case_error, ELPA Syncer, 2022/11/01