Quizzer
view release on metacpan or search on metacpan
exercises/compile-tcsh/tcsh-6.10.00/csh-mode.el view on Meta::CPAN
(defvar csh-tab-always-indent t
"*Controls the operation of the TAB key. If t (the default), always
reindent the current line. If nil, indent the current line only if
point is at the left margin or in the line's indentation; otherwise
insert a tab.")
;;
;; ----------------------------------------> Constants containing syntax regexps
;;
(defconst csh-case-default-re
"^\\s *\\(case\\|default\\)\\b"
"Regexp used to locate grouping keywords case and default" )
(defconst csh-case-item-re "^\\s *\\(case .*\\|default\\):"
"Regexp used to match case-items")
(defconst csh-end-re "^\\s *end\\b"
"Regexp used to match keyword: end")
(defconst csh-endif-re "^\\s *endif\\b"
"Regexp used to match keyword: endif")
(defconst csh-endsw-re "^\\s *endsw\\b"
"Regexp used to match keyword: endsw")
(defconst csh-else-re "^\\s *\\belse\\(\\b\\|$\\)"
"Regexp used to match keyword: else")
(defconst csh-else-if-re "^\\s *\\belse if\\(\\b\\|$\\)"
"Regexp used to match keyword pair: else if")
(defconst csh-if-re "^\\s *if\\b.+\\(\\\\\\|\\bthen\\b\\)"
"Regexp used to match non-one-line if statements")
(defconst csh-iteration-keywords-re "^[^#\n]*\\s\"*\\b\\(while\\|foreach\\)\\b"
"Match one of the keywords: while, foreach")
(defconst csh-keywords-re
"^\\s *\\(else\\b\\|foreach\\b\\|if\\b.+\\(\\\\\\|\\bthen\\b\\)\\|switch\\b\\|while\\b\\)"
"Regexp used to detect compound command keywords: else, if, foreach, while")
(defconst csh-label-re "^\\s *[^!#$\n ]+:"
"Regexp used to match flow-control labels")
(defconst csh-multiline-re "^.*\\\\$"
"Regexp used to match a line with a statement using more lines.")
(defconst csh-switch-re "^\\s *switch\\b"
"Regexp used to match keyword: switch")
;;
;; ----------------------------------------> Variables controlling fontification
;;
(defvar csh-keywords '("@" "alias" "bg" "break" "breaksw" "case" "cd" "chdir"
"continue" "default" "dirs" "echo" "else" "end" "endif"
"endsw" "eval" "exec" "exit" "fg" "foreach" "glob" "goto"
"hashstat" "history" "if" "jobs" "kill" "limit" "login"
"logout" "limit" "notify" "onintr" "popd" "printenv"
"pushd" "rehash" "repeat" "set" "setenv" "shift" "source"
"stop" "suspend" "switch" "then" "time" "umask" "unalias"
"unhash" "unlimit" "unset" "unsetenv" "wait" "while"
;; tcsh-keywords
"alloc" "bindkey" "builtins" "complete" "echotc"
"filetest" "hup" "log" "ls-F" "nice" "nohup" "sched"
"settc" "setty" "telltc" "uncomplete" "where" "which"))
(require 'font-lock) ; need to do this before referring to font-lock-* below
(defconst csh-font-lock-keywords
;; NOTE: The order of some of the items in this list is significant. Do not
;; alphabetize or otherwise blindly rearrange.
(list
;; Comments on line 1, which are missed by syntactic fontification.
'("^#.*" 0 font-lock-comment-face)
;; Label definitions (1 means first parenthesized exp in regexp).
'("^\\s *\\([^!#$\n ]+\\):" 1 font-lock-function-name-face)
;; Label references.
'("\\b\\(goto\\|onintr\\)\\b\\s +\\([^!#$ \n\t]+\\)"
2 font-lock-function-name-face)
;; Variable settings.
'("\\(@\\|set\\|setenv\\)\\s +\\([0-9A-Za-z_]+\\b\\)"
2 font-lock-variable-name-face)
;; Variable references not inside of strings.
'("\\$[][0-9A-Za-z_#:?]+" 0 font-lock-variable-name-face)
;; Backquoted strings. 'keep' means to just fontify non-fontified text.
'("`\\(.*\\)`" 1 font-lock-reference-face keep)
;; NOTE: The following variables need to be anchored to the beginning of
;; line to prevent re-fontifying text in comments. Due to this, we
;; can only catch a finite number of occurrences. More can be added.
;; The 't' means to override previous fontification.
;;
;; Variable references inside of " strings.
'("^[^#\n]*\".*\\(\\$[][0-9A-Za-z_#:?]+\\).*\""
1 font-lock-variable-name-face t) ; 1
'("^[^#\n]*\".*\\(\\$[][0-9A-Za-z_#:?]+\\).*\\$[][0-9A-Za-z_#:?]+.*\""
1 font-lock-variable-name-face t) ; 2
(cons (concat "^[^#\n]*\".*\\(\\$[][0-9A-Za-z_#:?]+\\).*"
"\\$[][0-9A-Za-z_#:?]+.*\\$[][0-9A-Za-z_#:?]+.*\"")
(list 1 font-lock-variable-name-face t)) ; 3
;;
;; History substitutions.
'("^![^~= \n\t]+" 0 font-lock-reference-face t) ; BOL
'("^[^#\n]*[^#\\\n]\\(![^~= \n\t]+\\)" 1 font-lock-reference-face t) ; 1
'("^[^#\n]*[^#\\\n]\\(![^~= \n\t]+\\).*![^~= \n\t]+"
1 font-lock-reference-face t) ; 2
;; Keywords.
(cons (concat
"\\(\\<"
(mapconcat 'identity csh-keywords "\\>\\|\\<")
"\\>\\)")
1)
))
(put 'csh-mode 'font-lock-keywords 'csh-font-lock-keywords)
;;
;; -------------------------------------------------------> Mode-specific tables
;;
(defvar csh-mode-abbrev-table nil
"Abbrev table used while in csh mode.")
(define-abbrev-table 'csh-mode-abbrev-table ())
(defvar csh-mode-map nil
"Keymap used in csh mode")
(if csh-mode-map
()
(setq csh-mode-map (make-sparse-keymap))
;;(define-key csh-mode-map "\177" 'backward-delete-char-untabify)
(define-key csh-mode-map "\C-c\t" 'csh-completion-init-and-pickup)
(define-key csh-mode-map "\C-j" 'reindent-then-newline-and-indent)
(define-key csh-mode-map "\e\t" 'csh-complete-symbol)
(define-key csh-mode-map "\n" 'reindent-then-newline-and-indent)
(define-key csh-mode-map '[return] 'reindent-then-newline-and-indent)
(define-key csh-mode-map "\t" 'csh-indent-command)
;;(define-key csh-mode-map "\t" 'csh-indent-line)
)
( run in 2.706 seconds using v1.01-cache-2.11-cpan-302cb4679cc )