]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cwarn.el
Merge from emacs-24; up to 2014-06-02T14:17:07Z!michael.albinus@gmx.de
[gnu-emacs] / lisp / progmodes / cwarn.el
index 211c856f9b7d42ec80cac4b7cdcaa3b7ac9340ae..1aa5170591a57a2d64d0bcb675e34c886f33f152 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cwarn.el --- highlight suspicious C and C++ constructions
 
 ;;; cwarn.el --- highlight suspicious C and C++ constructions
 
-;; Copyright (C) 1999-201 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren <andersl@andersl.com>
 ;; Keywords: c, languages, faces
 
 ;; Author: Anders Lindgren <andersl@andersl.com>
 ;; Keywords: c, languages, faces
 
 ;;{{{ Dependencies
 
 
 ;;{{{ Dependencies
 
-(eval-when-compile (require 'cl))
-
 (require 'custom)
 (require 'font-lock)
 (require 'cc-mode)
 (require 'custom)
 (require 'font-lock)
 (require 'cc-mode)
 (defgroup cwarn nil
   "Highlight suspicious C and C++ constructions."
   :version "21.1"
 (defgroup cwarn nil
   "Highlight suspicious C and C++ constructions."
   :version "21.1"
-  :link '(url-link "http://www.andersl.com/emacs")
   :group 'faces)
 
   :group 'faces)
 
-(defvar cwarn-mode nil
-  "*Non-nil when Cwarn mode is active.
-
-Never set this variable directly, use the command `cwarn-mode'
-instead.")
-
 (defcustom cwarn-configuration
   '((c-mode (not reference))
     (c++-mode t))
 (defcustom cwarn-configuration
   '((c-mode (not reference))
     (c++-mode t))
-  "*List of items each describing which features are enable for a mode.
+  "List of items each describing which features are enable for a mode.
 Each item is on the form (mode featurelist), where featurelist can be
 on one of three forms:
 
 Each item is on the form (mode featurelist), where featurelist can be
 on one of three forms:
 
@@ -158,7 +149,7 @@ keyword list."
   :group 'cwarn)
 
 (defcustom cwarn-verbose t
   :group 'cwarn)
 
 (defcustom cwarn-verbose t
-  "*When nil, CWarn mode will not generate any messages.
+  "When nil, CWarn mode will not generate any messages.
 
 Currently, messages are generated when the mode is activated and
 deactivated."
 
 Currently, messages are generated when the mode is activated and
 deactivated."
@@ -166,7 +157,7 @@ deactivated."
   :type 'boolean)
 
 (defcustom cwarn-mode-text " CWarn"
   :type 'boolean)
 
 (defcustom cwarn-mode-text " CWarn"
-  "*String to display in the mode line when CWarn mode is active.
+  "String to display in the mode line when CWarn mode is active.
 
 \(When the string is not empty, make sure that it has a leading space.)"
   :tag "CWarn mode text"                ; To separate it from `global-...'
 
 \(When the string is not empty, make sure that it has a leading space.)"
   :tag "CWarn mode text"                ; To separate it from `global-...'
@@ -174,7 +165,7 @@ deactivated."
   :type 'string)
 
 (defcustom cwarn-load-hook nil
   :type 'string)
 
 (defcustom cwarn-load-hook nil
-  "*Functions to run when CWarn mode is first loaded."
+  "Functions to run when CWarn mode is first loaded."
   :tag "Load Hook"
   :group 'cwarn
   :type 'hook)
   :tag "Load Hook"
   :group 'cwarn
   :type 'hook)
@@ -192,34 +183,31 @@ Note, in addition to enabling this minor mode, the major mode must
 be included in the variable `cwarn-configuration'.  By default C and
 C++ modes are included.
 
 be included in the variable `cwarn-configuration'.  By default C and
 C++ modes are included.
 
-With ARG, turn CWarn mode on if and only if arg is positive."
+With a prefix argument ARG, enable the mode if ARG is positive,
+and disable it otherwise.  If called from Lisp, enable the mode
+if ARG is omitted or nil."
   :group 'cwarn :lighter cwarn-mode-text
   (cwarn-font-lock-keywords cwarn-mode)
   :group 'cwarn :lighter cwarn-mode-text
   (cwarn-font-lock-keywords cwarn-mode)
-  (if font-lock-mode (font-lock-fontify-buffer)))
+  (font-lock-flush))
 
 ;;;###autoload
 
 ;;;###autoload
-(defun turn-on-cwarn-mode ()
-  "Turn on CWarn mode.
-
-This function is designed to be added to hooks, for example:
-  (add-hook 'c-mode-hook 'turn-on-cwarn-mode)"
-  (cwarn-mode 1))
+(define-obsolete-function-alias 'turn-on-cwarn-mode 'cwarn-mode "24.1")
 
 ;;}}}
 ;;{{{ Help functions
 
 (defun cwarn-is-enabled (mode &optional feature)
   "Non-nil if CWarn FEATURE is enabled for MODE.
 
 ;;}}}
 ;;{{{ Help functions
 
 (defun cwarn-is-enabled (mode &optional feature)
   "Non-nil if CWarn FEATURE is enabled for MODE.
-feature is an atom representing one construction to highlight.
+FEATURE is an atom representing one construction to highlight.
 
 Check if any feature is enabled for MODE if no feature is specified.
 
 The valid features are described by the variable
 `cwarn-font-lock-feature-keywords-alist'."
 
 Check if any feature is enabled for MODE if no feature is specified.
 
 The valid features are described by the variable
 `cwarn-font-lock-feature-keywords-alist'."
-  (let ((mode-configuraion (assq mode cwarn-configuration)))
-    (and mode-configuraion
+  (let ((mode-configuration (assq mode cwarn-configuration)))
+    (and mode-configuration
         (or (null feature)
         (or (null feature)
-            (let ((list-or-t (nth 1 mode-configuraion)))
+            (let ((list-or-t (nth 1 mode-configuration)))
               (or (eq list-or-t t)
                   (if (eq (car-safe list-or-t) 'not)
                       (not (memq feature (cdr list-or-t)))
               (or (eq list-or-t t)
                   (if (eq (car-safe list-or-t) 'not)
                       (not (memq feature (cdr list-or-t)))
@@ -235,7 +223,7 @@ The valid features are described by the variable
     (eq (char-after) ?#)))
 
 (defun cwarn-font-lock-keywords (addp)
     (eq (char-after) ?#)))
 
 (defun cwarn-font-lock-keywords (addp)
-  "Install/Remove keywords into current buffer.
+  "Install/remove keywords into current buffer.
 If ADDP is non-nil, install else remove."
   (dolist (pair cwarn-font-lock-feature-keywords-alist)
     (let ((feature (car pair))
 If ADDP is non-nil, install else remove."
   (dolist (pair cwarn-font-lock-feature-keywords-alist)
     (let ((feature (car pair))
@@ -246,29 +234,6 @@ If ADDP is non-nil, install else remove."
          (funcall (if addp 'font-lock-add-keywords 'font-lock-remove-keywords)
                   nil keywords)))))
 
          (funcall (if addp 'font-lock-add-keywords 'font-lock-remove-keywords)
                   nil keywords)))))
 
-;;}}}
-;;{{{ Backward compatibility
-
-;; This piece of code will be part of CC mode as of Emacs 20.4.
-(if (not (fboundp 'c-at-toplevel-p))
-(defun c-at-toplevel-p ()
-  "Return a determination as to whether point is at the `top-level'.
-Being at the top-level means that point is either outside any
-enclosing block (such function definition), or inside a class
-definition, but outside any method blocks.
-
-If point is not at the top-level (e.g. it is inside a method
-definition), then nil is returned.  Otherwise, if point is at a
-top-level not enclosed within a class definition, t is returned.
-Otherwise, a 2-vector is returned where the zeroth element is the
-buffer position of the start of the class declaration, and the first
-element is the buffer position of the enclosing class' opening
-brace."
-  (let ((state (c-parse-state)))
-    (or (not (c-most-enclosing-brace state))
-       (c-search-uplist-for-classkey state))))
-)
-
 ;;}}}
 ;;{{{ Font-lock keywords and match functions
 
 ;;}}}
 ;;{{{ Font-lock keywords and match functions
 
@@ -368,7 +333,7 @@ The semicolon after a `do { ... } while (x);' construction is not matched."
   "Turn on CWarn mode in the current buffer if applicable.
 The mode is turned if some feature is enabled for the current
 `major-mode' in `cwarn-configuration'."
   "Turn on CWarn mode in the current buffer if applicable.
 The mode is turned if some feature is enabled for the current
 `major-mode' in `cwarn-configuration'."
-  (if (cwarn-is-enabled major-mode) (turn-on-cwarn-mode)))
+  (when (cwarn-is-enabled major-mode) (cwarn-mode 1)))
 
 ;;;###autoload
 (define-globalized-minor-mode global-cwarn-mode
 
 ;;;###autoload
 (define-globalized-minor-mode global-cwarn-mode