Klimi's new dotfiles with stow.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

66 wiersze
2.5 KiB

4 lat temu
  1. ;;; ghci-script-mode.el --- GHCi scripts major mode -*- lexical-binding: t -*-
  2. ;; Copyright (c) 2014 Chris Done. All rights reserved.
  3. ;; This file is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation; either version 3, or (at your option)
  6. ;; any later version.
  7. ;; This file is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Code:
  14. (require 'haskell)
  15. (defvar ghci-script-mode-keywords
  16. ;; The comment syntax can't be described simply in syntax-table.
  17. ;; We could use font-lock-syntactic-keywords, but is it worth it?
  18. '(("^[ \t]*--.*" . font-lock-comment-face)
  19. ("^ *\\([^ \t:]+\\):" (1 font-lock-keyword-face))
  20. ("^:[a-z{]+ *\\+" . font-lock-keyword-face)
  21. ("^:[a-z{]+ " . font-lock-keyword-face)))
  22. ;;;###autoload
  23. (define-derived-mode ghci-script-mode text-mode "GHCi-Script"
  24. "Major mode for working with .ghci files."
  25. (setq-local adaptive-fill-mode nil)
  26. (setq-local comment-start "-- ")
  27. (setq-local comment-padding 0)
  28. (setq-local comment-start-skip "[-{]-[ \t]*")
  29. (setq-local comment-end "")
  30. (setq-local comment-end-skip "[ \t]*\\(-}\\|\\s>\\)")
  31. (setq-local font-lock-defaults '(ghci-script-mode-keywords t t nil nil))
  32. (setq-local indent-tabs-mode nil)
  33. (setq-local tab-width 8)
  34. (when (boundp 'electric-indent-inhibit)
  35. (setq electric-indent-inhibit t))
  36. (setq-local dabbrev-case-fold-search nil)
  37. (setq-local dabbrev-case-distinction nil)
  38. (setq-local dabbrev-case-replace nil)
  39. (setq-local dabbrev-abbrev-char-regexp "\\sw\\|[.]")
  40. (setq haskell-literate nil))
  41. ;;;###autoload
  42. (add-to-list 'auto-mode-alist '("\\.ghci\\'" . ghci-script-mode))
  43. (define-key ghci-script-mode-map (kbd "C-c C-l") 'ghci-script-mode-load)
  44. (defun ghci-script-mode-load ()
  45. "Load the current script file into the GHCi session."
  46. (interactive)
  47. (let ((buffer (haskell-session-interactive-buffer (haskell-session)))
  48. (filename (buffer-file-name)))
  49. (save-buffer)
  50. (with-current-buffer buffer
  51. (set-marker haskell-interactive-mode-prompt-start (point-max))
  52. (haskell-interactive-mode-run-expr
  53. (concat ":script " filename)))))
  54. (provide 'ghci-script-mode)