aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorSimon Marshall1996-01-25 10:27:31 +0000
committerSimon Marshall1996-01-25 10:27:31 +0000
commit3e7fc8bd9f63eaf98fd89e033f4a075c09bc88ea (patch)
tree3bfe9e344d666462ecf71c8262617d783d992e7f /lisp
parentc28baa2ad84dd83e01a6a7d26cbfe8d4379242ae (diff)
downloademacs-3e7fc8bd9f63eaf98fd89e033f4a075c09bc88ea.tar.gz
emacs-3e7fc8bd9f63eaf98fd89e033f4a075c09bc88ea.zip
Support for Font Lock mode.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/perl-mode.el83
1 files changed, 64 insertions, 19 deletions
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index c38daa0d782..21fce869f6d 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -157,24 +157,65 @@ The expansion is entirely correct because it uses the C preprocessor."
157 ) 157 )
158 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.") 158 "Imenu generic expression for Perl mode. See `imenu-generic-expression'.")
159 159
160(defvar perl-font-lock-keywords 160;; Regexps updated with help from Tom Tromey <tromey@cambric.colorado.edu> and
161 (list 161;; Jim Campbell <jec@murzim.ca.boeing.com>.
162; ("if" "until" "while" "elsif" "else" "unless" "for" "foreach" "continue" 162
163; "exit" "die" "last" "goto" "next" "redo" "return" "local" "exec") 163(defconst perl-font-lock-keywords-1
164 (concat "\\<\\(" 164 '(;; What is this for?
165 "continue\\|die\\|e\\(ls\\(e\\|if\\)\\|x\\(ec\\|it\\)\\)\\|" 165 ;;("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face)
166 "for\\(\\|each\\)\\|goto\\|if\\|l\\(ast\\|ocal\\)\\|next\\|" 166 ;;
167 "re\\(do\\|turn\\)\\|un\\(less\\|til\\)\\|while" 167 ;; Fontify preprocessor statements as we do in `c-font-lock-keywords'.
168 "\\)\\>") 168 ;; Ilya Zakharevich <ilya@math.ohio-state.edu> thinks this is a bad idea.
169; ("#endif" "#else" "#ifdef" "#ifndef" "#if" "#include" "#define" "#undef") 169 ("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
170 (cons (concat "#\\(define\\|e\\(lse\\|ndif\\)\\|" 170 ("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
171 "i\\(f\\(\\|def\\|ndef\\)\\|nclude\\)\\|undef\\)\\>") 171 ("^#[ \t]*if\\>"
172 'font-lock-reference-face) 172 ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil
173 '("^[ \n\t]*sub[ \t]+\\([^ \t{]+\\)[ \t]*[{]" 1 font-lock-function-name-face) 173 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t)))
174 '("[ \n\t{]*\\(eval\\)[ \n\t(;]" 1 font-lock-function-name-face) 174 ("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?"
175 '("\\(--- .* ---\\|=== .* ===\\)" . font-lock-string-face) 175 (1 font-lock-reference-face) (2 font-lock-variable-name-face nil t))
176 ) 176 ;;
177 "Additional expressions to highlight in Perl mode.") 177 ;; Fontify function and package names in declarations.
178 ("\\<\\(package\\|sub\\)\\>[ \t]*\\(\\sw+\\)?"
179 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
180 ("\\<\\(import\\|no\\|require\\|use\\)\\>[ \t]*\\(\\sw+\\)?"
181 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t)))
182 "Subdued level highlighting for Perl mode.")
183
184(defconst perl-font-lock-keywords-2
185 (append perl-font-lock-keywords-1
186 (list
187 ;;
188 ;; Fontify keywords, except those fontified otherwise.
189; (make-regexp '("if" "until" "while" "elsif" "else" "unless" "do" "dump"
190; "for" "foreach" "exit" "die"
191; "BEGIN" "END" "return" "exec" "eval"))
192 (concat "\\<\\("
193 "BEGIN\\|END\\|d\\(ie\\|o\\|ump\\)\\|"
194 "e\\(ls\\(e\\|if\\)\\|val\\|x\\(ec\\|it\\)\\)\\|"
195 "for\\(\\|each\\)\\|if\\|return\\|un\\(less\\|til\\)\\|while"
196 "\\)\\>")
197 ;;
198 ;; Fontify local and my keywords as types.
199 '("\\<\\(local\\|my\\)\\>" . font-lock-type-face)
200 ;;
201 ;; Fontify function, variable and file name references.
202 '("&\\(\\sw+\\)" 1 font-lock-function-name-face)
203 ;; Additionally underline non-scalar variables. Maybe this is a bad idea.
204 ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
205 '("[$*]{?\\(\\sw+\\)" 1 font-lock-variable-name-face)
206 '("\\([@%]\\|\\$#\\)\\(\\sw+\\)"
207 (2 (cons font-lock-variable-name-face '(underline))))
208 '("<\\(\\sw+\\)>" 1 font-lock-reference-face)
209 ;;
210 ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
211 '("\\<\\(continue\\|goto\\|last\\|next\\|redo\\)\\>[ \t]*\\(\\sw+\\)?"
212 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))
213 '("^[ \t]*\\(\\sw+\\)[ \t]*:[^:]" 1 font-lock-reference-face)))
214 "Gaudy level highlighting for Perl mode.")
215
216(defvar perl-font-lock-keywords perl-font-lock-keywords-1
217 "Default expressions to highlight in Perl mode.")
218
178 219
179(defvar perl-indent-level 4 220(defvar perl-indent-level 4
180 "*Indentation of Perl statements with respect to containing block.") 221 "*Indentation of Perl statements with respect to containing block.")
@@ -281,8 +322,12 @@ Turning on Perl mode runs the normal hook `perl-mode-hook'."
281 (setq comment-indent-function 'perl-comment-indent) 322 (setq comment-indent-function 'perl-comment-indent)
282 (make-local-variable 'parse-sexp-ignore-comments) 323 (make-local-variable 'parse-sexp-ignore-comments)
283 (setq parse-sexp-ignore-comments t) 324 (setq parse-sexp-ignore-comments t)
325 ;; Tell font-lock.el how to handle Perl.
284 (make-local-variable 'font-lock-defaults) 326 (make-local-variable 'font-lock-defaults)
285 (setq font-lock-defaults '(perl-font-lock-keywords)) 327 (setq font-lock-defaults '((perl-font-lock-keywords
328 perl-font-lock-keywords-1
329 perl-font-lock-keywords-2)
330 nil nil ((?\_ . "w"))))
286 ;; Tell imenu how to handle Perl. 331 ;; Tell imenu how to handle Perl.
287 (make-local-variable 'imenu-generic-expression) 332 (make-local-variable 'imenu-generic-expression)
288 (setq imenu-generic-expression perl-imenu-generic-expression) 333 (setq imenu-generic-expression perl-imenu-generic-expression)