Skip to content

Commit 1460a7e

Browse files
authored
Merge pull request #53 from Hi-Angel/defvar-cleanup
Defvars cleanup
2 parents 08b295b + d31134c commit 1460a7e

6 files changed

+49
-40
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: 3 additions & 4 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
@@ -307,13 +306,13 @@ Returns keywords suitable for `font-lock-keywords'."
307306

308307
;;;###autoload
309308
(defun purescript-font-lock-choose-keywords ()
310-
(cl-case (bound-and-true-p purescript-literate)
309+
(cl-case purescript-literate
311310
(bird purescript-font-lock-bird-literate-keywords)
312311
((latex tex) purescript-font-lock-latex-literate-keywords)
313312
(t purescript-font-lock-keywords)))
314313

315314
(defun purescript-font-lock-choose-syntactic-keywords ()
316-
(cl-case (bound-and-true-p purescript-literate)
315+
(cl-case purescript-literate
317316
(bird purescript-bird-syntactic-keywords)
318317
((latex tex) purescript-latex-syntactic-keywords)
319318
(t purescript-basic-syntactic-keywords)))

purescript-indent.el

Lines changed: 2 additions & 4 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
@@ -1486,9 +1485,8 @@ One indentation cycle is used."
14861485

14871486
;;; purescript-indent-mode
14881487

1489-
(defvar purescript-indent-mode nil
1488+
(defvar-local purescript-indent-mode nil
14901489
"Non-nil if the semi-intelligent PureScript indentation mode is in effect.")
1491-
(make-variable-buffer-local 'purescript-indent-mode)
14921490

14931491
(defvar purescript-indent-map
14941492
(let ((map (make-sparse-keymap)))

purescript-indentation.el

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
(require 'syntax)
3636
(require 'cl-lib)
37+
(require 'simple)
38+
(require 'purescript-vars)
3739

38-
(defvar delete-active-region)
39-
40-
;; Dynamically scoped variables.
40+
;; Dynamically scoped internal variables.
4141
(defvar following-token)
4242
(defvar current-token)
4343
(defvar left-indent)
@@ -47,7 +47,7 @@
4747
(defvar parse-line-number)
4848
(defvar possible-indentations)
4949
(defvar indentation-point)
50-
(defvar purescript-literate)
50+
(defvar-local purescript-indent-last-position nil)
5151

5252
(defgroup purescript-indentation nil
5353
"PureScript indentation."
@@ -118,9 +118,6 @@
118118
(define-key keymap [?\C-d] 'purescript-indentation-delete-char)
119119
keymap))
120120

121-
;; Used internally
122-
(defvar purescript-indent-last-position)
123-
124121
;;;###autoload
125122
(define-minor-mode purescript-indentation-mode
126123
"PureScript indentation mode that deals with the layout rule.
@@ -129,16 +126,12 @@ set and deleted as if they were real tabs. It supports
129126
autofill-mode."
130127
:lighter " Ind"
131128
:keymap purescript-indentation-mode-map
132-
(kill-local-variable 'indent-line-function)
133-
(kill-local-variable 'normal-auto-fill-function)
134129
(when purescript-indentation-mode
135130
(setq max-lisp-eval-depth (max max-lisp-eval-depth 600)) ;; set a higher limit for recursion
136-
(set (make-local-variable 'indent-line-function)
137-
'purescript-indentation-indent-line)
138-
(set (make-local-variable 'normal-auto-fill-function)
139-
'purescript-indentation-auto-fill-function)
140-
(set (make-local-variable 'purescript-indent-last-position)
141-
nil)))
131+
(setq-local indent-line-function
132+
#'purescript-indentation-indent-line)
133+
(setq-local normal-auto-fill-function
134+
#'purescript-indentation-auto-fill-function)))
142135

143136
;;;###autoload
144137
(defun turn-on-purescript-indentation ()

purescript-mode.el

Lines changed: 2 additions & 17 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,17 +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 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-
(make-variable-buffer-local 'purescript-literate)
114-
(put 'purescript-literate 'safe-local-variable 'symbolp)
115105
;; Default literate style for ambiguous literate buffers.
116106
(defcustom purescript-literate-default 'bird
117107
"Default value for `purescript-literate'.
@@ -289,8 +279,6 @@ details."
289279
turn-on-purescript-simple-indent
290280
turn-on-purescript-unicode-input-method))
291281

292-
(defvar eldoc-print-current-symbol-info-function)
293-
294282
;; The main mode functions
295283
;;;###autoload
296284
(define-derived-mode purescript-mode prog-mode "PureScript"
@@ -337,10 +325,7 @@ see documentation for that variable for more details."
337325
(setq-local beginning-of-defun-function 'purescript-beginning-of-defun)
338326
(setq prettify-symbols-alist purescript-font-lock-prettify-symbols-alist
339327
;; make (ff-find-other-file) find .js FFI file, given .purs
340-
ff-other-file-alist '((".purs\\'" (".js"))))
341-
(when (bound-and-true-p purescript-font-lock-symbols)
342-
(warn "`purescript-font-lock-symbols' is obsolete: please enable `prettify-symbols-mode' locally or globally instead."))
343-
)
328+
ff-other-file-alist '((".purs\\'" (".js")))))
344329

345330
(defun purescript-fill-paragraph (justify)
346331
(save-excursion

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)