Mercurial > emacs
annotate lisp/progmodes/hideif.el @ 41709:df0a6a02b580
(mark-paragraph): Clarify doc. Clarify
error message. Suggestion from Richard Stallman.
author | Kai Großjohann <kgrossjo@eu.uu.net> |
---|---|
date | Fri, 30 Nov 2001 17:18:27 +0000 |
parents | a4d0b6e48cf4 |
children | c2b7b74ef973 |
rev | line source |
---|---|
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
30805
diff
changeset
|
1 ;;; hideif.el --- hides selected code within ifdef |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
2 |
41645
a4d0b6e48cf4
Fix copyright year.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41644
diff
changeset
|
3 ;; Copyright (C) 1988,1994,2001 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
30805
3cfd3dc474b8
Change authors' mail address.
Gerd Moellmann <gerd@gnu.org>
parents:
30327
diff
changeset
|
5 ;; Author: Daniel LaLiberte <liberte@holonexus.org> |
7324
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
6 ;; Maintainer: FSF |
11455 | 7 ;; Keywords: c, outlines |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
8 |
895
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
10 |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
14 ;; any later version. |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
15 |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
19 ;; GNU General Public License for more details. |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
20 |
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
895
81e6b85a9261
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
853
diff
changeset
|
25 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
26 ;;; Commentary: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
27 |
14169 | 28 ;; To initialize, toggle the hide-ifdef minor mode with |
29 ;; | |
30 ;; M-x hide-ifdef-mode | |
31 ;; | |
32 ;; This will set up key bindings and call hide-ifdef-mode-hook if it | |
33 ;; has a value. To explicitly hide ifdefs using a buffer-local | |
34 ;; define list (default empty), type | |
35 ;; | |
36 ;; M-x hide-ifdefs or C-c @ h | |
37 ;; | |
38 ;; Hide-ifdef suppresses the display of code that the preprocessor wouldn't | |
39 ;; pass through. The support of constant expressions in #if lines is | |
40 ;; limited to identifiers, parens, and the operators: &&, ||, !, and | |
41 ;; "defined". Please extend this. | |
42 ;; | |
43 ;; The hidden code is marked by ellipses (...). Be | |
44 ;; cautious when editing near ellipses, since the hidden text is | |
45 ;; still in the buffer, and you can move the point into it and modify | |
41619 | 46 ;; text unawares. |
14169 | 47 ;; You can make your buffer read-only while hide-ifdef-hiding by setting |
48 ;; hide-ifdef-read-only to a non-nil value. You can toggle this | |
49 ;; variable with hide-ifdef-toggle-read-only (C-c @ C-q). | |
50 ;; | |
51 ;; You can undo the effect of hide-ifdefs by typing | |
52 ;; | |
53 ;; M-x show-ifdefs or C-c @ s | |
54 ;; | |
55 ;; Use M-x hide-ifdef-define (C-c @ d) to define a symbol. | |
56 ;; Use M-x hide-ifdef-undef (C-c @ u) to undefine a symbol. | |
57 ;; | |
58 ;; If you define or undefine a symbol while hide-ifdef-mode is in effect, | |
59 ;; the display will be updated. Only the define list for the current | |
60 ;; buffer will be affected. You can save changes to the local define | |
61 ;; list with hide-ifdef-set-define-alist. This adds entries | |
62 ;; to hide-ifdef-define-alist. | |
63 ;; | |
64 ;; If you have defined a hide-ifdef-mode-hook, you can set | |
65 ;; up a list of symbols that may be used by hide-ifdefs as in the | |
66 ;; following example: | |
67 ;; | |
41619 | 68 ;; (add-hook 'hide-ifdef-mode-hook |
29588
0cf06902af64
(hif-compress-define-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26519
diff
changeset
|
69 ;; (lambda () |
41619 | 70 ;; (unless hide-ifdef-define-alist |
71 ;; (setq hide-ifdef-define-alist | |
72 ;; '((list1 ONE TWO) | |
73 ;; (list2 TWO THREE)))) | |
74 ;; (hide-ifdef-use-define-alist 'list2))) ; use list2 by default | |
14169 | 75 ;; |
30327
09b01c9914a6
Correct author's email address. Fix typo in comment.
Gerd Moellmann <gerd@gnu.org>
parents:
29588
diff
changeset
|
76 ;; You can call hide-ifdef-use-define-alist (C-c @ U) at any time to specify |
14169 | 77 ;; another list to use. |
78 ;; | |
79 ;; To cause ifdefs to be hidden as soon as hide-ifdef-mode is called, | |
80 ;; set hide-ifdef-initially to non-nil. | |
81 ;; | |
82 ;; If you set hide-ifdef-lines to t, hide-ifdefs hides all the #ifdef lines. | |
83 ;; In the absence of highlighting, that might be a bad idea. If you set | |
84 ;; hide-ifdef-lines to nil (the default), the surrounding preprocessor | |
85 ;; lines will be displayed. That can be confusing in its own | |
86 ;; right. Other variations on display are possible, but not much | |
87 ;; better. | |
88 ;; | |
89 ;; You can explicitly hide or show individual ifdef blocks irrespective | |
90 ;; of the define list by using hide-ifdef-block and show-ifdef-block. | |
91 ;; | |
92 ;; You can move the point between ifdefs with forward-ifdef, backward-ifdef, | |
93 ;; up-ifdef, down-ifdef, next-ifdef, and previous-ifdef. | |
94 ;; | |
95 ;; If you have minor-mode-alist in your mode line (the default) two labels | |
96 ;; may appear. "Ifdef" will appear when hide-ifdef-mode is active. "Hiding" | |
97 ;; will appear when text may be hidden ("hide-ifdef-hiding" is non-nil). | |
98 ;; | |
99 ;; Written by Brian Marick, at Gould, Computer Systems Division, Urbana IL. | |
100 ;; Extensively modified by Daniel LaLiberte (while at Gould). | |
101 ;; | |
102 ;; You may freely modify and distribute this, but keep a record | |
103 ;; of modifications and send comments to: | |
104 ;; liberte@a.cs.uiuc.edu or ihnp4!uiucdcs!liberte | |
105 ;; I will continue to upgrade hide-ifdef-mode | |
106 ;; with your contributions. | |
31 | 107 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
108 ;;; Code: |
31 | 109 |
13297
9699410bf8bf
Provide hideif; require cc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
12954
diff
changeset
|
110 (require 'cc-mode) |
9699410bf8bf
Provide hideif; require cc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
12954
diff
changeset
|
111 |
20781 | 112 (defgroup hide-ifdef nil |
113 "Hide selected code within `ifdef'." | |
114 :group 'c) | |
115 | |
41619 | 116 (defvar hide-ifdef-mode-submap |
117 ;; Set up the submap that goes after the prefix key. | |
118 (let ((map (make-sparse-keymap))) | |
119 (define-key map "d" 'hide-ifdef-define) | |
120 (define-key map "u" 'hide-ifdef-undef) | |
121 (define-key map "D" 'hide-ifdef-set-define-alist) | |
122 (define-key map "U" 'hide-ifdef-use-define-alist) | |
7324
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
123 |
41619 | 124 (define-key map "h" 'hide-ifdefs) |
125 (define-key map "s" 'show-ifdefs) | |
126 (define-key map "\C-d" 'hide-ifdef-block) | |
127 (define-key map "\C-s" 'show-ifdef-block) | |
128 | |
129 (define-key map "\C-q" 'hide-ifdef-toggle-read-only) | |
130 (substitute-key-definition | |
131 'toggle-read-only 'hide-ifdef-toggle-outside-read-only map) | |
132 map) | |
133 "Keymap used by `hide-ifdef-mode' under `hide-ifdef-mode-prefix-key'.") | |
31 | 134 |
11652
1162093d885c
(hide-ifdef-mode-prefix-key): Change to C-c @.
Richard M. Stallman <rms@gnu.org>
parents:
11581
diff
changeset
|
135 (defconst hide-ifdef-mode-prefix-key "\C-c@" |
210 | 136 "Prefix key for all Hide-Ifdef mode commands.") |
31 | 137 |
41619 | 138 (defvar hide-ifdef-mode-map |
139 ;; Set up the mode's main map, which leads via the prefix key to the submap. | |
140 (let ((map (make-sparse-keymap))) | |
141 (define-key map hide-ifdef-mode-prefix-key hide-ifdef-mode-submap) | |
142 map) | |
143 "Keymap used with `hide-ifdef-mode'.") | |
31 | 144 |
145 (defvar hide-ifdef-hiding nil | |
7324
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
146 "Non-nil when text may be hidden.") |
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
147 |
31 | 148 (or (assq 'hide-ifdef-hiding minor-mode-alist) |
149 (setq minor-mode-alist | |
150 (cons '(hide-ifdef-hiding " Hiding") | |
151 minor-mode-alist))) | |
152 | |
7379
822429149720
(hide-ifdef-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
7324
diff
changeset
|
153 ;; fix c-mode syntax table so we can recognize whole symbols. |
822429149720
(hide-ifdef-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
7324
diff
changeset
|
154 (defvar hide-ifdef-syntax-table |
41619 | 155 (let ((st (copy-syntax-table c-mode-syntax-table))) |
156 (modify-syntax-entry ?_ "w" st) | |
157 (modify-syntax-entry ?& "." st) | |
158 (modify-syntax-entry ?\| "." st) | |
159 st) | |
7379
822429149720
(hide-ifdef-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
7324
diff
changeset
|
160 "Syntax table used for tokenizing #if expressions.") |
822429149720
(hide-ifdef-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
7324
diff
changeset
|
161 |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
162 (defvar hide-ifdef-env nil |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
163 "An alist of defined symbols and their values.") |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
164 |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
165 (defvar hif-outside-read-only nil |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
166 "Internal variable. Saves the value of `buffer-read-only' while hiding.") |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
167 |
998 | 168 ;;;###autoload |
41619 | 169 (define-minor-mode hide-ifdef-mode |
210 | 170 "Toggle Hide-Ifdef mode. This is a minor mode, albeit a large one. |
15166
83258eb2ede5
(hide-ifdef-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
171 With ARG, turn Hide-Ifdef mode on if arg is positive, off otherwise. |
210 | 172 In Hide-Ifdef mode, code within #ifdef constructs that the C preprocessor |
31 | 173 would eliminate may be hidden from view. Several variables affect |
174 how the hiding is done: | |
175 | |
41619 | 176 `hide-ifdef-env' |
31 | 177 An association list of defined and undefined symbols for the |
210 | 178 current buffer. Initially, the global value of `hide-ifdef-env' |
179 is used. | |
31 | 180 |
41619 | 181 `hide-ifdef-define-alist' |
31 | 182 An association list of defined symbol lists. |
210 | 183 Use `hide-ifdef-set-define-alist' to save the current `hide-ifdef-env' |
184 and `hide-ifdef-use-define-alist' to set the current `hide-ifdef-env' | |
185 from one of the lists in `hide-ifdef-define-alist'. | |
31 | 186 |
41619 | 187 `hide-ifdef-lines' |
31 | 188 Set to non-nil to not show #if, #ifdef, #ifndef, #else, and |
189 #endif lines when hiding. | |
190 | |
41619 | 191 `hide-ifdef-initially' |
210 | 192 Indicates whether `hide-ifdefs' should be called when Hide-Ifdef mode |
31 | 193 is activated. |
194 | |
41619 | 195 `hide-ifdef-read-only' |
31 | 196 Set to non-nil if you want to make buffers read only while hiding. |
210 | 197 After `show-ifdefs', read-only status is restored to previous value. |
31 | 198 |
199 \\{hide-ifdef-mode-map}" | |
41619 | 200 nil " Ifdef" nil |
31 | 201 (if hide-ifdef-mode |
202 (progn | |
41619 | 203 ;; inherit global values |
204 (set (make-local-variable 'hide-ifdef-env) | |
205 (default-value 'hide-ifdef-env)) | |
206 (set (make-local-variable 'hide-ifdef-hiding) | |
207 (default-value 'hide-ifdef-hiding)) | |
208 (set (make-local-variable 'hif-outside-read-only) buffer-read-only) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
209 (set (make-local-variable 'line-move-ignore-invisible) t) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
210 (add-hook 'change-major-mode-hook (lambda () (hide-ifdef-mode -1))) |
31 | 211 |
41619 | 212 (add-to-invisibility-spec '(hide-ifdef . t)) |
31 | 213 |
214 (if hide-ifdef-initially | |
215 (hide-ifdefs) | |
41619 | 216 (show-ifdefs))) |
217 ;; else end hide-ifdef-mode | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
218 (kill-local-variable 'line-move-ignore-invisible) |
31 | 219 (if hide-ifdef-hiding |
41619 | 220 (show-ifdefs)))) |
31 | 221 |
222 | |
223 (defun hif-show-all () | |
224 "Show all of the text in the current buffer." | |
225 (interactive) | |
41619 | 226 (hif-show-ifdef-region (point-min) (point-max))) |
31 | 227 |
13855 | 228 ;; By putting this on after-revert-hook, we arrange that it only |
229 ;; does anything when revert-buffer avoids turning off the mode. | |
230 ;; (That can happen in VC.) | |
41619 | 231 (defun hif-after-revert-function () |
13855 | 232 (and hide-ifdef-mode hide-ifdef-hiding |
233 (hide-ifdefs t))) | |
41619 | 234 (add-hook 'after-revert-hook 'hif-after-revert-function) |
13855 | 235 |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
236 (defun hif-end-of-line () |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
237 (end-of-line) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
238 (while (= (logand 1 (skip-chars-backward "\\\\")) 1) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
239 (end-of-line 2))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
240 |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
241 (defun hide-ifdef-region-internal (start end) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
242 (remove-overlays start end 'invisible 'hide-ifdef) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
243 (let ((o (make-overlay start end))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
244 (overlay-put o 'invisible 'hide-ifdef))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
245 |
31 | 246 (defun hide-ifdef-region (start end) |
247 "START is the start of a #if or #else form. END is the ending part. | |
248 Everything including these lines is made invisible." | |
41619 | 249 (save-excursion |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
250 (goto-char start) (hif-end-of-line) (setq start (point)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
251 (goto-char end) (hif-end-of-line) (setq end (point)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
252 (hide-ifdef-region-internal start end))) |
31 | 253 |
254 (defun hif-show-ifdef-region (start end) | |
255 "Everything between START and END is made visible." | |
41619 | 256 (remove-overlays start end 'invisible 'hide-ifdef)) |
31 | 257 |
258 | |
41619 | 259 ;;===%%SF%% evaluation (Start) === |
31 | 260 |
13855 | 261 ;; It is not useful to set this to anything but `eval'. |
262 ;; In fact, the variable might as well be eliminated. | |
31 | 263 (defvar hide-ifdef-evaluator 'eval |
13855 | 264 "The function to use to evaluate a form. |
265 The evaluator is given a canonical form and returns t if text under | |
31 | 266 that form should be displayed.") |
267 | |
268 (defvar hif-undefined-symbol nil | |
269 "...is by default considered to be false.") | |
270 | |
271 | |
272 (defun hif-set-var (var value) | |
273 "Prepend (var value) pair to hide-ifdef-env." | |
274 (setq hide-ifdef-env (cons (cons var value) hide-ifdef-env))) | |
275 | |
276 | |
277 (defun hif-lookup (var) | |
41619 | 278 ;; (message "hif-lookup %s" var) |
31 | 279 (let ((val (assoc var hide-ifdef-env))) |
280 (if val | |
281 (cdr val) | |
282 hif-undefined-symbol))) | |
283 | |
284 (defun hif-defined (var) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
285 (if (assoc var hide-ifdef-env) 1 0)) |
31 | 286 |
41619 | 287 ;;===%%SF%% evaluation (End) === |
31 | 288 |
289 | |
290 | |
41619 | 291 ;;===%%SF%% parsing (Start) === |
31 | 292 ;;; The code that understands what ifs and ifdef in files look like. |
293 | |
294 (defconst hif-cpp-prefix "\\(^\\|\r\\)[ \t]*#[ \t]*") | |
295 (defconst hif-ifndef-regexp (concat hif-cpp-prefix "ifndef")) | |
296 (defconst hif-ifx-regexp (concat hif-cpp-prefix "if\\(n?def\\)?[ \t]+")) | |
297 (defconst hif-else-regexp (concat hif-cpp-prefix "else")) | |
298 (defconst hif-endif-regexp (concat hif-cpp-prefix "endif")) | |
299 (defconst hif-ifx-else-endif-regexp | |
300 (concat hif-ifx-regexp "\\|" hif-else-regexp "\\|" hif-endif-regexp)) | |
301 | |
41619 | 302 ;; Used to store the current token and the whole token list during parsing. |
303 ;; Only bound dynamically. | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
304 (defvar hif-token) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
305 (defvar hif-token-list) |
31 | 306 |
41619 | 307 ;; pattern to match initial identifier, !, &&, ||, (, or ). |
308 ;; Added ==, + and -: garyo@avs.com 8/9/94 | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
309 (defconst hif-token-regexp |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
310 "\\(&&\\|||\\|[!=]=\\|!\\|[()+-]\\|[<>]=?\\|\\w+\\)") |
31 | 311 |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
312 (defun hif-tokenize (start end) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
313 "Separate string between START and END into a list of tokens." |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
314 (let ((token-list nil)) |
41619 | 315 (with-syntax-table hide-ifdef-syntax-table |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
316 (save-excursion |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
317 (goto-char start) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
318 (while (progn (forward-comment (point-max)) (< (point) end)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
319 ;; (message "expr-start = %d" expr-start) (sit-for 1) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
320 (cond |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
321 ((looking-at "\\\\\n") |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
322 (forward-char 2)) |
31 | 323 |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
324 ((looking-at hif-token-regexp) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
325 (let ((token (buffer-substring (point) (match-end 0)))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
326 (goto-char (match-end 0)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
327 ;; (message "token: %s" token) (sit-for 1) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
328 (push (cond |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
329 ((string-equal token "||") 'or) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
330 ((string-equal token "&&") 'and) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
331 ((string-equal token "==") 'equal) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
332 ((string-equal token "!=") 'hif-notequal) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
333 ((string-equal token "!") 'not) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
334 ((string-equal token "defined") 'hif-defined) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
335 ((string-equal token "(") 'lparen) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
336 ((string-equal token ")") 'rparen) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
337 ((string-equal token ">") 'hif-greater) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
338 ((string-equal token "<") 'hif-less) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
339 ((string-equal token ">=") 'hif-greater-equal) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
340 ((string-equal token "<=") 'hif-less-equal) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
341 ((string-equal token "+") 'hif-plus) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
342 ((string-equal token "-") 'hif-minus) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
343 ((string-match "\\`[0-9]*\\'" token) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
344 (string-to-number token)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
345 (t (intern token))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
346 token-list))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
347 (t (error "Bad #if expression: %s" (buffer-string))))))) |
7379
822429149720
(hide-ifdef-syntax-table): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
7324
diff
changeset
|
348 (nreverse token-list))) |
31 | 349 |
350 ;;;----------------------------------------------------------------- | |
351 ;;; Translate C preprocessor #if expressions using recursive descent. | |
352 ;;; This parser is limited to the operators &&, ||, !, and "defined". | |
8914 | 353 ;;; Added ==, !=, +, and -. Gary Oberbrunner, garyo@avs.com, 8/9/94 |
31 | 354 |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
355 (defun hif-parse-if-exp (hif-token-list) |
31 | 356 "Parse the TOKEN-LIST. Return translated list in prefix form." |
357 (hif-nexttoken) | |
358 (prog1 | |
359 (hif-expr) | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
360 (if hif-token ; is there still a token? |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
361 (error "Error: unexpected token: %s" hif-token)))) |
31 | 362 |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
363 (defsubst hif-nexttoken () |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
364 "Pop the next token from token-list into the let variable \"hif-token\"." |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
365 (setq hif-token (pop hif-token-list))) |
31 | 366 |
367 (defun hif-expr () | |
13855 | 368 "Parse an expression as found in #if. |
31 | 369 expr : term | expr '||' term." |
370 (let ((result (hif-term))) | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
371 (while (eq hif-token 'or) |
31 | 372 (hif-nexttoken) |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
373 (setq result (list 'hif-or result (hif-term)))) |
210 | 374 result)) |
31 | 375 |
376 (defun hif-term () | |
13855 | 377 "Parse a term : eq-expr | term '&&' eq-expr." |
8914 | 378 (let ((result (hif-eq-expr))) |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
379 (while (eq hif-token 'and) |
31 | 380 (hif-nexttoken) |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
381 (setq result (list 'hif-and result (hif-eq-expr)))) |
210 | 382 result)) |
31 | 383 |
8914 | 384 (defun hif-eq-expr () |
19528
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
385 "Parse an eq-expr : math | eq-expr `=='|`!='|`<'|`>'|`>='|`<=' math." |
8914 | 386 (let ((result (hif-math)) |
387 (eq-token nil)) | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
388 (while (memq hif-token '(equal hif-notequal hif-greater hif-less |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
389 hif-greater-equal hif-less-equal)) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
390 (setq eq-token hif-token) |
8914 | 391 (hif-nexttoken) |
392 (setq result (list eq-token result (hif-math)))) | |
393 result)) | |
394 | |
395 (defun hif-math () | |
13855 | 396 "Parse an expression with + or - and simpler things. |
8914 | 397 math : factor | math '+|-' factor." |
398 (let ((result (hif-factor)) | |
399 (math-op nil)) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
400 (while (memq hif-token '(hif-plus hif-minus)) |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
401 (setq math-op hif-token) |
8914 | 402 (hif-nexttoken) |
403 (setq result (list math-op result (hif-factor)))) | |
404 result)) | |
405 | |
31 | 406 (defun hif-factor () |
13855 | 407 "Parse a factor: '!' factor | '(' expr ')' | 'defined(' id ')' | id." |
31 | 408 (cond |
26519 | 409 ((eq hif-token 'not) |
410 (hif-nexttoken) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
411 (list 'hif-not (hif-factor))) |
31 | 412 |
26519 | 413 ((eq hif-token 'lparen) |
414 (hif-nexttoken) | |
415 (let ((result (hif-expr))) | |
416 (if (not (eq hif-token 'rparen)) | |
417 (error "Bad token in parenthesized expression: %s" hif-token) | |
418 (hif-nexttoken) | |
419 result))) | |
31 | 420 |
26519 | 421 ((eq hif-token 'hif-defined) |
422 (hif-nexttoken) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
423 (let ((paren (when (eq hif-token 'lparen) (hif-nexttoken) t)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
424 (ident hif-token)) |
26519 | 425 (if (memq hif-token '(or and not hif-defined lparen rparen)) |
426 (error "Error: unexpected token: %s" hif-token)) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
427 (when paren |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
428 (hif-nexttoken) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
429 (unless (eq hif-token 'rparen) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
430 (error "Error: expected \")\" after identifier"))) |
26519 | 431 (hif-nexttoken) |
41619 | 432 `(hif-defined (quote ,ident)))) |
31 | 433 |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
434 ((numberp hif-token) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
435 (prog1 hif-token (hif-nexttoken))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
436 |
26519 | 437 (t ; identifier |
438 (let ((ident hif-token)) | |
439 (if (memq ident '(or and)) | |
440 (error "Error: missing identifier")) | |
441 (hif-nexttoken) | |
41619 | 442 `(hif-lookup (quote ,ident)))))) |
31 | 443 |
8914 | 444 (defun hif-mathify (val) |
445 "Treat VAL as a number: if it's t or nil, use 1 or 0." | |
41619 | 446 (cond ((eq val t) 1) |
447 ((null val) 0) | |
8914 | 448 (t val))) |
449 | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
450 (defun hif-and (a b) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
451 (and (not (zerop (hif-mathify a))) (not (zerop (hif-mathify b))))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
452 (defun hif-or (a b) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
453 (or (not (zerop (hif-mathify a))) (not (zerop (hif-mathify b))))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
454 (defun hif-not (a) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
455 (zerop (hif-mathify a))) |
8914 | 456 (defun hif-plus (a b) |
457 "Like ordinary plus but treat t and nil as 1 and 0." | |
458 (+ (hif-mathify a) (hif-mathify b))) | |
459 (defun hif-minus (a b) | |
460 "Like ordinary minus but treat t and nil as 1 and 0." | |
461 (- (hif-mathify a) (hif-mathify b))) | |
462 (defun hif-notequal (a b) | |
463 "Like (not (equal A B)) but as one symbol." | |
464 (not (equal a b))) | |
19528
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
465 (defun hif-greater (a b) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
466 "Simple comparison." |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
467 (> (hif-mathify a) (hif-mathify b))) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
468 (defun hif-less (a b) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
469 "Simple comparison." |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
470 (< (hif-mathify a) (hif-mathify b))) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
471 (defun hif-greater-equal (a b) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
472 "Simple comparison." |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
473 (>= (hif-mathify a) (hif-mathify b))) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
474 (defun hif-less-equal (a b) |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
475 "Simple comparison." |
8fc9b5fc7633
(hif-greater, hif-less, hif-greater-equal)
Richard M. Stallman <rms@gnu.org>
parents:
16182
diff
changeset
|
476 (<= (hif-mathify a) (hif-mathify b))) |
31 | 477 ;;;----------- end of parser ----------------------- |
478 | |
479 | |
480 (defun hif-canonicalize () | |
41619 | 481 "When at beginning of #ifX, return a Lisp expression for its condition." |
31 | 482 (save-excursion |
483 (let ((negate (looking-at hif-ifndef-regexp))) | |
484 (re-search-forward hif-ifx-regexp) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
485 (let* ((tokens (hif-tokenize (point) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
486 (progn (hif-end-of-line) (point)))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
487 (expr (hif-parse-if-exp tokens))) |
41619 | 488 ;; (message "hif-canonicalized: %s" expr) |
31 | 489 (if negate |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
490 (list 'hif-not expr) |
31 | 491 expr))))) |
492 | |
493 | |
494 (defun hif-find-any-ifX () | |
13855 | 495 "Move to next #if..., or #ifndef, at point or after." |
41619 | 496 ;; (message "find ifX at %d" (point)) |
31 | 497 (prog1 |
498 (re-search-forward hif-ifx-regexp (point-max) t) | |
499 (beginning-of-line))) | |
500 | |
501 | |
502 (defun hif-find-next-relevant () | |
13855 | 503 "Move to next #if..., #else, or #endif, after the current line." |
41619 | 504 ;; (message "hif-find-next-relevant at %d" (point)) |
31 | 505 (end-of-line) |
41619 | 506 ;; avoid infinite recursion by only going to beginning of line if match found |
31 | 507 (if (re-search-forward hif-ifx-else-endif-regexp (point-max) t) |
210 | 508 (beginning-of-line))) |
31 | 509 |
510 (defun hif-find-previous-relevant () | |
13855 | 511 "Move to previous #if..., #else, or #endif, before the current line." |
41619 | 512 ;; (message "hif-find-previous-relevant at %d" (point)) |
31 | 513 (beginning-of-line) |
41619 | 514 ;; avoid infinite recursion by only going to beginning of line if match found |
31 | 515 (if (re-search-backward hif-ifx-else-endif-regexp (point-min) t) |
210 | 516 (beginning-of-line))) |
31 | 517 |
518 | |
519 (defun hif-looking-at-ifX () ;; Should eventually see #if | |
520 (looking-at hif-ifx-regexp)) | |
521 (defun hif-looking-at-endif () | |
522 (looking-at hif-endif-regexp)) | |
523 (defun hif-looking-at-else () | |
524 (looking-at hif-else-regexp)) | |
525 | |
526 | |
527 | |
528 (defun hif-ifdef-to-endif () | |
529 "If positioned at #ifX or #else form, skip to corresponding #endif." | |
41619 | 530 ;; (message "hif-ifdef-to-endif at %d" (point)) (sit-for 1) |
31 | 531 (hif-find-next-relevant) |
532 (cond ((hif-looking-at-ifX) | |
533 (hif-ifdef-to-endif) ; find endif of nested if | |
534 (hif-ifdef-to-endif)) ; find outer endif or else | |
535 ((hif-looking-at-else) | |
536 (hif-ifdef-to-endif)) ; find endif following else | |
537 ((hif-looking-at-endif) | |
538 'done) | |
539 (t | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3457
diff
changeset
|
540 (error "Mismatched #ifdef #endif pair")))) |
31 | 541 |
542 | |
543 (defun hif-endif-to-ifdef () | |
544 "If positioned at #endif form, skip backward to corresponding #ifX." | |
41619 | 545 ;; (message "hif-endif-to-ifdef at %d" (point)) |
31 | 546 (let ((start (point))) |
547 (hif-find-previous-relevant) | |
548 (if (= start (point)) | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3457
diff
changeset
|
549 (error "Mismatched #ifdef #endif pair"))) |
31 | 550 (cond ((hif-looking-at-endif) |
551 (hif-endif-to-ifdef) ; find beginning of nested if | |
552 (hif-endif-to-ifdef)) ; find beginning of outer if or else | |
553 ((hif-looking-at-else) | |
554 (hif-endif-to-ifdef)) | |
555 ((hif-looking-at-ifX) | |
556 'done) | |
922 | 557 (t))) ; never gets here |
31 | 558 |
559 | |
560 (defun forward-ifdef (&optional arg) | |
561 "Move point to beginning of line of the next ifdef-endif. | |
210 | 562 With argument, do this that many times." |
31 | 563 (interactive "p") |
564 (or arg (setq arg 1)) | |
41619 | 565 (if (< arg 0) (backward-ifdef (- arg)) |
566 (while (< 0 arg) | |
567 (setq arg (- arg)) | |
568 (let ((start (point))) | |
569 (unless (hif-looking-at-ifX) | |
31 | 570 (hif-find-next-relevant)) |
41619 | 571 (if (hif-looking-at-ifX) |
572 (hif-ifdef-to-endif) | |
573 (goto-char start) | |
574 (error "No following #ifdef")))))) | |
31 | 575 |
576 | |
577 (defun backward-ifdef (&optional arg) | |
578 "Move point to beginning of the previous ifdef-endif. | |
210 | 579 With argument, do this that many times." |
31 | 580 (interactive "p") |
581 (or arg (setq arg 1)) | |
41619 | 582 (if (< arg 0) (forward-ifdef (- arg)) |
583 (while (< 0 arg) | |
584 (setq arg (1- arg)) | |
585 (beginning-of-line) | |
586 (let ((start (point))) | |
587 (unless (hif-looking-at-endif) | |
31 | 588 (hif-find-previous-relevant)) |
41619 | 589 (if (hif-looking-at-endif) |
590 (hif-endif-to-ifdef) | |
591 (goto-char start) | |
592 (error "No previous #ifdef")))))) | |
31 | 593 |
594 | |
595 (defun down-ifdef () | |
596 "Move point to beginning of nested ifdef or else-part." | |
597 (interactive) | |
598 (let ((start (point))) | |
599 (hif-find-next-relevant) | |
600 (if (or (hif-looking-at-ifX) (hif-looking-at-else)) | |
601 () | |
602 (goto-char start) | |
210 | 603 (error "No following #ifdef")))) |
31 | 604 |
605 | |
606 (defun up-ifdef () | |
607 "Move point to beginning of enclosing ifdef or else-part." | |
608 (interactive) | |
609 (beginning-of-line) | |
610 (let ((start (point))) | |
41619 | 611 (unless (hif-looking-at-endif) |
612 (hif-find-previous-relevant)) | |
31 | 613 (if (hif-looking-at-endif) |
614 (hif-endif-to-ifdef)) | |
615 (if (= start (point)) | |
210 | 616 (error "No previous #ifdef")))) |
31 | 617 |
618 (defun next-ifdef (&optional arg) | |
619 "Move to the beginning of the next #ifX, #else, or #endif. | |
210 | 620 With argument, do this that many times." |
31 | 621 (interactive "p") |
622 (or arg (setq arg 1)) | |
41619 | 623 (if (< arg 0) (previous-ifdef (- arg)) |
624 (while (< 0 arg) | |
625 (setq arg (1- arg)) | |
626 (hif-find-next-relevant) | |
627 (when (eolp) | |
628 (beginning-of-line) | |
629 (error "No following #ifdefs, #elses, or #endifs"))))) | |
31 | 630 |
631 (defun previous-ifdef (&optional arg) | |
632 "Move to the beginning of the previous #ifX, #else, or #endif. | |
210 | 633 With argument, do this that many times." |
31 | 634 (interactive "p") |
635 (or arg (setq arg 1)) | |
41619 | 636 (if (< arg 0) (next-ifdef (- arg)) |
637 (while (< 0 arg) | |
638 (setq arg (1- arg)) | |
639 (let ((start (point))) | |
640 (hif-find-previous-relevant) | |
641 (if (= start (point)) | |
642 (error "No previous #ifdefs, #elses, or #endifs")))))) | |
31 | 643 |
644 | |
41619 | 645 ;;===%%SF%% parsing (End) === |
31 | 646 |
647 | |
41619 | 648 ;;===%%SF%% hide-ifdef-hiding (Start) === |
31 | 649 |
650 | |
651 ;;; A range is a structure with four components: | |
652 ;;; ELSE-P True if there was an else clause for the ifdef. | |
653 ;;; START The start of the range. (beginning of line) | |
654 ;;; ELSE The else marker (beginning of line) | |
655 ;;; Only valid if ELSE-P is true. | |
656 ;;; END The end of the range. (beginning of line) | |
657 | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
658 (defsubst hif-make-range (start end &optional else) |
41619 | 659 (list start else end)) |
31 | 660 |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
661 (defsubst hif-range-start (range) (elt range 0)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
662 (defsubst hif-range-else (range) (elt range 1)) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
663 (defsubst hif-range-end (range) (elt range 2)) |
31 | 664 |
665 | |
666 | |
667 ;;; Find-Range | |
668 ;;; The workhorse, it delimits the #if region. Reasonably simple: | |
669 ;;; Skip until an #else or #endif is found, remembering positions. If | |
670 ;;; an #else was found, skip some more, looking for the true #endif. | |
671 | |
672 (defun hif-find-range () | |
41619 | 673 "Return a Range structure describing the current #if region. |
31 | 674 Point is left unchanged." |
41619 | 675 ;; (message "hif-find-range at %d" (point)) |
31 | 676 (save-excursion |
677 (beginning-of-line) | |
678 (let ((start (point)) | |
679 (else nil) | |
680 (end nil)) | |
681 ;; Part one. Look for either #endif or #else. | |
682 ;; This loop-and-a-half dedicated to E. Dijkstra. | |
41619 | 683 (while (progn |
684 (hif-find-next-relevant) | |
685 (hif-looking-at-ifX)) ; Skip nested ifdef | |
686 (hif-ifdef-to-endif)) | |
31 | 687 ;; Found either a #else or an #endif. |
688 (cond ((hif-looking-at-else) | |
689 (setq else (point))) | |
690 (t | |
41619 | 691 (setq end (point)))) ; (save-excursion (end-of-line) (point)) |
31 | 692 ;; If found #else, look for #endif. |
41619 | 693 (when else |
694 (while (progn | |
695 (hif-find-next-relevant) | |
696 (hif-looking-at-ifX)) ; Skip nested ifdef | |
697 (hif-ifdef-to-endif)) | |
698 (if (hif-looking-at-else) | |
699 (error "Found two elses in a row? Broken!")) | |
700 (setq end (point))) ; (save-excursion (end-of-line) (point)) | |
701 (hif-make-range start end else)))) | |
31 | 702 |
703 | |
704 ;;; A bit slimy. | |
705 | |
706 (defun hif-hide-line (point) | |
210 | 707 "Hide the line containing point. Does nothing if `hide-ifdef-lines' is nil." |
31 | 708 (if hide-ifdef-lines |
709 (save-excursion | |
710 (goto-char point) | |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
711 (hide-ifdef-region-internal (line-beginning-position) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
712 (progn (hif-end-of-line) (point)))))) |
31 | 713 |
714 | |
715 ;;; Hif-Possibly-Hide | |
716 ;;; There are four cases. The #ifX expression is "taken" if it | |
717 ;;; the hide-ifdef-evaluator returns T. Presumably, this means the code | |
718 ;;; inside the #ifdef would be included when the program was | |
719 ;;; compiled. | |
720 ;;; | |
721 ;;; Case 1: #ifX taken, and there's an #else. | |
722 ;;; The #else part must be hidden. The #if (then) part must be | |
723 ;;; processed for nested #ifX's. | |
724 ;;; Case 2: #ifX taken, and there's no #else. | |
725 ;;; The #if part must be processed for nested #ifX's. | |
726 ;;; Case 3: #ifX not taken, and there's an #else. | |
727 ;;; The #if part must be hidden. The #else part must be processed | |
728 ;;; for nested #ifs. | |
729 ;;; Case 4: #ifX not taken, and there's no #else. | |
730 ;;; The #ifX part must be hidden. | |
731 ;;; | |
732 ;;; Further processing is done by narrowing to the relevant region | |
733 ;;; and just recursively calling hide-ifdef-guts. | |
734 ;;; | |
735 ;;; When hif-possibly-hide returns, point is at the end of the | |
736 ;;; possibly-hidden range. | |
737 | |
738 (defun hif-recurse-on (start end) | |
210 | 739 "Call `hide-ifdef-guts' after narrowing to end of START line and END line." |
31 | 740 (save-excursion |
741 (save-restriction | |
742 (goto-char start) | |
743 (end-of-line) | |
744 (narrow-to-region (point) end) | |
745 (hide-ifdef-guts)))) | |
746 | |
747 (defun hif-possibly-hide () | |
13855 | 748 "Called at #ifX expression, this hides those parts that should be hidden. |
749 It uses the judgement of `hide-ifdef-evaluator'." | |
41619 | 750 ;; (message "hif-possibly-hide") (sit-for 1) |
751 (let ((test (hif-canonicalize)) | |
752 (range (hif-find-range))) | |
753 ;; (message "test = %s" test) (sit-for 1) | |
31 | 754 |
41619 | 755 (hif-hide-line (hif-range-end range)) |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
756 (if (not (hif-not (funcall hide-ifdef-evaluator test))) |
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
757 (cond ((hif-range-else range) ; case 1 |
31 | 758 (hif-hide-line (hif-range-else range)) |
41644
6546efdc0288
(hif-end-of-line): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41619
diff
changeset
|
759 (hide-ifdef-region (hif-range-else range) |
41619 | 760 (1- (hif-range-end range))) |
761 (hif-recurse-on (hif-range-start range) | |
762 (hif-range-else range))) | |
763 (t ; case 2 | |
764 (hif-recurse-on (hif-range-start range) | |
765 (hif-range-end range)))) | |
766 (cond ((hif-range-else range) ; case 3 | |
767 (hif-hide-line (hif-range-else range)) | |
768 (hide-ifdef-region (hif-range-start range) | |
769 (1- (hif-range-else range))) | |
770 (hif-recurse-on (hif-range-else range) | |
771 (hif-range-end range))) | |
772 (t ; case 4 | |
773 (hide-ifdef-region (point) | |
774 (1- (hif-range-end range)))))) | |
775 (hif-hide-line (hif-range-start range)) ; Always hide start. | |
776 (goto-char (hif-range-end range)) | |
777 (end-of-line))) | |
31 | 778 |
779 | |
780 | |
781 (defun hide-ifdef-guts () | |
13855 | 782 "Does most of the work of `hide-ifdefs'. |
783 It does not do the work that's pointless to redo on a recursive entry." | |
41619 | 784 ;; (message "hide-ifdef-guts") |
31 | 785 (save-excursion |
786 (goto-char (point-min)) | |
787 (while (hif-find-any-ifX) | |
788 (hif-possibly-hide)))) | |
789 | |
41619 | 790 ;;===%%SF%% hide-ifdef-hiding (End) === |
31 | 791 |
792 | |
41619 | 793 ;;===%%SF%% exports (Start) === |
31 | 794 |
998 | 795 ;;;###autoload |
20781 | 796 (defcustom hide-ifdef-initially nil |
797 "*Non-nil means call `hide-ifdefs' when Hide-Ifdef mode is first activated." | |
798 :type 'boolean | |
799 :group 'hide-ifdef) | |
31 | 800 |
998 | 801 ;;;###autoload |
20781 | 802 (defcustom hide-ifdef-read-only nil |
803 "*Set to non-nil if you want buffer to be read-only while hiding text." | |
804 :type 'boolean | |
805 :group 'hide-ifdef) | |
31 | 806 |
998 | 807 ;;;###autoload |
20781 | 808 (defcustom hide-ifdef-lines nil |
809 "*Non-nil means hide the #ifX, #else, and #endif lines." | |
810 :type 'boolean | |
811 :group 'hide-ifdef) | |
31 | 812 |
813 (defun hide-ifdef-toggle-read-only () | |
41619 | 814 "Toggle `hide-ifdef-read-only'." |
31 | 815 (interactive) |
816 (setq hide-ifdef-read-only (not hide-ifdef-read-only)) | |
817 (message "Hide-Read-Only %s" | |
818 (if hide-ifdef-read-only "ON" "OFF")) | |
819 (if hide-ifdef-hiding | |
820 (setq buffer-read-only (or hide-ifdef-read-only hif-outside-read-only))) | |
11581
e21661a78292
(hide-ifdef-toggle-read-only): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11455
diff
changeset
|
821 (force-mode-line-update)) |
31 | 822 |
823 (defun hide-ifdef-toggle-outside-read-only () | |
13855 | 824 "Replacement for `toggle-read-only' within Hide-Ifdef mode." |
31 | 825 (interactive) |
826 (setq hif-outside-read-only (not hif-outside-read-only)) | |
827 (message "Read only %s" | |
828 (if hif-outside-read-only "ON" "OFF")) | |
829 (setq buffer-read-only | |
830 (or (and hide-ifdef-hiding hide-ifdef-read-only) | |
41619 | 831 hif-outside-read-only)) |
11581
e21661a78292
(hide-ifdef-toggle-read-only): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11455
diff
changeset
|
832 (force-mode-line-update)) |
31 | 833 |
834 | |
835 (defun hide-ifdef-define (var) | |
836 "Define a VAR so that #ifdef VAR would be included." | |
837 (interactive "SDefine what? ") | |
8914 | 838 (hif-set-var var 1) |
31 | 839 (if hide-ifdef-hiding (hide-ifdefs))) |
840 | |
841 (defun hide-ifdef-undef (var) | |
842 "Undefine a VAR so that #ifdef VAR would not be included." | |
843 (interactive "SUndefine what? ") | |
844 (hif-set-var var nil) | |
845 (if hide-ifdef-hiding (hide-ifdefs))) | |
846 | |
847 | |
13855 | 848 (defun hide-ifdefs (&optional nomsg) |
1476 | 849 "Hide the contents of some #ifdefs. |
850 Assume that defined symbols have been added to `hide-ifdef-env'. | |
851 The text hidden is the text that would not be included by the C | |
852 preprocessor if it were given the file with those symbols defined. | |
31 | 853 |
8375 | 854 Turn off hiding by calling `show-ifdefs'." |
31 | 855 |
856 (interactive) | |
857 (message "Hiding...") | |
13856
8046a1616264
(hide-ifdefs): Set hif-outside-read-only here.
Richard M. Stallman <rms@gnu.org>
parents:
13855
diff
changeset
|
858 (setq hif-outside-read-only buffer-read-only) |
41619 | 859 (unless hide-ifdef-mode (hide-ifdef-mode 1)) ; turn on hide-ifdef-mode |
31 | 860 (if hide-ifdef-hiding |
861 (show-ifdefs)) ; Otherwise, deep confusion. | |
41619 | 862 (setq hide-ifdef-hiding t) |
863 (hide-ifdef-guts) | |
7324
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
864 (setq buffer-read-only (or hide-ifdef-read-only hif-outside-read-only)) |
13855 | 865 (or nomsg |
866 (message "Hiding done"))) | |
31 | 867 |
868 | |
869 (defun show-ifdefs () | |
13855 | 870 "Cancel the effects of `hide-ifdef': show the contents of all #ifdefs." |
31 | 871 (interactive) |
7324
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
872 (setq buffer-read-only hif-outside-read-only) |
41619 | 873 (hif-show-all) |
210 | 874 (setq hide-ifdef-hiding nil)) |
31 | 875 |
876 | |
877 (defun hif-find-ifdef-block () | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3457
diff
changeset
|
878 "Utility for hide and show `ifdef-block'. |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
879 Return as (TOP . BOTTOM) the extent of ifdef block." |
31 | 880 (let (max-bottom) |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
881 (cons (save-excursion |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
882 (beginning-of-line) |
41619 | 883 (unless (or (hif-looking-at-else) (hif-looking-at-ifX)) |
884 (up-ifdef)) | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
885 (prog1 (point) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
886 (hif-ifdef-to-endif) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
887 (setq max-bottom (1- (point))))) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
888 (save-excursion |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
889 (beginning-of-line) |
41619 | 890 (unless (hif-looking-at-endif) |
891 (hif-find-next-relevant)) | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
892 (while (hif-looking-at-ifX) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
893 (hif-ifdef-to-endif) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
894 (hif-find-next-relevant)) |
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
895 (min max-bottom (1- (point))))))) |
31 | 896 |
897 | |
898 (defun hide-ifdef-block () | |
899 "Hide the ifdef block (true or false part) enclosing or before the cursor." | |
900 (interactive) | |
41619 | 901 (unless hide-ifdef-mode (hide-ifdef-mode 1)) |
902 (let ((top-bottom (hif-find-ifdef-block))) | |
23440
21dd0dd62240
(hide-ifdef-env, hif-outside-read-only):
Andreas Schwab <schwab@suse.de>
parents:
20781
diff
changeset
|
903 (hide-ifdef-region (car top-bottom) (cdr top-bottom)) |
41619 | 904 (when hide-ifdef-lines |
905 (hif-hide-line (car top-bottom)) | |
906 (hif-hide-line (1+ (cdr top-bottom)))) | |
210 | 907 (setq hide-ifdef-hiding t)) |
7324
7e78d145539b
(show-ifdefs, hide-ifdefs): Bind inhibit-read-only.
Richard M. Stallman <rms@gnu.org>
parents:
5560
diff
changeset
|
908 (setq buffer-read-only (or hide-ifdef-read-only hif-outside-read-only))) |
31 | 909 |
910 | |
911 (defun show-ifdef-block () | |
912 "Show the ifdef block (true or false part) enclosing or before the cursor." | |
913 (interactive) | |
41619 | 914 (if hide-ifdef-lines |
915 (save-excursion | |
916 (beginning-of-line) | |
917 (hif-show-ifdef-region (1- (point)) (progn (end-of-line) (point)))) | |
918 (let ((top-bottom (hif-find-ifdef-block))) | |
919 (hif-show-ifdef-region (1- (car top-bottom)) (cdr top-bottom))))) | |
31 | 920 |
921 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3457
diff
changeset
|
922 ;;; definition alist support |
31 | 923 |
924 (defvar hide-ifdef-define-alist nil | |
41619 | 925 "A global assoc list of pre-defined symbol lists.") |
31 | 926 |
927 (defun hif-compress-define-list (env) | |
928 "Compress the define list ENV into a list of defined symbols only." | |
41619 | 929 (let ((new-defs nil)) |
930 (dolist (def env new-defs) | |
931 (if (hif-lookup (car def)) (push (car env) new-defs))))) | |
31 | 932 |
933 (defun hide-ifdef-set-define-alist (name) | |
1476 | 934 "Set the association for NAME to `hide-ifdef-env'." |
31 | 935 (interactive "SSet define list: ") |
41619 | 936 (push (cons name (hif-compress-define-list hide-ifdef-env)) |
937 hide-ifdef-define-alist)) | |
31 | 938 |
939 (defun hide-ifdef-use-define-alist (name) | |
1476 | 940 "Set `hide-ifdef-env' to the define list specified by NAME." |
31 | 941 (interactive "SUse define list: ") |
942 (let ((define-list (assoc name hide-ifdef-define-alist))) | |
943 (if define-list | |
944 (setq hide-ifdef-env | |
29588
0cf06902af64
(hif-compress-define-list)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26519
diff
changeset
|
945 (mapcar (lambda (arg) (cons arg t)) |
31 | 946 (cdr define-list))) |
947 (error "No define list for %s" name)) | |
210 | 948 (if hide-ifdef-hiding (hide-ifdefs)))) |
31 | 949 |
13297
9699410bf8bf
Provide hideif; require cc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
12954
diff
changeset
|
950 (provide 'hideif) |
9699410bf8bf
Provide hideif; require cc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
12954
diff
changeset
|
951 |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
952 ;;; hideif.el ends here |