]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cpp.el
(compilation-start): Pass nil as startfile to comint-exec.
[gnu-emacs] / lisp / progmodes / cpp.el
index 743f5545361fffe66875b45ab18e4566579ea9e9..e85c4752412080c14fe6dd5766b7b5037b6c74f6 100644 (file)
@@ -1,6 +1,7 @@
 ;;; 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, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+;; Free Software Foundation
 
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: c, faces, tools
 
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: c, faces, tools
@@ -9,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 
 ;; GNU Emacs 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)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 
 ;;; Commentary:
 
@@ -32,7 +33,7 @@
 ;;; Todo:
 
 ;; Should parse "#if" and "#elif" expressions and merge the faces
 ;;; 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
 
 ;; 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,6 +50,7 @@
 ;;; Customization:
 (defgroup cpp nil
   "Highlight or hide text according to cpp conditionals."
 ;;; Customization:
 (defgroup cpp nil
   "Highlight or hide text according to cpp conditionals."
+  :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
   :group 'c
   :prefix "cpp-")
 
   :group 'c
   :prefix "cpp-")
 
   :type 'file
   :group 'cpp)
 
   :type 'file
   :group 'cpp)
 
+(define-widget 'cpp-face 'lazy
+  "Either a face or the special symbol 'invisible'."
+  :type '(choice (const invisible) (face)))
+
 (defcustom cpp-known-face 'invisible
   "*Face used for known cpp symbols."
 (defcustom cpp-known-face 'invisible
   "*Face used for known cpp symbols."
-  :type 'face
+  :type 'cpp-face
   :group 'cpp)
 
 (defcustom cpp-unknown-face 'highlight
   "*Face used for unknown cpp symbols."
   :group 'cpp)
 
 (defcustom cpp-unknown-face 'highlight
   "*Face used for unknown cpp symbols."
-  :type 'face
+  :type 'cpp-face
   :group 'cpp)
 
   :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 and don't have
   "*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 and don't have
@@ -92,11 +98,13 @@ 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.
 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."
-  :type '(repeat (list string face face
-                      (choice (const t)
-                              (const nil)
-                              (const both))))
+3. t, nil, or `both' depending on what text may be edited."
+  :type '(repeat (list (string :tag "Macro")
+                      (cpp-face :tag "True")
+                      (cpp-face :tag "False")
+                      (choice (const :tag "True branch writable" t)
+                              (const :tag "False branch writeable" nil)
+                              (const :tag "Both branches writeable" both))))
   :group 'cpp)
 
 (defvar cpp-overlay-list nil)
   :group 'cpp)
 
 (defvar cpp-overlay-list nil)
@@ -144,7 +152,7 @@ or a cons cell (background-color . COLOR)."
   '("light gray" "light blue" "light cyan" "light yellow" "light pink"
     "pale green" "beige" "orange" "magenta" "violet" "medium purple"
     "turquoise")
   '("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 colors useful with dark foreground colors."
   :type '(repeat string)
   :group 'cpp)
 
   :type '(repeat string)
   :group 'cpp)
 
@@ -152,7 +160,7 @@ or a cons cell (background-color . COLOR)."
   '("dim gray" "blue" "cyan" "yellow" "red"
     "dark green" "brown" "dark orange" "dark khaki" "dark violet" "purple"
     "dark turquoise")
   '("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."
+  "Background colors useful with light foreground colors."
   :type '(repeat string)
   :group 'cpp)
 
   :type '(repeat string)
   :group 'cpp)
 
@@ -181,7 +189,7 @@ or a cons cell (background-color . COLOR)."
    '(("default" . default)
      ("invisible" . invisible))
    "Alist of names and faces available even if you don't use a window system."
    '(("default" . default)
      ("invisible" . invisible))
    "Alist of names and faces available even if you don't use a window system."
-  :type '(repeat (cons string face))
+  :type '(repeat (cons string cpp-face))
   :group 'cpp)
 
 (defvar cpp-face-all-list
   :group 'cpp)
 
 (defvar cpp-face-all-list
@@ -368,7 +376,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))
     (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
        ()
           (overlay-put overlay 'face cpp-unknown-face)))
     (if cpp-unknown-writable
        ()
@@ -379,9 +387,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)
 (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)))
 
   (overlay-put overlay 'modification-hooks '(cpp-signal-read-only))
   (overlay-put overlay 'insert-in-front-hooks '(cpp-signal-read-only)))
 
@@ -461,7 +466,7 @@ A prefix arg suppresses display of that buffer."
 
 (defun cpp-edit-mode ()
   "Major mode for editing the criteria for highlighting cpp conditionals.
 
 (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)
 You can also use the keyboard accelerators indicated like this: [K]ey."
   (kill-all-local-variables)
   (buffer-disable-undo)
@@ -521,6 +526,8 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
                     'cpp-edit-toggle-unknown)
     (insert (format "\n\n\n%39s: %14s %14s %7s\n\n" "Expression"
                    "[T]rue Face" "[F]alse Face" "[W]rite"))
                     'cpp-edit-toggle-unknown)
     (insert (format "\n\n\n%39s: %14s %14s %7s\n\n" "Expression"
                    "[T]rue Face" "[F]alse Face" "[W]rite"))
+
+    (setq symbols (reverse symbols))
     (while symbols
       (let*  ((symbol (car symbols))
              (entry (assoc symbol cpp-edit-list))
     (while symbols
       (let*  ((symbol (car symbols))
              (entry (assoc symbol cpp-edit-list))
@@ -535,7 +542,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))
                 (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)))
        (if (> (length symbol) 39)
            (insert (substring symbol 0 39) ": ")
          (insert (format "%39s: " symbol)))
@@ -649,7 +656,7 @@ With optional argument ARG, make them writable iff ARG is positive."
   (interactive
    (let ((symbol (cpp-choose-symbol)))
      (list symbol
   (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))
                            (nth 2 (assoc symbol cpp-edit-list))))))
   (setcar (nthcdr 2 (cpp-edit-list-entry-get-or-create symbol)) face)
   (cpp-edit-reset))
@@ -676,7 +683,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
   ;; 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.
 
 (defun cpp-choose-branch ()
   ;; Choose a branch, either nil, t, or both.
@@ -824,4 +831,5 @@ BRANCH should be either nil (false branch), t (true branch) or 'both."
 
 (provide 'cpp)
 
 
 (provide 'cpp)
 
+;;; arch-tag: fb7d433d-745d-495a-96f0-86908ab63f74
 ;;; cpp.el ends here
 ;;; cpp.el ends here