Mercurial > emacs
comparison lisp/progmodes/cpp.el @ 11456:0950bf9c8d06
(cpp-parse-open): Delete comments that go past end of line.
(cpp-edit-reset): Clean up the four standard buttons.
(cpp-parse-buffer): Name was undefined--use cpp-highlight-buffer.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 15 Apr 1995 02:04:41 +0000 |
parents | 9728aab0cab3 |
children | 5865f4bc9521 |
comparison
equal
deleted
inserted
replaced
11455:4235784197f3 | 11456:0950bf9c8d06 |
---|---|
80 ;;;###autoload | 80 ;;;###autoload |
81 (defun cpp-highlight-buffer (arg) | 81 (defun cpp-highlight-buffer (arg) |
82 "Highlight C code according to preprocessor conditionals. | 82 "Highlight C code according to preprocessor conditionals. |
83 This command pops up a buffer which you should edit to specify | 83 This command pops up a buffer which you should edit to specify |
84 what kind of highlighting to use, and the criteria for highlighting. | 84 what kind of highlighting to use, and the criteria for highlighting. |
85 A prefix arg supresses display of that buffer." | 85 A prefix arg suppresses display of that buffer." |
86 (interactive "P") | 86 (interactive "P") |
87 (setq cpp-parse-symbols nil) | 87 (setq cpp-parse-symbols nil) |
88 (cpp-parse-reset) | 88 (cpp-parse-reset) |
89 (if (null cpp-edit-list) | 89 (if (null cpp-edit-list) |
90 (cpp-edit-load)) | 90 (cpp-edit-load)) |
144 (or arg | 144 (or arg |
145 (null cpp-parse-symbols) | 145 (null cpp-parse-symbols) |
146 (cpp-parse-edit))) | 146 (cpp-parse-edit))) |
147 | 147 |
148 (defun cpp-parse-open (branch expr begin end) | 148 (defun cpp-parse-open (branch expr begin end) |
149 ;; Push information about conditional to stack. | 149 "Push information about conditional-beginning onto stack." |
150 ;; Discard comments within this line. | |
150 (while (string-match "\\b[ \t]*/\\*.*\\*/[ \t]*\\b" expr) | 151 (while (string-match "\\b[ \t]*/\\*.*\\*/[ \t]*\\b" expr) |
151 (setq expr (concat (substring expr 0 (match-beginning 0)) | 152 (setq expr (concat (substring expr 0 (match-beginning 0)) |
152 (substring expr (match-end 0))))) | 153 (substring expr (match-end 0))))) |
154 ;; If a comment starts on this line and continues past, discard it. | |
155 (if (string-match "\\b[ \t]*/\\*" expr) | |
156 (setq expr (substring expr 0 (match-beginning 0)))) | |
157 ;; Delete any C++ comment from the line. | |
153 (if (string-match "\\b[ \t]*\\(//.*\\)?$" expr) | 158 (if (string-match "\\b[ \t]*\\(//.*\\)?$" expr) |
154 (setq expr (substring expr 0 (match-beginning 0)))) | 159 (setq expr (substring expr 0 (match-beginning 0)))) |
155 (while (string-match "[ \t]+" expr) | 160 (while (string-match "[ \t]+" expr) |
156 (setq expr (concat (substring expr 0 (match-beginning 0)) | 161 (setq expr (concat (substring expr 0 (match-beginning 0)) |
157 (substring expr (match-end 0))))) | 162 (substring expr (match-end 0))))) |
202 ;;;###autoload | 207 ;;;###autoload |
203 (defun cpp-parse-edit () | 208 (defun cpp-parse-edit () |
204 "Edit display information for cpp conditionals." | 209 "Edit display information for cpp conditionals." |
205 (interactive) | 210 (interactive) |
206 (or cpp-parse-symbols | 211 (or cpp-parse-symbols |
207 (cpp-parse-buffer t)) | 212 (cpp-highlight-buffer t)) |
208 (let ((buffer (current-buffer))) | 213 (let ((buffer (current-buffer))) |
209 (pop-to-buffer "*CPP Edit*") | 214 (pop-to-buffer "*CPP Edit*") |
210 (cpp-edit-mode) | 215 (cpp-edit-mode) |
211 (setq cpp-edit-buffer buffer) | 216 (setq cpp-edit-buffer buffer) |
212 (cpp-edit-reset))) | 217 (cpp-edit-reset))) |
350 | 355 |
351 (defun cpp-edit-apply () | 356 (defun cpp-edit-apply () |
352 "Apply edited display information to original buffer." | 357 "Apply edited display information to original buffer." |
353 (interactive) | 358 (interactive) |
354 (cpp-edit-home) | 359 (cpp-edit-home) |
355 (cpp-parse-buffer t)) | 360 (cpp-highlight-buffer t)) |
356 | 361 |
357 (defun cpp-edit-reset () | 362 (defun cpp-edit-reset () |
358 "Reset display information from original buffer." | 363 "Reset display information from original buffer." |
359 (interactive) | 364 (interactive) |
360 (let ((buffer (current-buffer)) | 365 (let ((buffer (current-buffer)) |
367 (set-buffer buffer) | 372 (set-buffer buffer) |
368 (setq cpp-edit-symbols symbols) | 373 (setq cpp-edit-symbols symbols) |
369 (erase-buffer) | 374 (erase-buffer) |
370 (insert "CPP Display Information for `") | 375 (insert "CPP Display Information for `") |
371 (cpp-make-button (buffer-name cpp-edit-buffer) 'cpp-edit-home) | 376 (cpp-make-button (buffer-name cpp-edit-buffer) 'cpp-edit-home) |
372 (insert "' ") | |
373 (cpp-make-button "[H]ome" 'cpp-edit-home) | |
374 (insert " ") | |
375 (cpp-make-button "[A]pply" 'cpp-edit-apply) | |
376 (insert " ") | |
377 (cpp-make-button "[S]ave" 'cpp-edit-save) | |
378 (insert " ") | |
379 (cpp-make-button "[L]oad" 'cpp-edit-load) | |
380 (insert "\n\nClick mouse-2 on item you want to change or use\n" | 377 (insert "\n\nClick mouse-2 on item you want to change or use\n" |
381 "keyboard equivalent indicated with brackets like [T]his.\n\n") | 378 "or switch to this buffer and type the keyboard equivalents.\n" |
379 "Keyboard equivalents are indicated with brackets like [T]his.\n\n") | |
380 (cpp-make-button "[H]ome (display the C file)" 'cpp-edit-home) | |
381 (insert " ") | |
382 (cpp-make-button "[A]pply new settings" 'cpp-edit-apply) | |
383 (insert "\n") | |
384 (cpp-make-button "[S]ave settings" 'cpp-edit-save) | |
385 (insert " ") | |
386 (cpp-make-button "[L]oad settings" 'cpp-edit-load) | |
387 (insert "\n\n") | |
388 | |
382 (insert "[B]ackground: ") | 389 (insert "[B]ackground: ") |
383 (cpp-make-button (car (rassq cpp-face-type cpp-face-type-list)) | 390 (cpp-make-button (car (rassq cpp-face-type cpp-face-type-list)) |
384 'cpp-edit-background) | 391 'cpp-edit-background) |
385 (insert "\n[K]nown conditionals: ") | 392 (insert "\n[K]nown conditionals: ") |
386 (cpp-make-button (cpp-face-name cpp-known-face) | 393 (cpp-make-button (cpp-face-name cpp-known-face) |