Skip to content

Commit 7ec3407

Browse files
committed
Export purescript-literate from a shared location
This gets rid of repeated "defvar"s in different files by instead importing the variable from a shared location.
1 parent 9412ed0 commit 7ec3407

File tree

6 files changed

+38
-15
lines changed

6 files changed

+38
-15
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ELFILES = \
2525
purescript-utils.el \
2626
purescript-decl-scan.el \
2727
purescript-yas.el \
28+
purescript-vars.el \
2829
tests/purescript-sort-imports-tests.el \
2930
tests/purescript-indentation-tests.el \
3031
tests/purescript-font-lock-tests.el \

purescript-font-lock.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969

7070
(require 'font-lock)
7171
(require 'cl-lib)
72+
(require 'purescript-vars)
7273

7374
(defcustom purescript-font-lock-prettify-symbols-alist
7475
`(("/\\" . ,(decode-char 'ucs #X2227))
@@ -263,8 +264,6 @@ Returns keywords suitable for `font-lock-keywords'."
263264
:type 'boolean
264265
:group 'purescript)
265266

266-
(defvar purescript-literate)
267-
268267
(defun purescript-syntactic-face-function (state)
269268
"`font-lock-syntactic-face-function' for PureScript."
270269
(cond

purescript-indent.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@
8888

8989
;;; Code:
9090

91+
(require 'purescript-vars)
9192
(require 'purescript-string)
9293
(require 'cl-lib)
9394

94-
(defvar purescript-literate)
95-
9695
(defgroup purescript-indent nil
9796
"PureScript indentation."
9897
:group 'purescript

purescript-indentation.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
(require 'syntax)
3636
(require 'cl-lib)
37+
(require 'purescript-vars)
3738

3839
(defvar delete-active-region)
3940

@@ -47,7 +48,6 @@
4748
(defvar parse-line-number)
4849
(defvar possible-indentations)
4950
(defvar indentation-point)
50-
(defvar purescript-literate)
5151

5252
(defgroup purescript-indentation nil
5353
"PureScript indentation."

purescript-mode.el

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
(require 'dabbrev)
3535
(require 'compile)
3636
(require 'outline)
37+
(require 'purescript-vars)
3738
(require 'purescript-align-imports)
3839
(require 'purescript-sort-imports)
3940
(require 'purescript-string)
@@ -101,16 +102,6 @@ sure all purescript customize definitions have been loaded."
101102
purescript-yas))
102103
(customize-browse 'purescript))
103104

104-
;; Are we looking at a literate script?
105-
(defvar-local purescript-literate nil
106-
"*If not nil, the current buffer contains a literate PureScript script.
107-
Possible values are: `bird' and `tex', for Bird-style and LaTeX-style
108-
literate scripts respectively. Set by `purescript-mode' and
109-
`literate-purescript-mode'. For an ambiguous literate buffer -- i.e. does
110-
not contain either \"\\begin{code}\" or \"\\end{code}\" on a line on
111-
its own, nor does it contain \">\" at the start of a line -- the value
112-
of `purescript-literate-default' is used.")
113-
(put 'purescript-literate 'safe-local-variable 'symbolp)
114105
;; Default literate style for ambiguous literate buffers.
115106
(defcustom purescript-literate-default 'bird
116107
"Default value for `purescript-literate'.

purescript-vars.el

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
;;; purescript-vars.el --- Variable definitions for PureScript Mode -*- lexical-binding: t -*-
2+
3+
;; Author: 1997-1998 Graeme E Moss <gem@cs.york.ac.uk>
4+
;; 1997-1998 Tommy Thorn <thorn@irisa.fr>
5+
;; 2003 Dave Love <fx@gnu.org>
6+
;; 2025 Konstantin Kharlamov <Hi-Angel@yandex.ru>
7+
8+
;; This file is not part of GNU Emacs.
9+
10+
;; This file is free software; you can redistribute it and/or modify
11+
;; it under the terms of the GNU General Public License as published by
12+
;; the Free Software Foundation; either version 3, or (at your option)
13+
;; any later version.
14+
15+
;; This file is distributed in the hope that it will be useful,
16+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
;; GNU General Public License for more details.
19+
20+
;; You should have received a copy of the GNU General Public License
21+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+
(defvar-local purescript-literate nil
24+
"If not nil, the current buffer contains a literate PureScript script.
25+
Possible values are: `bird' and `tex', for Bird-style and LaTeX-style
26+
literate scripts respectively. Set by `purescript-mode' and
27+
`literate-purescript-mode'. For an ambiguous literate buffer -- i.e. does
28+
not contain either \"\\begin{code}\" or \"\\end{code}\" on a line on
29+
its own, nor does it contain \">\" at the start of a line -- the value
30+
of `purescript-literate-default' is used.")
31+
(put 'purescript-literate 'safe-local-variable 'symbolp)
32+
33+
(provide 'purescript-vars)

0 commit comments

Comments
 (0)