 ;; M-x run-factor === Start a Factor listener inside Emacs
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; BUG: A double quote character on a commented line will break the
-;; syntax highlighting for that line.
 
 (defgroup factor nil
   "Factor mode"

  :type 'hook
  :group 'factor)

(defconst factor-font-lock-keywords
  '(("#!.*$" . font-lock-comment-face)
    ("!( .* )" . font-lock-comment-face)
    ("^!.*$" . font-lock-comment-face)
    (" !.*$" . font-lock-comment-face)
    ("( .* )" . font-lock-comment-face)
    "BIN:"
    "MAIN:"
    "IN:" "USING:" "TUPLE:" "^C:" "^M:"
    "METHOD:"
    "USE:" "REQUIRE:" "PROVIDE:"
    "REQUIRES:"
    "GENERIC:" "GENERIC#" "SYMBOL:" "PREDICATE:" "VAR:" "VARS:"
    "C-STRUCT:"
    "C-UNION:" "<PRIVATE" "PRIVATE>" "MACRO:" "MACRO::" "DEFER:" "TYPEDEF:"
    "SYMBOLS:"
))

(defun factor-indent-line ()
  "Indent current line as Factor code"

  (setq comment-start "! ")
  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults
	'(factor-font-lock-keywords t nil nil nil))
  (set-syntax-table factor-mode-syntax-table)
  (make-local-variable 'indent-line-function)
  (setq indent-line-function 'factor-indent-line)
