Skip to content

Commit

Permalink
Merge pull request #1740 from goose121/master
Browse files Browse the repository at this point in the history
Use "!" class for literate comments instead of "<" (fixes #1594)
  • Loading branch information
purcell authored Apr 7, 2021
2 parents 1baa12a + 4ea8774 commit 426e28b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions haskell-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ on an uppercase identifier."
(goto-char (1+ (point)))))))
;; must return nil here so that it is not fontified again as string
nil))
;; Detect literate comment lines starting with syntax class '<'
;; Detect literate comment lines starting with syntax class '!'
((save-excursion
(goto-char (nth 8 state))
(equal (string-to-syntax "<") (syntax-after (point))))
(equal (string-to-syntax "!") (syntax-after (point))))
'haskell-literate-comment-face)
;; Detect pragmas. A pragma is enclosed in special comment
;; delimiters {-# .. #-}.
Expand Down
2 changes: 1 addition & 1 deletion haskell-lexeme.el
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ See `haskell-lexeme-classify-by-first-char' for details."
(point (point-marker)))
(or
(and
(equal (string-to-syntax "<")
(equal (string-to-syntax "!")
(get-char-property (point) 'syntax-table))
(progn
(set-match-data (list point (set-marker (make-marker) (line-end-position))))
Expand Down
11 changes: 9 additions & 2 deletions haskell-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,18 @@ be set to the preferred literate style."
(or
(and
(not (equal (string-to-syntax "<") (syntax-after (point))))
(not (equal (string-to-syntax "!") (syntax-after (point))))
(not (looking-at-p "^>")))
(looking-at-p "^\\\\begin{code}[\t ]*$")))))))
(while (< (point) end)
(unless (looking-at-p "^[\t ]*$")
(if previous-line-latex-code
(if (looking-at-p "^\\\\end{code}[\t ]*$")
(progn
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "<"))
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "!"))
(save-excursion
(end-of-line)
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "!")))
(setq previous-line-latex-code nil))
;; continue latex-code
)
Expand All @@ -521,7 +525,10 @@ be set to the preferred literate style."
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "-"))
;; this is a literate comment
(progn
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "<"))
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "!"))
(save-excursion
(end-of-line)
(put-text-property (point) (1+ (point)) 'syntax-table (string-to-syntax "!")))
(when (looking-at-p "^\\\\begin{code}[\t ]*$")
(setq previous-line-latex-code t))))))
(forward-line 1))))
Expand Down

0 comments on commit 426e28b

Please sign in to comment.