File: ess-font-lock.el

package info (click to toggle)
ess 16.10-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 7,260 kB
  • ctags: 2,341
  • sloc: lisp: 27,692; sh: 1,579; asm: 848; makefile: 368
file content (167 lines) | stat: -rw-r--r-- 6,751 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
;;; ess-font-lock.el --- font-lock color options

;; Copyright (C) 2000--2006 A.J. Rossini, Richard M. Heiberger, Martin
;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.

;; Author: Richard M. Heiberger <rmh@temple.edu>
;; Created: 06 Feb 2000

;; Keywords: languages, faces

;; This file is part of ESS

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; A copy of the GNU General Public License is available at
;; http://www.r-project.org/Licenses/

;;; Commentary:

;; provides syntax highlighting support.

;;; Code:

                                        ; Requires and autoloads

(require 'font-lock)
(require 'paren)
(if (fboundp 'show-paren-mode) (show-paren-mode 1))

;;; Emacs 20.x notes:

;; font-lock faces are defined in /emacs/emacs-20.5/lisp/font-lock.el
;; The font-lock faces are applied to ESS buffers by
;; ess-mode.el ess-inf.el ess-trns.el ess-custom.el
;; The keywords for faces are defined in the ess[dl]*.el files.
;; All faces can be looked at, under Emacs 20.x, with
;;        [menu-bar] [Edit] [Text Properties] [Display Faces}

;;; For XEmacs

;; ... (tony needs to write something here).

(defun ess-font-lock-rmh ()
  "Set font-lock colors to Richard Heiberger's usual choice."
  (interactive)

  (if (featurep 'xemacs) nil
    (set-foreground-color "Black")
    (set-background-color "lightcyan"))

  (set-face-background 'mode-line "lightskyblue")
  (set-face-foreground 'mode-line "midnightblue")

  (set-face-foreground 'font-lock-comment-face "Firebrick")
  (set-face-foreground 'font-lock-function-name-face "Blue")
  (set-face-foreground 'font-lock-keyword-face "Purple")
  (set-face-foreground 'font-lock-constant-face "Brown")
  (set-face-foreground 'font-lock-string-face "VioletRed")
  (set-face-foreground 'font-lock-type-face "Sienna")
  (set-face-foreground 'font-lock-variable-name-face "Black"))

(defun ess-font-lock-blue ()
  "Set font-lock colors to Richard Heiberger's blue color scheme."
  (interactive)

  (if (featurep 'xemacs) nil
    (set-foreground-color "Black")
    (set-background-color "LightBlue"))

  (set-face-foreground 'mode-line "LightBlue")
  (set-face-background 'mode-line "DarkSlateBlue")

  (set-face-foreground 'font-lock-comment-face "Firebrick")
  (set-face-foreground 'font-lock-function-name-face "Blue")
  (set-face-foreground 'font-lock-keyword-face "Purple")
  (set-face-foreground 'font-lock-constant-face "Brown")
  (set-face-foreground 'font-lock-string-face "VioletRed")
  (set-face-foreground 'font-lock-type-face "Sienna")
  (set-face-foreground 'font-lock-variable-name-face "Black"))

(defun ess-font-lock-wheat ()
  "Set font-lock colors to Richard Heiberger's wheat color scheme."
  (interactive)

  (if (featurep 'xemacs) nil
    (set-foreground-color "Black")
    (set-background-color "Wheat"))

  (set-face-foreground 'mode-line "Wheat")
  (set-face-background 'mode-line "Sienna")

  (set-face-foreground 'font-lock-comment-face "Firebrick")
  (set-face-foreground 'font-lock-function-name-face "Blue")
  (set-face-foreground 'font-lock-keyword-face "Purple")
  (set-face-foreground 'font-lock-constant-face "Brown")
  (set-face-foreground 'font-lock-string-face "VioletRed")
  (set-face-foreground 'font-lock-type-face "Sienna")
  (set-face-foreground 'font-lock-variable-name-face "Black"))


(defun ess-font-lock-bw ()
  "Set font-lock colors to Richard Heiberger's black and white color scheme."
  (interactive)

  (if (featurep 'xemacs) nil
    (set-foreground-color "Black")
    (set-background-color "white"))

  (set-face-foreground 'mode-line "gray10")
  (set-face-background 'mode-line "gray90")

  ;; modify-face is an interactive compiled Lisp function in `faces'.
  ;; Sample usage:

  ;;(modify-face FACE                        FOREGROUND BACKGROUND STIPPLE BOLD-P ITALIC-P UNDERLINE-P &optional INVERSE-P FRAME)

  (modify-face 'mode-line                     "gray10"   "gray90"   nil     nil    t        nil       )
  (modify-face 'font-lock-comment-face       "black"    "white"    nil     nil    t        nil       )
  (modify-face 'font-lock-function-name-face "black"    "white"    nil     t      nil      nil       )
  (modify-face 'font-lock-keyword-face       "black"    "white"    nil     nil    nil      t         )
  (modify-face 'font-lock-constant-face      "black"    "white"    nil     t      nil      nil       )
  (modify-face 'font-lock-string-face        "black"    "white"    nil     nil    t        t         )
  (modify-face 'font-lock-type-face          "black"    "white"    nil     t      t        nil       )
  (modify-face 'font-lock-variable-name-face "black"    "white"    nil     nil    nil      nil       )
  (modify-face 'font-lock-builtin-face       "black"    "white"    nil     t      nil      nil       )
  (modify-face 'font-lock-warning-face       "black"    "white"    nil     t      nil      nil       )
  (modify-face 'show-paren-match-face        "gray20"   "gray80"   nil     t      nil      nil       )
  (modify-face 'show-paren-mismatch-face     "white"    "gray40"   nil     t      t        nil       ))

(defun ess-font-lock-db ()
  "Set font-lock colors (leave fore-/back-ground alone) courtesy David Brahm <David.Brahm@fmr.com>"
  (interactive)
  (set-face-foreground 'font-lock-comment-face       "Firebrick")  ; #...    %...
  (set-face-foreground 'font-lock-string-face        "SeaGreen")   ; "..."   "..."
  (set-face-foreground 'font-lock-keyword-face       "MediumBlue") ; if      \end
  (set-face-foreground 'font-lock-function-name-face "VioletRed")  ; talk<-  {center}
  (set-face-foreground 'font-lock-variable-name-face "Blue")       ; xv
  (set-face-foreground 'font-lock-type-face          "Goldenrod")  ; T,F       ?
  (set-face-foreground 'font-lock-constant-face      "Magenta")    ; <-      {eq1}
  )

(provide 'ess-font-lock)

 ; Local variables section

;;; This file is automatically placed in Outline minor mode.
;;; The file is structured as follows:
;;; Chapters:     ^L ;
;;; Sections:    ;;*;;
;;; Subsections: ;;;*;;;
;;; Components:  defuns, defvars, defconsts
;;;              Random code beginning with a ;;;;* comment
;;; Local variables:
;;; mode: emacs-lisp
;;; mode: outline-minor
;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"
;;; End:

;;; ess-font-lock.el ends here