Download
(require 'cc-mode)
(defcustom bc-mode-hook nil
"Normal hook run when entering bc-mode."
:type 'hook
:group 'data)
(defvar bc-command-line "bc -l"
"Command line executed for `bc'.")
(defconst bc-font-lock-keywords
(eval-when-compile
(list
'("\\(#.*\\)$"
(1 font-lock-comment-face))
'("^[ \t]*\\(define\\)\\>[ \t]*\\(\\sw+\\)?"
(1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
(cons (regexp-opt
'("SCALE" "IBASE" "OBASE" "LAST") 'words)
'font-lock-variable-name-face)
(regexp-opt
'("break" "continue" "delete" "exit" "else" "for" "quit" "auto" "local"
"if" "print" "return" "while") 'words)
(list (regexp-opt
'("length" "read" "scale" "sqrt") 'words)
1 'font-lock-builtin-face)
(cons (regexp-opt '("&&" "||" "<=" "<" ">=" ">" "==" "!="))
'font-lock-constant-face)
))
"Default expressions to highlight in BC mode.")
(define-derived-mode bc-mode c-mode "BC"
"Major mode for editing BC code.
This is much like C mode except for the syntax of comments. Its keymap
inherits from C mode's and it has the same variables for customizing
indentation. It uses `c-mode-syntax-table'.
Turning on BC mode runs `bc-mode-hook'."
(set-syntax-table c-mode-syntax-table)
(set (make-local-variable 'comment-start) "/* ")
(set (make-local-variable 'comment-end) " */")
(set (make-local-variable 'comment-start-skip) "#+ *|/\\* +")
(setq font-lock-defaults '(bc-font-lock-keywords nil nil ((?_ . "w"))))
(run-hooks 'bc-mode-hook))
(provide 'bc-mode)