]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cpp.el
(menu-bar-make-mm-toggle): Don't put a quote befor FNAME
[gnu-emacs] / lisp / progmodes / cpp.el
index f5a3c912eeac9482a5763df20b833b6dd05775a0..6e4c8d1f457168debf7c1858144ae9e57ae93d4c 100644 (file)
@@ -1,4 +1,4 @@
-;;; cpp.el --- Highlight or hide text according to cpp conditionals.
+;;; cpp.el --- highlight or hide text according to cpp conditionals
 
 ;; Copyright (C) 1994, 1995 Free Software Foundation
 
 ;;; Code:
 
 ;;; Customization:
-
-(defvar cpp-config-file (convert-standard-filename ".cpp.el")
-  "*File name to save cpp configuration.")
-
-(defvar cpp-known-face 'invisible
-  "*Face used for known cpp symbols.")
-
-(defvar cpp-unknown-face 'highlight
-  "*Face used for unknown cpp symbols.")
-
-(defvar cpp-face-type 'light 
+(defgroup cpp nil
+  "Highlight or hide text according to cpp conditionals."
+  :group 'c
+  :prefix "cpp-")
+
+(defcustom cpp-config-file (convert-standard-filename ".cpp.el")
+  "*File name to save cpp configuration."
+  :type 'file
+  :group 'cpp)
+
+(defcustom cpp-known-face 'invisible
+  "*Face used for known cpp symbols."
+  :type 'face
+  :group 'cpp)
+
+(defcustom cpp-unknown-face 'highlight
+  "*Face used for unknown cpp symbols."
+  :type 'face
+  :group 'cpp)
+
+(defcustom cpp-face-type 'light 
   "*Indicate what background face type you prefer.
 Can be either light or dark for color screens, mono for monochrome
-screens, and none if you don't use a window system.")
-
-(defvar cpp-known-writable t
-  "*Non-nil means you are allowed to modify the known conditionals.")
-
-(defvar cpp-unknown-writable t
-  "*Non-nil means you are allowed to modify the unknown conditionals.")
-
-(defvar cpp-edit-list nil
+screens, and none if you don't use a window system and don't have
+a color-capable display."
+  :options '(light dark mono nil)
+  :type 'symbol
+  :group 'cpp)
+
+(defcustom cpp-known-writable t
+  "*Non-nil means you are allowed to modify the known conditionals."
+  :type 'boolean
+  :group 'cpp)
+
+(defcustom cpp-unknown-writable t
+  "*Non-nil means you are allowed to modify the unknown conditionals."
+  :type 'boolean
+  :group 'cpp)
+
+(defcustom cpp-edit-list nil
   "Alist of cpp macros and information about how they should be displayed.
 Each entry is a list with the following elements:
 0. The name of the macro (a string).
 1. Face used for text that is `ifdef' the macro.
 2. Face used for text that is `ifndef' the macro.
-3. `t', `nil', or `both' depending on what text may be edited.")
+3. `t', `nil', or `both' depending on what text may be edited."
+  :type '(repeat (list string face face
+                      (choice (const t)
+                              (const nil)
+                              (const both))))
+  :group 'cpp)
 
 (defvar cpp-overlay-list nil)
 ;; List of cpp overlays active in the current buffer.
@@ -108,38 +131,58 @@ Each entry is a list with the following elements:
     ("true" . t)
     ("both" . both)))
 
-(defvar cpp-face-default-list nil
-  "List of faces you can choose from for cpp conditionals.")
+(defcustom cpp-face-default-list nil
+  "Alist of faces you can choose from for cpp conditionals.
+Each element has the form (STRING . FACE), where STRING
+serves as a name (for `cpp-highlight-buffer' only)
+and FACE is either a face (a symbol)
+or a cons cell (background-color . COLOR)."
+  :type '(repeat (cons string (choice face (cons (const background-color) string))))
+  :group 'cpp)
 
-(defvar cpp-face-light-name-list
+(defcustom cpp-face-light-name-list
   '("light gray" "light blue" "light cyan" "light yellow" "light pink"
     "pale green" "beige" "orange" "magenta" "violet" "medium purple"
     "turquoise")
-  "Background colours useful with dark foreground colors.")
+  "Background colours useful with dark foreground colors."
+  :type '(repeat string)
+  :group 'cpp)
 
-(defvar cpp-face-dark-name-list
+(defcustom cpp-face-dark-name-list
   '("dim gray" "blue" "cyan" "yellow" "red"
     "dark green" "brown" "dark orange" "dark khaki" "dark violet" "purple"
     "dark turquoise")
-  "Background colours useful with light foreground colors.")
-
-(defvar cpp-face-light-list nil
-  "Alist of names and faces to be used for light backgrounds.")
-
-(defvar cpp-face-dark-list nil
-  "Alist of names and faces to be used for dark backgrounds.")
-
-(defvar cpp-face-mono-list
-  '(("bold" . 'bold)
-    ("bold-italic" . 'bold-italic)
-    ("italic" . 'italic)
-    ("underline" . 'underline))
-  "Alist of names and faces to be used for monochrome screens.")
-
-(defvar cpp-face-none-list
+  "Background colours useful with light foreground colors."
+  :type '(repeat string)
+  :group 'cpp)
+
+(defcustom cpp-face-light-list nil
+  "Alist of names and faces to be used for light backgrounds."
+  :type '(repeat (cons string (choice face
+                                     (cons (const background-color) string))))
+  :group 'cpp)
+
+(defcustom cpp-face-dark-list nil
+  "Alist of names and faces to be used for dark backgrounds."
+  :type '(repeat (cons string (choice face
+                                     (cons (const background-color) string))))
+  :group 'cpp)
+
+(defcustom cpp-face-mono-list
+  '(("bold" . bold)
+    ("bold-italic" . bold-italic)
+    ("italic" . italic)
+    ("underline" . underline))
+  "Alist of names and faces to be used for monochrome screens."
+  :type '(repeat (cons string face))
+  :group 'cpp)
+
+(defcustom cpp-face-none-list
    '(("default" . default)
      ("invisible" . invisible))
-   "Alist of names and faces available even if you don't use a window system.")
+   "Alist of names and faces available even if you don't use a window system."
+  :type '(repeat (cons string face))
+  :group 'cpp)
 
 (defvar cpp-face-all-list
   (append cpp-face-light-list
@@ -168,7 +211,8 @@ This command pops up a buffer which you should edit to specify
 what kind of highlighting to use, and the criteria for highlighting.
 A prefix arg suppresses display of that buffer."
   (interactive "P")
-  (unless (memq 'cpp buffer-invisibility-spec) 
+  (unless (or (eq t buffer-invisibility-spec)
+             (memq 'cpp buffer-invisibility-spec))
     (add-to-invisibility-spec 'cpp))
   (setq cpp-parse-symbols nil)
   (cpp-parse-reset)
@@ -448,7 +492,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
     (erase-buffer)
     (insert "CPP Display Information for `")
     (cpp-make-button (buffer-name cpp-edit-buffer) 'cpp-edit-home)
-    (insert "\n\nClick mouse-2 on item you want to change or use\n"
+    (insert "'\n\nClick mouse-2 on item you want to change or use\n"
            "or switch to this buffer and type the keyboard equivalents.\n"
            "Keyboard equivalents are indicated with brackets like [T]his.\n\n")
     (cpp-make-button "[H]ome (display the C file)" 'cpp-edit-home)
@@ -632,7 +676,7 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
   ;; Choose a symbol if called from keyboard, otherwise use the one clicked on.
   (if cpp-button-event
       cpp-callback-data
-    (completing-read "Symbol: " (mapcar 'list cpp-edit-symbols) nil t)))
+    (completing-read "Symbol: " cpp-edit-symbols nil t)))
 
 (defun cpp-choose-branch ()
   ;; Choose a branch, either nil, t, or both.
@@ -643,7 +687,7 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
                cpp-branch-list))))
 
 (defun cpp-choose-face (prompt default)
-  ;; Choose a face from cpp-face-defalt-list.
+  ;; Choose a face from cpp-face-default-list.
   ;; PROMPT is what to say to the user.
   ;; DEFAULT is the default face.
   (or (if cpp-button-event
@@ -732,6 +776,7 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
     (add-text-properties from to
                         (append (list 'face face)
                                 '(mouse-face highlight)
+                                '(help-echo "mouse-2: change/use this item")
                                 (list 'cpp-callback callback)
                                 (if data (list 'cpp-data data))))))
 
@@ -752,12 +797,10 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
 
 (defun cpp-create-bg-face (color)
   ;; Create entry for face with background COLOR.
-  (let ((name (intern (concat "cpp " color))))
-    (make-face name)
-    (set-face-background name color)
-    (cons color name)))
+  (cons color (cons 'background-color color)))
 
-(cpp-choose-default-face (if window-system cpp-face-type 'none))
+(cpp-choose-default-face
+ (if (or window-system (display-color-p)) cpp-face-type 'none))
 
 (defun cpp-face-name (face)
   ;; Return the name of FACE from `cpp-face-all-list'.