comparison lisp/progmodes/cc-align.el @ 24282:5b0864259a4b Release_5_25

Installed CC Mode 5.25.
author Barry A. Warsaw <barry@zope.org>
date Mon, 08 Feb 1999 16:53:18 +0000
parents 95f894e68525
children 03befb219d03
comparison
equal deleted inserted replaced
24281:d03b1e915af1 24282:5b0864259a4b
1 ;;; cc-align.el --- custom indentation functions for CC Mode 1 ;;; cc-align.el --- custom indentation functions for CC Mode
2 2
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
4 4
5 ;; Authors: 1992-1997 Barry A. Warsaw 5 ;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
6 ;; 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen 7 ;; 1987 Dave Detlefs and Stewart Clamen
7 ;; 1985 Richard M. Stallman 8 ;; 1985 Richard M. Stallman
8 ;; Maintainer: cc-mode-help@python.org 9 ;; Maintainer: bug-cc-mode@gnu.org
9 ;; Created: 22-Apr-1997 (split from cc-mode.el) 10 ;; Created: 22-Apr-1997 (split from cc-mode.el)
10 ;; Version: See cc-mode.el 11 ;; Version: See cc-mode.el
11 ;; Keywords: c languages oop 12 ;; Keywords: c languages oop
12 13
13 ;; This file is part of GNU Emacs. 14 ;; This file is part of GNU Emacs.
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the 27 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA. 29 ;; Boston, MA 02111-1307, USA.
29 30
30 (eval-when-compile 31 (eval-when-compile
32 (require 'cc-defs)
31 (require 'cc-vars) 33 (require 'cc-vars)
32 (require 'cc-engine) 34 (require 'cc-engine)
33 (require 'cc-langs)) 35 (require 'cc-langs))
34 36
35 37
55 (langelem-col (c-langelem-col langelem t))) 57 (langelem-col (c-langelem-col langelem t)))
56 (if (save-excursion 58 (if (save-excursion
57 (beginning-of-line) 59 (beginning-of-line)
58 (looking-at "[ \t]*)")) 60 (looking-at "[ \t]*)"))
59 (progn (goto-char (match-end 0)) 61 (progn (goto-char (match-end 0))
60 (forward-sexp -1) 62 (c-forward-sexp -1)
61 (forward-char 1) 63 (forward-char 1)
62 (c-forward-syntactic-ws) 64 (c-forward-syntactic-ws)
63 (- (current-column) langelem-col)) 65 (- (current-column) langelem-col))
64 (goto-char containing-sexp) 66 (goto-char containing-sexp)
65 (or (eolp) 67 (or (eolp)
109 (save-excursion 111 (save-excursion
110 (condition-case nil 112 (condition-case nil
111 (let (opencol spec) 113 (let (opencol spec)
112 (beginning-of-line) 114 (beginning-of-line)
113 (backward-up-list 1) 115 (backward-up-list 1)
114 (setq spec (if (fboundp 'c-looking-at-special-brace-list) 116 (setq spec (c-looking-at-special-brace-list))
115 (c-looking-at-special-brace-list))) 117 (if spec (goto-char (car (car spec))))
116 (if spec (goto-char (car spec)))
117 (setq opencol (current-column)) 118 (setq opencol (current-column))
118 (forward-char 1) 119 (forward-char 1)
119 (if spec (progn 120 (if spec (progn
120 (c-forward-syntactic-ws) 121 (c-forward-syntactic-ws)
121 (forward-char 1))) 122 (forward-char 1)))
192 (save-excursion 193 (save-excursion
193 (let ((eol (progn (end-of-line) (point)))) 194 (let ((eol (progn (end-of-line) (point))))
194 (beginning-of-line) 195 (beginning-of-line)
195 (skip-chars-forward " \t") 196 (skip-chars-forward " \t")
196 (if (and (eq (following-char) ?{) 197 (if (and (eq (following-char) ?{)
197 (condition-case nil 198 (c-safe (progn (c-forward-sexp) t))
198 (progn (forward-sexp) t)
199 (error nil))
200 (<= (point) eol) 199 (<= (point) eol)
201 (eq (preceding-char) ?})) 200 (eq (preceding-char) ?}))
202 c-basic-offset 201 c-basic-offset
203 0)))) 202 0))))
204 203
289 (< (point) (c-point 'eol))) 288 (< (point) (c-point 'eol)))
290 (skip-chars-forward "^=" (c-point 'eol)) 289 (skip-chars-forward "^=" (c-point 'eol))
291 (if (c-in-literal (cdr langelem)) 290 (if (c-in-literal (cdr langelem))
292 (forward-char 1) 291 (forward-char 1)
293 (setq donep t))) 292 (setq donep t)))
294 (if (not (eq (char-after) ?=)) 293 (if (or (not (eq (char-after) ?=))
294 (save-excursion
295 (forward-char 1)
296 (c-forward-syntactic-ws (c-point 'eol))
297 (eolp)))
295 ;; there's no equal sign on the line 298 ;; there's no equal sign on the line
296 c-basic-offset 299 c-basic-offset
297 ;; calculate indentation column after equals and ws, unless 300 ;; calculate indentation column after equals and ws, unless
298 ;; our line contains an equals sign 301 ;; our line contains an equals sign
299 (if (not equalp) 302 (if (not equalp)
322 (open-bracket-col (progn 325 (open-bracket-col (progn
323 (goto-char open-bracket-pos) 326 (goto-char open-bracket-pos)
324 (current-column))) 327 (current-column)))
325 (target-col (progn 328 (target-col (progn
326 (forward-char) 329 (forward-char)
327 (forward-sexp) 330 (c-forward-sexp)
328 (skip-chars-forward " \t") 331 (skip-chars-forward " \t")
329 (if (eolp) 332 (if (eolp)
330 (+ open-bracket-col c-basic-offset) 333 (+ open-bracket-col c-basic-offset)
331 (current-column)))) 334 (current-column))))
332 ) 335 )
371 (skip-chars-forward "^:" eol) 374 (skip-chars-forward "^:" eol)
372 (if (eq (char-after) ?:) 375 (if (eq (char-after) ?:)
373 (+ curcol (- prev-col-column (current-column))) 376 (+ curcol (- prev-col-column (current-column)))
374 c-basic-offset))))) 377 c-basic-offset)))))
375 378
379 (defun c-lineup-inexpr-block (langelem)
380 ;; This function lines up the block for the various constructs that
381 ;; uses a block inside an expression. For constructs matching
382 ;; c-lambda-key and c-inexpr-block-key, indentation to the column of
383 ;; the beginning of the match is added. For standalone statement
384 ;; blocks, indentation to the column of the opening brace is added.
385 (save-excursion
386 (back-to-indentation)
387 (let ((res (or (c-looking-at-inexpr-block)
388 (if (c-safe (backward-up-list 1)
389 (eq (char-after) ?{))
390 (c-looking-at-inexpr-block)))))
391 (if (not res)
392 0
393 (goto-char (cdr res))
394 (- (current-column)
395 (progn
396 (back-to-indentation)
397 (current-column)))))))
398
376 (defun c-lineup-dont-change (langelem) 399 (defun c-lineup-dont-change (langelem)
377 ;; Do not change the indentation of the current line 400 ;; Do not change the indentation of the current line
378 (save-excursion 401 (save-excursion
379 (back-to-indentation) 402 (back-to-indentation)
380 (current-column))) 403 (current-column)))
392 (let (langelem) 415 (let (langelem)
393 (if (and (eq syntax 'block-close) 416 (if (and (eq syntax 'block-close)
394 (setq langelem (assq 'block-close c-syntactic-context)) 417 (setq langelem (assq 'block-close c-syntactic-context))
395 (progn (goto-char (cdr langelem)) 418 (progn (goto-char (cdr langelem))
396 (if (eq (char-after) ?{) 419 (if (eq (char-after) ?{)
397 (c-safe (forward-sexp -1))) 420 (c-safe (c-forward-sexp -1)))
398 (looking-at "\\<do\\>[^_]"))) 421 (looking-at "\\<do\\>[^_]")))
399 '(before) 422 '(before)
400 '(before after))))) 423 '(before after)))))
401 424
402 (defun c-gnu-impose-minimum () 425 (defun c-gnu-impose-minimum ()