• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:indent +defs:line +defs:function

61 (defun c-indent-line (&optional syntax quiet ignore-point-pos)
62 "Indent the current line according to the syntactic context,
64 syntactic information for the current line. Be silent about syntactic
68 is otherwise empty \(ignoring any line continuation backslash), but
72 (let ((line-cont-backslash (save-excursion
73 (end-of-line)
80 (beginning-of-line)
81 (looking-at (if line-cont-backslash
88 ;; on the line, so that any code that does back-to-indentation
90 ;; removes a line continuation backslash it'll be restored
107 (c-save-buffer-state (indent)
110 (setq indent (c-get-syntactic-indentation
114 (message "syntax: %s, indent: %d"
115 c-syntactic-context indent))
116 (setq shift-amt (- indent (current-indentation))))
117 (c-shift-line-indentation shift-amt)
118 (run-hooks 'c-special-indent-hook)
121 (let ((indent 0))
123 (while (and (= (forward-line -1) 0)
126 (setq indent (current-indentation))
128 (setq shift-amt (- indent (current-indentation)))
129 (c-shift-line-indentation shift-amt)))
130 (when (and c-fix-backslashes line-cont-backslash)
133 (indent-to bs-col)
136 ;; Realign the line continuation backslash.
140 (defun c-newline-and-indent (&optional newline-arg)
141 "Insert a newline and indent the new line.
142 This function fixes line continuation backslashes if inside a macro,
144 `indent-according-to-mode', so that lineup functions like
150 ;; Avoid calling c-backslash-region from c-indent-line if it's
153 ;; want any backslash alignment from indent-according-to-mode.
158 (beginning-of-line)
161 (= (forward-line -1) 0)))
169 (indent-to col)
173 ;; The backslash stayed on the previous line. Insert one
176 ;; backslashes on the newly inserted line.
180 ;; The backslash moved to the new line, if there was any. Let
181 ;; c-backslash-region fix a backslash on the previous line,
182 ;; and the one that might be on the new line.
190 ;; wasted, since c-indent-line might look at the current
194 ;; We temporarily insert another line break, so that the
195 ;; lineup functions will see the line as empty. That makes
197 ;; proceeds to the preceding line in this case.
204 (indent-according-to-mode))
210 ;; this line, since it then won't align correctly with the
211 ;; lines below if the first line in the macro is broken.
215 "Show syntactic information for current line.
216 With universal argument, inserts the analysis as a comment on that line."
221 ;; `c-indent-line', to be consistent.
243 (indent-for-comment)
249 "Insert a comment with the syntactic analysis on every line in the region."
257 (forward-line)))))
284 (force-mode-line-update)))
293 functions and the electric keys indent according to the syntactic
297 functions indents every new line to the same level as the previous
298 nonempty line, and \\[c-indent-command] adjusts the indentation in steps
301 e.g. `c-special-indent-hook'.
374 line) then all preceding whitespace is consumed. If however a prefix
376 inside a literal then the function in the variable
377 `c-backspace-function' is called."
383 (funcall c-backspace-function (prefix-numeric-value arg))
395 (funcall c-backspace-function 1))))
402 line) then all following whitespace is consumed. If however a prefix
404 inside a literal then the function in the variable `c-delete-function'
411 (funcall c-delete-function (prefix-numeric-value arg))
423 (funcall c-delete-function 1))))
425 ;; This function is only used in XEmacs.
428 This function either deletes forward as `c-electric-delete-forward' or
430 the function `delete-forward-p' is defined and returns non-nil, it
435 function to control that."
442 ;; This function is only used in XEmacs.
446 function `delete-forward-p' is defined and returns non-nil, it deletes
452 function to control that."
473 (and (= (forward-line -1) 0)
474 (progn (end-of-line)
482 (beginning-of-line)
491 ;; nec. the same as the s.c. of the line point is on). N.B. This won't work
522 ;; (not necessarily the same as the S.C. of the line it is on). Return
575 ;; If syntax is a function symbol, then call it using the
587 ;; content of the braces is a single line of code, compact the whole
588 ;; construct to a single line, if this line isn't too long. The Right
605 (forward-line -2)
632 (setq eol-col (save-excursion (end-of-line) (current-column)))
634 ;; Necessary to put the closing brace before any line
653 ;; Can we trim space before comment to make the line fit?
670 the mode line) newlines are inserted before and after the brace as
673 \(b) Any auto-newlines are indented. The original line is also
683 (old-blink-paren blink-paren-function)
684 blink-paren-function)
691 ;; the line here if there's a preceding "else" or something.
697 (indent-according-to-mode))
702 ln-syntax br-syntax syntax) ; Syntactic context of the original line,
703 ; of the brace itself, of the line the brace ends up on.
708 (c-indent-line ln-syntax))
720 ;; after the cleanups when the line has its final
723 (c-newline-and-indent)))
726 ;; `syntax' is the syntactic context of the line which ends up
803 ;; Indent the line after the cleanups since it might
804 ;; very well indent differently due to them, e.g. if
805 ;; c-indent-one-line-block is used together with the
808 (c-indent-line)))
812 (c-newline-and-indent))
831 Indent the line as a comment, if:
833 1. The slash is second of a \"//\" line oriented comment introducing
834 token and we are on a comment-only-line, or
862 (delete-region (progn (forward-line 0) (point))
863 (progn (end-of-line) (point)))
873 (indent-according-to-mode))))
879 comment-only-line, indent the line as a comment. If a numeric ARG is
886 ;; current line, unless this star introduces a comment-only line.
901 (indent-according-to-mode))
912 the mode line) a newline might be inserted. See the variable
915 \(b) Any auto-newlines are indented. The original line is also
938 (c-indent-line))
956 ;; reindent line
959 (c-indent-line c-syntactic-context))
973 (c-newline-and-indent))
984 the mode line) newlines are inserted before and after the colon based on
987 \(b) Any auto-newlines are indented. The original line is also
1006 (indent-according-to-mode))
1026 ;; indent the current line if it's done syntactically.
1031 (indent-according-to-mode))
1047 ;; the following line. Lets first look for ones that can be
1048 ;; found when looking on the line with the colon
1070 (c-newline-and-indent)
1075 (c-newline-and-indent))
1085 line will be reindented if the inserted character is a paren or if it
1169 ;; Indent the line if appropriate.
1179 (indent-according-to-mode)))
1183 blink-paren-function)
1188 (funcall blink-paren-function))))
1194 line is reindented unless a numeric ARG is supplied, or the parenthesis
1197 Whitespace between a function name and the parenthesis may get added or
1212 (old-blink-paren blink-paren-function)
1213 blink-paren-function)
1215 (indent-according-to-mode))
1217 ;; If we're at EOL, check for new-line clean-ups.
1255 ;; Check for clean-ups at function calls. These two DON'T need
1296 "Reindent the current line if appropriate.
1298 This function is used to reindent the line after a keyword which
1302 The line is reindented if there is nothing but whitespace before the
1303 keyword on the line, the keyword is not inserted inside a literal, and
1323 (indent-according-to-mode)
1352 (defun c-in-function-trailer-p (&optional lim)
1364 ;; This function might do hidden buffer changes.
1374 ;; be the return type of a function, or the like. Exclude
1389 ;; constructs, included in the term "function" in the rest of this comment).
1394 ;; at-header : we're at the start of a function's header.
1395 ;; in-header : we're inside a function's header, this extending right
1397 ;; in-block : we're inside a function's brace block.
1400 ;; at-function-end : we're just after the closing brace (or semicolon) that
1401 ;; terminates the function.
1402 ;; outwith-function: we're not at or in any function. Being inside a
1403 ;; non-brace construct also counts as 'outwith-function'.
1405 ;; This function might do hidden buffer changes.
1417 ((c-in-function-trailer-p)
1423 'at-function-end)
1441 ;; of a parameter declaration, not the actual function.
1459 'outwith-function)
1465 'outwith-function))
1468 (c-in-function-trailer-p))
1469 'at-function-end
1470 'outwith-function))
1476 ;; Skip to the opening brace of the Nth function before point. If
1477 ;; point is inside a function, this counts as the first. Point must be
1482 ;; `in-header', `in-block', `in-trailer', `at-function-end',
1483 ;; `outwith-function' as returned by c-where-wrt-brace-construct.
1488 ;; This function may do hidden buffer changes
1499 ((memq where '(at-header outwith-function at-function-end in-trailer))
1533 (beginning-of-defun-function end-of-defun-function
1545 ;; Move forward to the closing brace of a function.
1547 (if (memq where '(at-function-end outwith-function))
1555 ;; ... and backward to the function header.
1559 ;; Move backward to the opening brace of a function.
1563 ;; Go backward to this function's header.
1568 ;; Try to be line oriented; position point at the closest
1581 ;; Skip to the closing brace of the Nth function after point. If
1582 ;; point is inside a function, this counts as the first. Point must be
1587 ;; `in-header', `in-block', `in-trailer', `at-function-end',
1588 ;; `outwith-function' as returned by c-where-wrt-brace-construct.
1593 ;; This function may do hidden buffer changes.
1607 ((memq where '(at-function-end outwith-function at-header in-header))
1636 (beginning-of-defun-function end-of-defun-function
1648 ;; Move backwards to the } of a function
1650 (if (memq where '(at-header outwith-function))
1657 ;; Move forward to the } of a function
1663 (if (c-in-function-trailer-p) ; after "}" of struct/enum, etc.
1668 ;; Try to be line oriented; position point after the next
1676 (forward-line 1))
1688 ;; position is at the next line, providing there is one before the
1691 ;; This function might do hidden buffer changes.
1719 (forward-line 1)
1739 (forward-line 1)
1764 ;; Try to be line oriented; position the limits at the
1787 (forward-line 1)
1793 (defun c-mark-function ()
1798 function does not require the declaration to contain a brace block."
1803 ;; We try to be line oriented, unless there are several
1804 ;; declarations on the same line.
1817 (defun c-in-comment-line-prefix-p ()
1821 ;; This function might do hidden buffer changes.
1824 (beginning-of-line)
1835 ;; present) removed. A c++-style line comment retains its opening "//" but
1842 ;; This function might do hidden buffer changes.
1870 ;; It is not a general function, but is intended only for calling from
1873 ;; This function might do hidden buffer changes.
1910 (if (c-in-comment-line-prefix-p)
1911 (beginning-of-line))
1935 ;; It is not a general function, but is intended only for calling from
1938 ;; This function might do hidden buffer changes.
1998 ;; It is not a general function, but is intended only for calling from
2001 ;; This function might do hidden buffer changes.
2056 ;; It is not a general function, but is intended only for calling from
2059 ;; This function might do hidden buffer changes.
2103 ;; This function might do hidden buffer changes.
2105 (c-collect-line-comments
2131 ;; This function might do hidden buffer changes.
2133 (c-collect-line-comments
2147 ;; This function might do hidden buffer changes.
2193 ;; Note that this function moves within either preprocessor commands
2199 ;; move into parens. Also stop before `#' when it's at boi on a line.
2201 ;; This function might do hidden buffer changes.
2216 ;; a preprocessor line.
2218 (beginning-of-line)
2290 ;; seems unavoidable. Depending on the context this function is called
2309 ;; Note that this function moves within either preprocessor commands
2312 ;; Stop before `{', `}', and `#' when it's at boi on a line, but on the
2318 ;; This function might do hidden buffer changes.
2379 ;; Stop if we encounter a preprocessor line.
2405 (defun c-one-line-string-p (range)
2406 ;; Is the literal defined by RANGE a string contained in a single line?
2408 ;; This function might do hidden buffer changes.
2423 When called from a program, this function takes 3 optional args: the
2441 res ; result from sub-function call
2443 (range (c-collect-line-comments (c-literal-limits lim)))) ; (start.end) of current literal or NIL
2460 ;; Single line string or sentence-flag is null => skip the
2463 (c-one-line-string-p range))
2475 ;; Comment inside a statement or a multi-line string.
2502 (beginning-of-line)
2523 When called from a program, this function takes 3 optional args: the
2539 (range (c-collect-line-comments (c-literal-limits lim)))) ; (start.end) of current literal or NIL
2558 ;; or a Single line string.
2560 (c-one-line-string-p range))
2566 ;; Comment or multi-line string.
2585 (end-of-line)
2606 (function
2628 (defun c-calc-comment-indent (entry)
2629 ;; This function might do hidden buffer changes.
2631 (setq entry (or (assq entry c-indent-comment-alist)
2632 (assq 'other c-indent-comment-alist)
2647 (beginning-of-line)
2660 (c-calc-comment-indent (cdr entry)))))))
2662 (defun c-comment-indent ()
2663 "Used by `indent-for-comment' to create and indent comments.
2664 See `c-indent-comment-alist' for a description."
2666 (end-of-line)
2677 (line-type
2680 ((progn (beginning-of-line)
2682 'empty-line)
2692 (if (and (memq line-type '(anchored-comment empty-line))
2693 c-indent-comments-syntactically-p)
2696 ;; because indent-for-comment hasn't put the comment-start
2701 ;; c-comment-only-line-offset since it doesn't apply here.
2704 (let ((c-comment-only-line-offset
2705 (if (consp c-comment-only-line-offset)
2706 c-comment-only-line-offset
2707 (cons c-comment-only-line-offset
2708 c-comment-only-line-offset))))
2711 (c-calc-comment-indent line-type)))))
2732 function stops at them when going backward, but not when going
2752 function stops at them when going forward, but not when going
2783 after each scan. I.e. if TARGET-DEPTH is -1, the function will move
2792 (search-function (if forward 're-search-forward 're-search-backward))
2805 ;; Find the "next" significant line in the proper direction.
2808 ;; comes at the beginning of a line aside from
2813 (funcall search-function
2816 (beginning-of-line)
2817 ;; Now verify it is really a preproc line.
2849 ;; When searching forward, start from next line so
2850 ;; that we don't find the same line again.
2851 (if forward (forward-line 1))
2857 (if forward (forward-line 1)))))
2868 ;; commands to indent lines, regions, defuns, and expressions
2869 (defun c-indent-command (&optional arg)
2870 "Indent current line as C code, and/or insert some whitespace.
2872 If `c-tab-always-indent' is t, always just indent the current line.
2873 If nil, indent the current line only if point is at the left margin or
2874 in the line's indentation; otherwise insert some whitespace[*]. If
2876 literals (comments and strings), but the line is always reindented.
2880 means indent rigidly all the lines of the expression starting after
2881 point so that this line becomes properly indented. The relative
2884 If `c-syntactic-indentation' is nil, the line is just indented one
2890 variable `c-insert-tab-function', which is called to do the actual
2891 insertion of whitespace. Normally the function in this variable
2893 depending on the variable `indent-tabs-mode'."
2896 (let ((indent-function
2898 (symbol-function 'indent-according-to-mode)
2904 (c-shift-line-indentation (* steps c-basic-offset))
2907 (end-of-line)
2910 ;; Realign the line continuation backslash if inside a macro.
2914 ;; If c-syntactic-indentation and got arg, always indent this
2915 ;; line as C and shift remaining lines of expression the same
2921 (c-indent-line)
2927 (if (eq c-tab-always-indent t)
2928 (beginning-of-line)) ; FIXME!!! What is this here for? ACM 2005/10/31
2933 (forward-line 1)
2936 (indent-code-rigidly beg end shift-amt "#")))
2937 ;; Else use c-tab-always-indent to determine behavior.
2939 ;; CASE 1: indent when at column zero or in line's indentation,
2941 ((not c-tab-always-indent)
2945 (funcall c-insert-tab-function)
2946 (funcall indent-function)))
2947 ;; CASE 2: just indent the line
2948 ((eq c-tab-always-indent t)
2949 (funcall indent-function))
2950 ;; CASE 3: if in a literal, insert a tab, but always indent the
2951 ;; line
2954 (funcall c-insert-tab-function))
2955 (funcall indent-function)
2958 (defun c-indent-exp (&optional shutup-p)
2959 "Indent each line in the balanced expression following point syntactically.
2969 ;; ends on another line.
2980 (error "Cannot find start of balanced expression to indent"))
2985 (error "Cannot find end of balanced expression to indent"))
2986 (forward-line)
2988 (c-indent-region (point) end)))))
2992 (defun c-indent-defun ()
2994 In the macro case this also has the effect of realigning any line
3001 ;; We try to be line oriented, unless there are several
3002 ;; declarations on the same line.
3008 (c-indent-region (car decl-limits)
3013 (defun c-indent-region (start end &optional quiet)
3014 "Indent syntactically every line whose first char is between START
3023 ;; Advance to first nonblank line.
3024 (beginning-of-line)
3027 (beginning-of-line)
3041 (c-progress-init start end 'c-indent-region)
3049 (beginning-of-line)
3050 ;; Get syntax and indent.
3059 (forward-line)
3060 (c-indent-line syntax t t)
3061 (if (progn (end-of-line)
3065 (forward-line)
3068 (forward-line)))
3069 (c-indent-line syntax t t)
3070 (forward-line)))
3074 (c-progress-fini 'c-indent-region))
3083 (defun c-indent-line-or-region ()
3084 "When the region is active, indent it syntactically. Otherwise
3085 indent the current line syntactically."
3089 (c-indent-region (region-beginning) (region-end))
3090 (c-indent-line)))
3149 (defun c-backslash-region (from to delete-flag &optional line-mode)
3150 "Insert, align, or delete end-of-line backslashes on the lines in the region.
3156 This function does not modify blank lines at the start of the region.
3157 If the region ends at the start of a line and the macro doesn't
3159 line is deleted.
3167 ;; position of point that tells the indentation of the line.
3173 column longest-line-col bs-col-after-end)
3176 (if (and (not line-mode) (bobp))
3178 ;; and there's no line to back up to.
3180 (when (and (not line-mode) (bolp))
3181 ;; Do not back up the to line if line-mode is set, to make
3182 ;; e.g. c-newline-and-indent consistent regardless whether
3194 (and (progn (end-of-line)
3196 (= (forward-line 1) 0)
3197 (progn (end-of-line)
3200 (when line-mode
3201 ;; Back up the to line if line-mode is set, since the line
3202 ;; after the newly inserted line break should not be
3203 ;; touched in c-newline-and-indent.
3207 ;; do not want to delete the backslash at the last line.
3209 (if (and line-mode
3214 (setq longest-line-col 0)
3217 ;; Include one more line in the max column
3218 ;; calculation, since the to line will be backslashed
3220 (forward-line 1))
3221 (end-of-line)
3227 (setq longest-line-col (max longest-line-col
3229 (beginning-of-line)
3234 (beginning-of-line)
3247 ;; to line since it's likely to be bogus (e.g. when
3248 ;; called from c-newline-and-indent).
3254 (forward-line 1)))
3255 (if (and column (< column longest-line-col))
3257 ;; any line is too long.
3262 (if (> (% longest-line-col tab-width) 0)
3263 (setq longest-line-col
3264 (* (/ (+ longest-line-col tab-width -1)
3268 longest-line-col)))
3273 ;; after the to line.
3278 ;; remove any on the last line.
3281 (beginning-of-line)
3286 ;; The function above leaves point on the line
3303 (end-of-line)
3325 (indent-to column))
3337 (indent-to column 1)))
3339 (zerop (forward-line 1)))
3340 (bolp))) ; forward-line has funny behavior at eob.
3349 (end-of-line)
3365 (zerop (forward-line 1)))
3366 (bolp)))))) ; forward-line has funny behavior at eob.
3372 (end-of-line)
3380 (zerop (forward-line 1)))
3381 (bolp)))) ; forward-line has funny behavior at eob.
3396 ;; separators, one-line paragraphs etc. Unfortunately, when it comes
3406 ;; line comments). By default, we set up and use adaptive-fill-mode,
3410 ;; Determine the appropriate comment fill prefix for a block or line
3413 ;; function also uses the value of point in some heuristics.
3415 ;; This function might do hidden buffer changes.
3424 prefix-line comment-prefix res comment-text-end)
3445 (beginning-of-line)
3447 ;; The current line is not the comment starter, so the
3448 ;; comment has more than one line, and it can therefore be
3450 (setq prefix-line (point))
3453 (if (and (= (forward-line 1) 0)
3455 ;; The line after the comment starter is inside the
3457 (setq prefix-line (point))
3459 ;; The comment is only one line. Take the comment prefix
3470 ;; starter; take the prefix straight from this line.
3476 ;; have to temporarily insert and indent a new line to
3483 (indent-to (prog1 (current-column)
3495 ;; The prefix ends the line with no whitespace
3507 (beginning-of-line)
3511 ;; The current line is not the comment starter and
3514 (setq prefix-line (point))
3517 (cond ((or (/= (forward-line 1) 0)
3523 ;; The comment is either one line or the next line contains
3530 ;; The point was on the comment opener line, so we might want
3536 ;; second line, so let's use it. Normally it should do
3537 ;; to set `prefix-line' and let the code below pick up
3544 (setq prefix-line (point)))
3546 ;; There's no nonempty prefix on the line after the
3547 ;; comment opener. If the line is empty, or if the
3574 (setq prefix-line (point)))))
3577 ;; Otherwise the line after the comment starter is good
3579 (setq prefix-line (point))))
3582 ;; Haven't got the comment prefix on any real line that we
3584 ;; `comment-prefix' on a line and indent it to find the
3599 ;; If there's ws on the current line, we'll use it
3615 ;; before the line break and after comment-prefix in
3620 (indent-according-to-mode)
3635 ;; prefix-line is the bol of a line on which we should try
3638 (test-line
3651 ;; on another line.
3658 ;; Search for a line which has text after the prefix
3660 ;; after it. We start with the current line, then
3663 (goto-char prefix-line)
3664 (when (and (funcall test-line)
3670 ;; If the current line doesn't have text but do
3677 ;; For line comments we can search up to and
3678 ;; including the first line.
3679 (while (and (zerop (forward-line -1))
3681 (funcall test-line))
3684 (while (and (zerop (forward-line -1))
3686 (funcall test-line)))
3688 (goto-char prefix-line)
3689 (while (and (zerop (forward-line 1))
3691 (funcall test-line))
3693 (goto-char prefix-line)
3697 ;; A good line wasn't found, but at least we have a
3709 ;; on the comment start line that we can
3746 ;; The line doesn't match the comment prefix regexp.
3748 ;; We have a fallback for line comments that we must use.
3750 prefix-line (c-point 'boi))
3772 ;; If APPLY-OUTSIDE-LITERAL is nil then the function will be called
3775 ;; Note that this function does not do any hidden buffer changes.
3813 (setq c-lit-limits (c-collect-line-comments c-lit-limits))
3855 ;; Include the first line in the region.
3857 ;; The first line contains code before the
3858 ;; comment. We must fake a line that doesn't.
3872 ;; it's on its own line, it stays on its own line. If it's got
3873 ;; company on the line, it keeps (at least one word of) it.
3879 (beginning-of-line)
3886 ;; The comment ender IS on its own line. Exclude
3887 ;; this line from the filling.
3914 (forward-line -1) ; last line of the comment
3920 ;; comment line prefix. IS THIS POSSIBLE? (ACM,
3925 ; " \t"? "*/" is NOT alone on the line (ACM, 2005/8/18)
3969 ;; Begin with the next line.
3971 ;; Fake the fill prefix in the first line.
3986 ;; Leave the start line if it's
3996 ;; inside macros is bogus to begin with since the line
4001 (beginning-of-line)
4005 (forward-line)
4017 (beginning-of-line)
4021 (forward-line)
4026 ;; starter so that the first line looks like any other
4027 ;; comment line in the narrowed region.
4043 ;; Find the right spot on the line, break it, insert
4073 ;; Kludge: If the function that adapts the fill prefix
4075 ;; line comments, then force it by setting fill-prefix.
4094 ;; called function.
4099 ;; actual function.
4136 If any of the current line is a comment or within a comment, fill the
4138 comment indentation or line-starting decorations (see the
4155 (let ((fill-paragraph-function
4157 (if (not (eq fill-paragraph-function 'c-fill-paragraph))
4158 fill-paragraph-function)))
4169 ;; The decision whether the line should be broken is actually
4170 ;; done in c-indent-new-comment-line, which do-auto-fill
4178 (defun c-indent-new-comment-line (&optional soft allow-auto-fill)
4179 "Break line at point and indent, continuing comment or macro if within one.
4180 If inside a comment and `comment-multi-line' is non-nil, the
4181 indentation and line prefix are preserved (see the
4183 details). If inside a single line comment and `comment-multi-line' is
4184 nil, a new comment of the same type is started on the next line and
4185 indented as appropriate for comments. If inside a macro, a line
4187 new line is indented according to `c-syntactic-indentation'.
4190 ;; allow-auto-fill is used from c-context-line-break to allow auto
4191 ;; filling to break the line more than once. Since this function is
4196 (do-line-break
4203 ;; c-context-line-break.
4223 ;; The adaptive fill function has generated a prefix, but
4224 ;; we're on the first line in a block comment so it'll be
4229 c-line-comment-starter)
4231 ;; Kludge: If the function that adapted the fill prefix
4232 ;; doesn't produce the required comment starter for line
4242 (funcall do-line-break)
4251 (if (or comment-multi-line
4254 (end-of-line)
4260 (c-collect-line-comments c-lit-limits))
4278 ;; If point is on the 'B' then the line will be
4295 (beginning-of-line)
4306 (funcall do-line-break)
4323 (funcall do-line-break)
4328 ;; c-comment-indent may look at the current
4331 (indent-to col)
4333 (indent-for-comment))))
4337 ;; Do not clobber the alignment of the line continuation
4341 ;; doesn't indent the next line syntactically, and otoh a
4344 (c-newline-and-indent (if allow-auto-fill nil 1)))
4348 (beginning-of-line)
4350 (= (forward-line -1) 0)))
4352 (funcall do-line-break)
4353 (indent-to col))))))
4355 (defalias 'c-comment-line-break-function 'c-indent-new-comment-line)
4356 (make-obsolete 'c-comment-line-break-function 'c-indent-new-comment-line)
4358 ;; advice for indent-new-comment-line for older Emacsen
4359 (unless (boundp 'comment-line-break-function)
4360 (defvar c-inside-line-break-advice nil)
4361 (defadvice indent-new-comment-line (around c-line-break-advice
4363 "Call `c-indent-new-comment-line' if in CC Mode."
4364 (if (or c-inside-line-break-advice
4367 (let ((c-inside-line-break-advice t))
4368 (c-indent-new-comment-line (ad-get-arg 0))))))
4370 (defun c-context-line-break ()
4371 "Do a line break suitable to the context.
4373 When point is outside a comment or macro, insert a newline and indent
4375 is nil, in which case the new line is indented as the previous
4376 non-empty line instead.
4378 When point is inside the content of a preprocessor directive, a line
4379 continuation backslash is inserted before the line break and aligned
4386 C++-style line comment doesn't count as inside it.
4399 (setq c-lit-limits (c-collect-line-comments c-lit-limits)))
4421 (let ((comment-multi-line t)
4423 (c-indent-new-comment-line nil t)))
4433 ;; c-indent-line may look at the current indentation, so let's
4434 ;; start out with the same indentation as the previous line.
4437 (forward-line 0)
4439 (= (forward-line -1) 0)))
4441 (indent-to col))
4442 (indent-according-to-mode)))))
4444 (defun c-context-open-line ()
4445 "Insert a line break suitable to the context and leave point before it.
4446 This is the `c-context-line-break' equivalent to `open-line', which is
4447 normally bound to C-o. See `c-context-line-break' for the details."
4455 (c-context-line-break))