]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cpp.el
Romain Francoise's and Ami Fischman's bugfixes.
[gnu-emacs] / lisp / progmodes / cpp.el
index 975ca76eac7471d1fe43f665010d22849c4c3e88..0d9a9f62a60e47518a214ad32286de8c9544f1e8 100644 (file)
@@ -1,6 +1,6 @@
-;;; 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
+;; Copyright (C) 1994, 1995, 2003 Free Software Foundation
 
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: c, faces, tools
@@ -32,7 +32,7 @@
 ;;; Todo:
 
 ;; Should parse "#if" and "#elif" expressions and merge the faces
-;; somehow. 
+;; somehow.
 
 ;; Somehow it is sometimes possible to make changes near a read only
 ;; area which you can't undo.  Their are other strange effects in that
@@ -49,7 +49,7 @@
 ;;; Customization:
 (defgroup cpp nil
   "Highlight or hide text according to cpp conditionals."
-  :group 'C
+  :group 'c
   :prefix "cpp-")
 
 (defcustom cpp-config-file (convert-standard-filename ".cpp.el")
   :type 'face
   :group 'cpp)
 
-(defcustom cpp-face-type 'light 
+(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."
+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)
@@ -91,7 +92,7 @@ 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)
@@ -367,7 +368,7 @@ A prefix arg suppresses display of that buffer."
     (cond ((eq cpp-unknown-face 'invisible)
           (cpp-make-overlay-hidden overlay))
          ((eq cpp-unknown-face 'default))
-         (t 
+         (t
           (overlay-put overlay 'face cpp-unknown-face)))
     (if cpp-unknown-writable
        ()
@@ -378,9 +379,6 @@ A prefix arg suppresses display of that buffer."
 (defun cpp-make-overlay-hidden (overlay)
   ;; Make overlay hidden and intangible.
   (overlay-put overlay 'invisible 'cpp)
-  (overlay-put overlay 'intangible t)
-  ;; Unfortunately `intangible' is not implemented for overlays yet,
-  ;; so we make is read-only instead.
   (overlay-put overlay 'modification-hooks '(cpp-signal-read-only))
   (overlay-put overlay 'insert-in-front-hooks '(cpp-signal-read-only)))
 
@@ -460,7 +458,7 @@ A prefix arg suppresses display of that buffer."
 
 (defun cpp-edit-mode ()
   "Major mode for editing the criteria for highlighting cpp conditionals.
-Click on objects to change them.  
+Click on objects to change them.
 You can also use the keyboard accelerators indicated like this: [K]ey."
   (kill-all-local-variables)
   (buffer-disable-undo)
@@ -534,7 +532,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
                 (eq write 'both))
            (setq cpp-edit-list (delq entry cpp-edit-list)
                  entry nil))
-       
+
        (if (> (length symbol) 39)
            (insert (substring symbol 0 39) ": ")
          (insert (format "%39s: " symbol)))
@@ -648,7 +646,7 @@ With optional argument ARG, make them writable iff ARG is positive."
   (interactive
    (let ((symbol (cpp-choose-symbol)))
      (list symbol
-          (cpp-choose-face "False face" 
+          (cpp-choose-face "False face"
                            (nth 2 (assoc symbol cpp-edit-list))))))
   (setcar (nthcdr 2 (cpp-edit-list-entry-get-or-create symbol)) face)
   (cpp-edit-reset))
@@ -675,7 +673,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.
@@ -686,7 +684,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
@@ -775,6 +773,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))))))
 
@@ -797,7 +796,8 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
   ;; Create entry for face with background COLOR.
   (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'.
@@ -821,4 +821,5 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
 
 (provide 'cpp)
 
+;;; arch-tag: fb7d433d-745d-495a-96f0-86908ab63f74
 ;;; cpp.el ends here