@@ -499,14 +499,6 @@ that should be commented under LaTeX-style literate scripts."
499
499
(" ^\\ (\\\\\\ )end{code}$" 1 " !" ))
500
500
haskell-basic-syntactic-keywords))
501
501
502
- (defcustom haskell-font-lock-haddock (boundp 'font-lock-doc-face )
503
- " If non-nil try to highlight Haddock comments specially."
504
- :type 'boolean
505
- :group 'haskell )
506
-
507
- (defvar haskell-font-lock-seen-haddock nil )
508
- (make-variable-buffer-local 'haskell-font-lock-seen-haddock )
509
-
510
502
(defun haskell-syntactic-face-function (state )
511
503
" `font-lock-syntactic-face-function' for Haskell."
512
504
(cond
@@ -516,41 +508,28 @@ that should be commented under LaTeX-style literate scripts."
516
508
(and (eq haskell-literate 'bird )
517
509
(memq (char-before (nth 8 state)) '(nil ?\n ))))
518
510
haskell-literate-comment-face)
519
- ; ; Try and recognize Haddock comments. From what I gather from its
520
- ; ; documentation, its comments can take the following forms:
521
- ; ; a) {-| ... -}
522
- ; ; b) {-^ ... -}
523
- ; ; c) -- | ...
524
- ; ; d) -- ^ ...
525
- ; ; e) -- ...
526
- ; ; Where `e' is the tricky one: it is only a Haddock comment if it
527
- ; ; follows immediately another Haddock comment. Even an empty line
528
- ; ; breaks such a sequence of Haddock comments. It is not clear if `e'
529
- ; ; can follow any other case, so I interpreted it as following only cases
530
- ; ; c,d,e (not a or b). In any case, this `e' is expensive since it
531
- ; ; requires extra work for each and every non-Haddock comment, so I only
532
- ; ; go through the more expensive check if we've already seen a Haddock
533
- ; ; comment in the buffer.
511
+ ; ; Haddock comment start with either "-- [|^*$]" or "{- ?[|^*$]"
512
+ ; ; (note space optional for nested comments and mandatory for
513
+ ; ; double dash comments).
514
+ ; ;
515
+ ; ; Haddock comment will also continue on next line, provided:
516
+ ; ; - current line is a double dash haddock comment
517
+ ; ; - next line is also double dash comment
518
+ ; ; - there is only whitespace between
534
519
; ;
535
- ; ; And then there are also haddock section headers that start with
536
- ; ; any number of stars:
537
- ; ; -- * ...
538
- ((and haskell-font-lock-haddock
539
- (save-excursion
540
- (goto-char (nth 8 state))
541
- (or (looking-at " \\ (?:{- ?\\ |-- \\ )[|^*$]" )
542
- (and haskell-font-lock-seen-haddock
543
- (looking-at " --" )
544
- (let ((doc nil )
545
- pos)
546
- (while (and (not doc)
547
- (setq pos (line-beginning-position ))
548
- (forward-comment -1 )
549
- (eq (line-beginning-position 2 ) pos)
550
- (looking-at " --\\ ([ \\ t]*[|^*]\\ )?" ))
551
- (setq doc (match-beginning 1 )))
552
- doc)))))
553
- (setq haskell-font-lock-seen-haddock t )
520
+ ; ; We recognize double dash haddock comments by property
521
+ ; ; 'font-lock-doc-face attached to newline. In case of bounded
522
+ ; ; comments newline is outside of comment.
523
+ ((save-excursion
524
+ (goto-char (nth 8 state))
525
+ (or (looking-at " \\ (?:{- ?\\ |-- \\ )[|^*$]" )
526
+ (and (looking-at " --" ) ; are we at double dash comment
527
+ (forward-line -1 ) ; this is nil on first line
528
+ (eq (get-text-property (line-end-position ) 'face )
529
+ font-lock-doc-face ) ; is a doc face
530
+ (forward-line )
531
+ (skip-syntax-forward " -" ) ; see if there is only whitespace
532
+ (eq (point ) (nth 8 state))))) ; we are back in position
554
533
font-lock-doc-face )
555
534
(t font-lock-comment-face )))
556
535
0 commit comments