annotate lisp/progmodes/cwarn.el @ 27550:85fc4786dfde

(describe-function-1): Print note about arglist of autoloaded functions. Move arglist of primitives up from end of doc string. (help-manyarg-func-alist): Populate it.
author Dave Love <fx@gnu.org>
date Tue, 01 Feb 2000 14:12:00 +0000
parents f281dfbf8cd2
children 2ae4e53657a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26963
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; cwarn.el --- Highlight suspicious C and C++ constructions.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Anders Lindgren <andersl@andersl.com>
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Keywords: c, languages, faces
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; X-Url: http://www.andersl.com/emacs
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; Version: 1.3.1 1999-12-13
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;{{{ Documentation
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; Description:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; CWarn is a package that highlights suspicious C and C++ constructions.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; For example, take a look at the following piece of C code:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; if (x = 0);
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; foo();
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; The code contains two, possibly fatal, bugs. The first is that the
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; assignment operator "=" is used as part of the test; the user
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; probably ment to use the comparison operator "==".
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; The second problem is that an extra semicolon is placed after
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;; closing parenthesis of the test expression. This makes the body of
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; the if statement to be an empty statement, not the call to the
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; function "foo", as the user probably intended.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;; This package is capable of highlighting the following C and C++
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; constructions:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; * Assignments inside expressions, including variations like "+=".
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; * Semicolon following immediately after `if', `for', and `while'
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; (except, of course, after a `do .. while' statement).
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; * C++ functions with reference parameters.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 ;; Note that none of the constructions highlighted (especially not C++
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 ;; reference parameters) are considered errors by the langauage
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; definitions.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;; Usage:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;; CWarn is implemented as two minor modes: `cwarn-mode' and
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 ;; `global-cwarn-mode'. The former can be applied to individual buffers
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; and the latter to all buffers.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; Activate this package by Customize, or by placing the following line
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 ;; into the appropriate init file:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; (global-cwarn-mode 1)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 ;; Also, `font-lock-mode' or `global-font-lock-mode' must be enabled.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; Afterthought:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 ;; After using this package for several weeks it feels as though I
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; find stupid typo-style bugs while editing rather than at compile-
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;; or run-time, if I ever find them.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 ;; On the other hand, I find myself using assignments inside
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 ;; expressions much more often than I used to do. The reason is that
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; there is no risk of interpreting an assignment operator as a
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; comparison ("hey, the assignment operator is red, duh!").
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; Reporting bugs:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;; Out of the last ten bugs you found, how many did you report?
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; When reporting a bug, please:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 ;; * Send a mail the maintainer of the package, or to the author
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;; if no maintainer exists.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;; * Include the name of the package in the title of the mail, to
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ;; simplify for the recipient.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 ;; * State exactly what you did, what happened, and what you expected
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 ;; to see when you found the bug.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 ;; * If the bug cause an error, set the variable `debug-on-error' to t,
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 ;; repreat the operations that triggered the error and include
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;; the backtrace in the letter.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 ;; * If possible, include an example that activates the bug.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 ;; * Should you speculate about the cause of the problem, please
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ;; state explicitly that you are guessing.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 ;;; Code:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 ;;{{{ Dependencies
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (eval-when-compile (require 'cl))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (require 'custom)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 (require 'font-lock)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (require 'cc-mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 ;;{{{ Variables
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (defgroup cwarn nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 "Highlight suspicious C and C++ constructions."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 :group 'faces)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (defvar cwarn-mode nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 "*Non-nil when Cwarn mode is active.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 Never set this variable directly, use the command `cwarn-mode'
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 instead.")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (defcustom global-cwarn-mode nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 "*When on, suspicious C and C++ constructions are highlighted.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 Set this variable using \\[customize] or use the command
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 `global-cwarn-mode'."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 :initialize 'custom-initialize-default
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 :set '(lambda (symbol value)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (global-cwarn-mode (or value 0)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 :type 'boolean
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :require 'cwarn)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (defcustom cwarn-configuration
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 '((c-mode (not reference))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (c++-mode t))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 "*List of items each describing which features are enable for a mode.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 Each item is on the form (mode featurelist), where featurelist can be
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 on one of three forms:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 * A list of enabled features.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 * A list starting with the atom `not' followed by the features
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 which are not enabled.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 * The atom t, that represent that all features are enabled.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 See variable `cwarn-font-lock-feature-keywords-alist' for available
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 features."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 :group 'cwarn)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 (defcustom cwarn-font-lock-feature-keywords-alist
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 '((assign . cwarn-font-lock-assignment-keywords)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 (semicolon . cwarn-font-lock-semicolon-keywords)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (reference . cwarn-font-lock-reference-keywords))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 "*Maps a CWarn feature to font-lock keywords.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 The keywords could either a font-lock keyword list or a symbol.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 If it is a symbol it is assumed to be a variable containing a font-lock
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 keyword list."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 :group 'cwarn)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (defcustom cwarn-verbose t
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 "*When nil, CWarn mode will not generate any messages.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 Currently, messages are generated when the mode is activated and
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 deactivated."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 :type 'boolean)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 (defcustom cwarn-mode-text " CWarn"
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 "*String to display in the mode line when CWarn mode is active.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 \(When the string is not empty, make sure that it has a leading space.)"
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 :tag "CWarn mode text" ; To separate it from `global-...'
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 :type 'string)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (defcustom cwarn-mode-hook nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 "*Functions to run when CWarn mode is activated."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 :tag "CWarn mode hook" ; To separate it from `global-...'
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 :type 'hook)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 (defcustom global-cwarn-mode-text ""
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 "*String to display when Global CWarn mode is active.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 The default is nothing since when this mode is active this text doesn't
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 vary over time, or between buffers. Hence mode line text
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 would only waste precious space."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 :type 'string)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (defcustom global-cwarn-mode-hook nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 "*Hook called when Global CWarn mode is activated."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 :type 'hook)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (defcustom cwarn-load-hook nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 "*Functions to run when CWarn mode is first loaded."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 :tag "Load Hook"
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 :group 'cwarn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 :type 'hook)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 ;;{{{ The modes
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 ;;;###autoload
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 (defun cwarn-mode (&optional arg)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 "Minor mode that hightlight suspicious C and C++ constructions.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 Note, in addition to enabling this minor mode, the major mode must
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 be included in the variable `cwarn-configuration'. By default C and
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 C++ modes are included.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 With ARG, turn CWarn mode on if and only if arg is positive."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (interactive "P")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (make-local-variable 'cwarn-mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (setq cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (if (null arg)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (not cwarn-mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (> (prefix-numeric-value arg) 0)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (if (and cwarn-verbose
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (interactive-p))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (message "Cwarn mode is now %s."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (if cwarn-mode "on" "off")))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (if (not global-cwarn-mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (if cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (cwarn-font-lock-add-keywords)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (cwarn-font-lock-remove-keywords)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (font-lock-fontify-buffer)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (if cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (run-hooks 'cwarn-mode-hook)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 ;;;###autoload
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 (defun turn-on-cwarn-mode ()
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 "Turn on CWarn mode.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 This function is designed to be added to hooks, for example:
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (add-hook 'c-mode-hook 'turn-on-cwarn-mode)"
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (cwarn-mode 1))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 ;;;###autoload
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (defun global-cwarn-mode (&optional arg)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 "Hightlight suspicious C and C++ constructions in all buffers.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 With ARG, turn CWarn mode on globally if and only if arg is positive."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (interactive "P")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (let ((old-global-cwarn-mode global-cwarn-mode))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (setq global-cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (if (null arg)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (not global-cwarn-mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (> (prefix-numeric-value arg) 0)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (if (and cwarn-verbose
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (interactive-p))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (message "Global CWarn mode is now %s."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (if global-cwarn-mode "on" "off")))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (when (not (eq global-cwarn-mode old-global-cwarn-mode))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 ;; Update for all future buffers.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (dolist (conf cwarn-configuration)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (if global-cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (cwarn-font-lock-add-keywords (car conf))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (cwarn-font-lock-remove-keywords (car conf))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 ;; Update all existing buffers.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (save-excursion
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (dolist (buffer (buffer-list))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (set-buffer buffer)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 ;; Update keywords in alive buffers.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (when (and font-lock-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (not cwarn-mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (cwarn-is-enabled major-mode))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (if global-cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (cwarn-font-lock-add-keywords)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (cwarn-font-lock-remove-keywords))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (font-lock-fontify-buffer))))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 ;; Kills all added keywords :-(
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 ;; (font-lock-mode 0)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 ;; (makunbound 'font-lock-keywords)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 ;; (font-lock-mode 1))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (when global-cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (run-hooks 'global-cwarn-mode-hook)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 ;;{{{ Help functions
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (defun cwarn-is-enabled (mode &optional feature)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 "Non-nil if CWarn FEATURE is enabled for MODE.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 feature is an atom representing one construction to highlight.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 Check if any feature is enabled for MODE if no feature is specified.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 The valid features are described by the variable
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 `cwarn-font-lock-feature-keywords-alist'."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (let ((mode-configuraion (assq mode cwarn-configuration)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (and mode-configuraion
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 (or (null feature)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (let ((list-or-t (nth 1 mode-configuraion)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (or (eq list-or-t t)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (if (eq (car-safe list-or-t) 'not)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (not (memq feature (cdr list-or-t)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (memq feature list-or-t))))))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (defun cwarn-inside-macro ()
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 "True if point is inside a C macro definition."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (save-excursion
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (beginning-of-line)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (while (eq (char-before (1- (point))) ?\\)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (forward-line -1))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (back-to-indentation)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (eq (char-after) ?#)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (defun cwarn-font-lock-add-keywords (&optional mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 "Install keywords into major MODE, or into current buffer if nil."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (dolist (pair cwarn-font-lock-feature-keywords-alist)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (let ((feature (car pair))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (keywords (cdr pair)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (if (not (listp keywords))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (setq keywords (symbol-value keywords)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (if (cwarn-is-enabled (or mode major-mode) feature)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (font-lock-add-keywords mode keywords)))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (defun cwarn-font-lock-remove-keywords (&optional mode)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 "Remove keywords from major MODE, or from current buffer if nil."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (dolist (pair cwarn-font-lock-feature-keywords-alist)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (let ((feature (car pair))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (keywords (cdr pair)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (if (not (listp keywords))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (setq keywords (symbol-value keywords)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (if (cwarn-is-enabled (or mode major-mode) feature)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (font-lock-remove-keywords mode keywords)))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 ;;{{{ Backward compatibility
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 ;; This piece of code will be part of CC mode as of Emacs 20.4.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (if (not (fboundp 'c-at-toplevel-p))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (defun c-at-toplevel-p ()
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 "Return a determination as to whether point is at the `top-level'.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 Being at the top-level means that point is either outside any
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 enclosing block (such function definition), or inside a class
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 definition, but outside any method blocks.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 If point is not at the top-level (e.g. it is inside a method
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 definition), then nil is returned. Otherwise, if point is at a
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 top-level not enclosed within a class definition, t is returned.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 Otherwise, a 2-vector is returned where the zeroth element is the
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 buffer position of the start of the class declaration, and the first
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 element is the buffer position of the enclosing class's opening
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 brace."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (let ((state (c-parse-state)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (or (not (c-most-enclosing-brace state))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (c-search-uplist-for-classkey state))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 )
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 ;;{{{ Font-lock keywords and match functions
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 ;; This section contains font-lock keywords. A font lock keyword can
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 ;; either contain a regular expression or a match function. All
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 ;; keywords defined here use match functions since the C and C++
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 ;; constructions highlighted by CWarn are too complex to be matched by
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 ;; regular expressions.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 ;; A match function should act like a normal forward search. They
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 ;; should return non-nil if they found a candidate and the match data
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 ;; should correspond to the highlight part of the font-lock keyword.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 ;; The functions shold not generate errors, in that case font-lock
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 ;; will fail to highlight the buffer. A match function takes one
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 ;; argument, LIMIT, that represent the end of area to be searched.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 ;;
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 ;; The variable `cwarn-font-lock-feature-keywords-alist' contains a
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 ;; mapping from CWarn features to the font-lock keywords defined
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 ;; below.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 ;;{{{ Assignment in expressions
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (defconst cwarn-font-lock-assignment-keywords
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 '((cwarn-font-lock-match-assignment-in-expression
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (1 font-lock-warning-face))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (defun cwarn-font-lock-match-assignment-in-expression (limit)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 "Match assignments inside expressions."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 (let ((res nil))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (while
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (progn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (setq res (re-search-forward "[^!<>=]\\(=\\)[^=]" limit t))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (and res
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (save-excursion
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (goto-char (match-beginning 1))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (condition-case nil ; In case "backward-up-list" barfs.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (progn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (backward-up-list 1)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (or (not (memq (following-char) '(?\( ?\[)))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (save-match-data
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (skip-chars-backward " ")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (skip-chars-backward "a-zA-Z0-9_")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (or
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 ;; Default parameter of function.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (c-at-toplevel-p)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 (looking-at "for\\>")))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (error t))))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 res))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 ;;{{{ Semicolon
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (defconst cwarn-font-lock-semicolon-keywords
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 '((cwarn-font-lock-match-dangerous-semicolon (0 font-lock-warning-face))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (defun cwarn-font-lock-match-dangerous-semicolon (limit)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 "Match semicolons directly after `for', `while', and `if'.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 Tne semicolon after a `do { ... } while (x);' construction is not matched."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (let ((res nil))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (while
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (progn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (setq res (search-forward ";" limit t))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (and res
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 (save-excursion
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (condition-case nil ; In case something barfs.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 (save-match-data
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 (backward-sexp 2) ; Expression and keyword.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (not (or (looking-at "\\(for\\|if\\)\\>")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (and (looking-at "while\\>")
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (condition-case nil
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (progn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (backward-sexp 2) ; Body and "do".
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (not (looking-at "do\\>")))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 (error t))))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (error t))))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 res))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 ;;{{{ Reference
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (defconst cwarn-font-lock-reference-keywords
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 '((cwarn-font-lock-match-reference (1 font-lock-warning-face))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (defun cwarn-font-lock-match-reference (limit)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 "Font-lock matcher for C++ reference parameters."
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (let ((res nil))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (while
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (progn
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (setq res (re-search-forward "[^&]\\(&\\)[^&=]" limit t))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (and res
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (save-excursion
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (goto-char (match-beginning 1))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (condition-case nil ; In case something barfs.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (save-match-data
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (backward-up-list 1)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (or (not (eq (following-char) ?\())
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (cwarn-inside-macro)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 (not (c-at-toplevel-p))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (error t))))))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 res))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 ;;{{{ The end
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (unless (assq 'cwarn-mode minor-mode-alist)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (push '(cwarn-mode cwarn-mode-text)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 minor-mode-alist))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (unless (assq 'global-cwarn-mode minor-mode-alist)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (push '(global-cwarn-mode global-cwarn-mode-text)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 minor-mode-alist))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (provide 'cwarn)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (run-hooks 'cwarn-load-hook)
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 ;; This makes it possible to set Global CWarn mode from
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 ;; Customize.
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (if global-cwarn-mode
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (global-cwarn-mode 1))
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 ;;}}}
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482
f281dfbf8cd2 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 ;;; cwarn.el ends here