Add 2011 to FSF/AIST copyright years.
[bpt/emacs.git] / lisp / progmodes / cpp.el
index e8d7ce8..5cff3b3 100644 (file)
@@ -1,16 +1,17 @@
 ;;; cpp.el --- highlight or hide text according to cpp conditionals
 
-;; Copyright (C) 1994, 1995, 2003 Free Software Foundation
+;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+;; Free Software Foundation
 
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Keywords: c, faces, tools
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; 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.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -49,6 +48,7 @@
 ;;; 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-")
 
   :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."
-  :type 'face
+  :type 'cpp-face
   :group 'cpp)
 
 (defcustom cpp-unknown-face 'highlight
   "*Face used for unknown cpp symbols."
-  :type 'face
+  :type 'cpp-face
   :group 'cpp)
 
 (defcustom cpp-face-type 'light
@@ -93,10 +97,12 @@ Each entry is a list with the following elements:
 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))))
+  :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 writable" nil)
+                              (const :tag "Both branches writable" both))))
   :group 'cpp)
 
 (defvar cpp-overlay-list nil)
@@ -144,7 +150,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")
-  "Background colours useful with dark foreground colors."
+  "Background colors useful with dark foreground colors."
   :type '(repeat string)
   :group 'cpp)
 
@@ -152,7 +158,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")
-  "Background colours useful with light foreground colors."
+  "Background colors useful with light foreground colors."
   :type '(repeat string)
   :group 'cpp)
 
@@ -181,7 +187,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."
-  :type '(repeat (cons string face))
+  :type '(repeat (cons string cpp-face))
   :group 'cpp)
 
 (defvar cpp-face-all-list
@@ -518,6 +524,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"))
+
+    (setq symbols (reverse symbols))
     (while symbols
       (let*  ((symbol (car symbols))
              (entry (assoc symbol cpp-edit-list))
@@ -567,8 +575,7 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
   "Save the current cpp configuration in a file."
   (interactive)
   (require 'pp)
-  (save-excursion
-    (set-buffer cpp-edit-buffer)
+  (with-current-buffer cpp-edit-buffer
     (let ((buffer (find-file-noselect cpp-config-file)))
       (set-buffer buffer)
       (erase-buffer)
@@ -613,7 +620,8 @@ You can also use the keyboard accelerators indicated like this: [K]ey."
 
 (defun cpp-edit-toggle-known (arg)
   "Toggle writable status for known conditionals.
-With optional argument ARG, make them writable iff ARG is positive."
+With optional argument ARG, make them writable if ARG is positive,
+otherwise make them unwritable."
   (interactive "@P")
   (if (or (and (null arg) cpp-known-writable)
          (<= (prefix-numeric-value arg) 0))
@@ -623,7 +631,8 @@ With optional argument ARG, make them writable iff ARG is positive."
 
 (defun cpp-edit-toggle-unknown (arg)
   "Toggle writable status for unknown conditionals.
-With optional argument ARG, make them writable iff ARG is positive."
+With optional argument ARG, make them writable if ARG is positive,
+otherwise make them unwritable."
   (interactive "@P")
   (if (or (and (null arg) cpp-unknown-writable)
          (<= (prefix-numeric-value arg) 0))
@@ -821,4 +830,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