• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/progmodes/

Lines Matching +defs:comment +defs:indent +defs:function

61 (defun c-indent-line (&optional syntax quiet ignore-point-pos)
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))))
118 (run-hooks 'c-special-indent-hook)
121 (let ((indent 0))
126 (setq indent (current-indentation))
128 (setq shift-amt (- indent (current-indentation)))
133 (indent-to bs-col)
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.
169 (indent-to col)
190 ;; wasted, since c-indent-line might look at the current
204 (indent-according-to-mode))
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."
293 functions and the electric keys indent according to the syntactic
298 nonempty line, and \\[c-indent-command] adjusts the indentation in steps
301 e.g. `c-special-indent-hook'.
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))))
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."
575 ;; If syntax is a function symbol, then call it using the
628 (setq cmnt-pos (and (c-backward-single-comment)
635 ;; oriented comment to keep it syntactically significant.
639 (delete-char 1) ; the `}' has blundered into a comment
644 (insert-char ?\} 1) ; reinsert the `}' before the comment.
647 (insert-char ?\ 1) ; Put a space before a bare comment.
653 ;; Can we trim space before comment to make the line fit?
683 (old-blink-paren blink-paren-function)
684 blink-paren-function)
697 (indent-according-to-mode))
708 (c-indent-line ln-syntax))
723 (c-newline-and-indent)))
746 ;; make sure matching open brace isn't in a comment
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))
827 If the slash is inserted immediately after the comment prefix in a c-style
828 comment, the comment might get closed by removing whitespace and possibly
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
837 comment.
848 ;; comment-close-slash cleanup? This DOESN'T need `c-electric-flag' or
852 (memq 'comment-close-slash c-cleanup-list)
855 (regexp-quote comment-end) "\\)?$"))
856 ; (eq c-block-comment-ender "*/") ; C-style comments ALWAYS end in */
861 (looking-at (concat c-current-comment-prefix "[ \t]*$")))))
873 (indent-according-to-mode))))
878 the star is the second character of a C style comment starter on a
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))
938 (c-indent-line))
952 ;; make sure matching open brace isn't in a comment
959 (c-indent-line c-syntactic-context))
973 (c-newline-and-indent))
1006 (indent-according-to-mode))
1026 ;; indent the current line if it's done syntactically.
1031 (indent-according-to-mode))
1070 (c-newline-and-indent)
1075 (c-newline-and-indent))
1179 (indent-according-to-mode)))
1183 blink-paren-function)
1188 (funcall blink-paren-function))))
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))
1255 ;; Check for clean-ups at function calls. These two DON'T need
1298 This function is used to reindent the line after a keyword which
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
1478 ;; outside any comment/string or macro.
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
1537 ;; Move back out of any macro/comment/string we happen to be in.
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.
1569 ;; preceding boi that isn't inside a comment, but if we hit
1573 (c-backward-single-comment)))
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
1583 ;; outside any comment/string or macro.
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
1640 ;; Move back out of any macro/comment/string we happen to be in.
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.
1669 ;; newline that isn't inside a comment, but if we hit the
1673 (c-forward-single-comment)))
1691 ;; This function might do hidden buffer changes.
1766 ;; isn't inside a comment, but if we hit a neighboring
1772 (c-backward-single-comment)))
1783 (c-forward-single-comment)))
1793 (defun c-mark-function ()
1798 function does not require the declaration to contain a brace block."
1817 (defun c-in-comment-line-prefix-p ()
1818 ;; Point is within a comment. Is it also within a comment-prefix?
1819 ;; Space at BOL which precedes a comment-prefix counts as part of it.
1821 ;; This function might do hidden buffer changes.
1826 (and (looking-at c-current-comment-prefix)
1830 (defun c-narrow-to-comment-innards (range)
1831 ;; Narrow to the "inside" of the comment (block) defined by range, as
1834 ;; A c-style block comment has its opening "/*" and its closing "*/" (if
1835 ;; present) removed. A c++-style line comment retains its opening "//" but
1840 ;; eliminates awkward things at the boundaries of the comment (block).
1842 ;; This function might do hidden buffer changes.
1859 (defun c-beginning-of-sentence-in-comment (range)
1860 ;; Move backwards to the "beginning of a sentence" within the comment
1863 ;; of the comment and return T.
1870 ;; It is not a general function, but is intended only for calling from
1873 ;; This function might do hidden buffer changes.
1877 (c-narrow-to-comment-innards range) ; This may move point back.
1880 (here-filler ; matches WS and comment-prefices at point.
1881 (concat "\\=\\(^[ \t]*\\(" c-current-comment-prefix "\\)"
1884 (concat "^[ \t]*\\(" c-current-comment-prefix "\\)[ \t\n\r\f]*\\="))
1900 ;; HERE, or we hit PAR-BEG. Beware of comment prefices!
1905 (and (not (bolp)) ; Found a non-blank comment-prefix?
1910 (if (c-in-comment-line-prefix-p)
1922 (defun c-end-of-sentence-in-comment (range)
1923 ;; Move forward to the "end of a sentence" within the comment defined by
1925 ;; comment delimiter and the terminating */ or newline). If we find an EOS,
1926 ;; return NIL. Otherwise, move point to just after the end of the comment
1932 ;; comment will count as EOS, providing we're not already in it.
1935 ;; It is not a general function, but is intended only for calling from
1938 ;; This function might do hidden buffer changes.
1944 (c-narrow-to-comment-innards range) ; This might move point forwards.
1961 (concat "^[ \t]*\\(" c-current-comment-prefix "\\)\\=")))
1962 ;; Go forward one "comment-prefix which looks like sentence-end"
1974 ;; Take special action if we're up against the end of a comment (of
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.
2098 ;; Point is not in a literal (i.e. comment or string (include AWK regexp)).
2103 ;; This function might do hidden buffer changes.
2108 (if (c-backward-single-comment)
2109 (cons (point) (progn (c-forward-single-comment) (point)))
2126 ;; Point is not in a literal (i.e. comment or string (include AWK regexp)).
2131 ;; This function might do hidden buffer changes.
2140 (if (c-forward-single-comment)
2147 ;; This function might do hidden buffer changes.
2169 ;; Move backwards over code which isn't a literal (i.e. comment or string),
2183 ;; (t . literal): No BOS found: only a comment/string. We _might_ be at
2193 ;; Note that this function moves within either preprocessor commands
2201 ;; This function might do hidden buffer changes.
2210 ;; Stop at the token after a comment.
2211 ((c-backward-single-comment) ; Also functions as backwards-ws.
2283 ;; (i.e. a comment/string) or the boundary of a preprocessor statement or
2290 ;; seems unavoidable. Depending on the context this function is called
2305 ;; As a clarification of "after the end-of-statement", if a comment or
2307 ;; as ending just after the last non-ws character before the comment.
2309 ;; Note that this function moves within either preprocessor commands
2318 ;; This function might do hidden buffer changes.
2337 ;; About to hit a comment?
2338 ((save-excursion (c-forward-single-comment))
2408 ;; This function might do hidden buffer changes.
2421 comment or multiline string, move by sentences instead of statements.
2423 When called from a program, this function takes 3 optional args: the
2441 res ; result from sub-function call
2479 (c-beginning-of-sentence-in-comment range)))
2521 comment or multiline string, move by sentences instead of statements.
2523 When called from a program, this function takes 3 optional args: the
2570 (c-end-of-sentence-in-comment range)))
2573 ;; vsemi. (N.B. AWK can't have a vsemi after a comment, but
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)
2640 (unless value (setq value comment-column))
2654 ;; Found comment to align with.
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."
2679 'anchored-comment)
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.
2703 (c-add-syntax 'comment-intro))
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))
2813 (funcall search-function
2868 ;; commands to indent lines, regions, defuns, and expressions
2869 (defun c-indent-command (&optional arg)
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
2880 means indent rigidly all the lines of the expression starting after
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)
2914 ;; If c-syntactic-indentation and got arg, always indent this
2921 (c-indent-line)
2927 (if (eq c-tab-always-indent t)
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
2954 (funcall c-insert-tab-function))
2955 (funcall indent-function)
2958 (defun c-indent-exp (&optional shutup-p)
2980 (error "Cannot find start of balanced expression to indent"))
2985 (error "Cannot find end of balanced expression to indent"))
2988 (c-indent-region (point) end)))))
2992 (defun c-indent-defun ()
3008 (c-indent-region (car decl-limits)
3013 (defun c-indent-region (start end &optional quiet)
3041 (c-progress-init start end 'c-indent-region)
3050 ;; Get syntax and indent.
3060 (c-indent-line syntax t t)
3069 (c-indent-line syntax t t)
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)))
3156 This function does not modify blank lines at the start of the region.
3182 ;; e.g. c-newline-and-indent consistent regardless whether
3203 ;; touched in c-newline-and-indent.
3248 ;; called from c-newline-and-indent).
3286 ;; The function above leaves point on the line
3325 (indent-to column))
3337 (indent-to column 1)))
3395 ;; possible to make them work correctly wrt the comment and string
3402 ;; We temporarily mask comment starters and enders as necessary for
3410 ;; Determine the appropriate comment fill prefix for a block or line
3411 ;; comment. Return a cons of the prefix string and the column where
3413 ;; function also uses the value of point in some heuristics.
3415 ;; This function might do hidden buffer changes.
3419 c-current-comment-prefix
3421 (comment-start-regexp (if (eq lit-type 'c++)
3423 comment-start-skip))
3424 prefix-line comment-prefix res comment-text-end)
3441 ;; Set fallback for comment-prefix if none is found.
3442 (setq comment-prefix "// "
3443 comment-text-end (cdr lit-limits))
3447 ;; The current line is not the comment starter, so the
3448 ;; comment has more than one line, and it can therefore be
3449 ;; used to find the comment fill prefix.
3455 ;; The line after the comment starter is inside the
3456 ;; comment, so we can use it.
3459 ;; The comment is only one line. Take the comment prefix
3469 ;; There is only whitespace before the comment
3475 ;; There is code before the comment starter, so we
3476 ;; have to temporarily insert and indent a new line to
3483 (indent-to (prog1 (current-column)
3501 (setq comment-text-end
3511 ;; The current line is not the comment starter and
3513 ;; to be used for the comment fill prefix.
3523 ;; The comment is either one line or the next line contains
3524 ;; just the comment ender. In this case we have no
3525 ;; information about a suitable comment prefix, so we resort
3526 ;; to c-block-comment-prefix.
3527 (setq comment-prefix (or c-block-comment-prefix "")))
3530 ;; The point was on the comment opener line, so we might want
3531 ;; to treat this as a not yet closed comment.
3540 ;; all if the comment isn't closed yet, so in that case
3543 (setq comment-prefix (match-string 1))
3547 ;; comment opener. If the line is empty, or if the
3549 ;; comment starter we assume it's an unclosed
3550 ;; comment starter, i.e. that
3551 ;; `c-block-comment-prefix' should be used.
3552 ;; Otherwise we assume it's a closed comment where
3554 ;; E.g. this is an unclosed comment:
3565 ;; (Looking for the presence of the comment closer
3567 ;; some comment further down when the comment
3573 (setq comment-prefix (or c-block-comment-prefix ""))
3577 ;; Otherwise the line after the comment starter is good
3581 (when comment-prefix
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
3592 (if (looking-at comment-start-regexp)
3594 comment-text-end))
3600 ;; instead of what's ending comment-prefix.
3601 (setq comment-prefix
3602 (concat (substring comment-prefix
3605 comment-prefix))
3615 ;; before the line break and after comment-prefix in
3617 (insert-and-inherit "x\n" comment-prefix "x")
3620 (indent-according-to-mode)
3641 (<= (match-end 0) comment-text-end))
3698 ;; fallback that matches the comment prefix regexp.
3709 ;; on the comment start line that we can
3712 (if (looking-at comment-start-regexp)
3746 ;; The line doesn't match the comment prefix regexp.
3747 (if comment-prefix
3751 comment-prefix)
3753 (+ (current-column) (length comment-prefix))))
3756 ;; comment where the lines doesn't have any comment
3765 ;; includes narrowing the buffer and, if point is inside a comment,
3766 ;; masking the comment starter and ender appropriately.
3772 ;; If APPLY-OUTSIDE-LITERAL is nil then the function will be called
3773 ;; only if the point turns out to be inside a comment or a string.
3775 ;; Note that this function does not do any hidden buffer changes.
3786 ;; If hang-ender-stuck isn't nil, the comment ender is
3791 ;; comment's last word and the comment ender, temporarily replaced
3809 ;; Widen to catch comment limits correctly.
3834 ;; For each of the possible types of text (string, C comment ...)
3838 ;; For some of these text types, particularly a block comment, we
3843 ((eq c-lit-type 'c++) ; Line comment.
3845 ;; Limit to the comment or paragraph end, whichever
3850 ;; The region includes the comment starter, so we must
3858 ;; comment. We must fake a line that doesn't.
3863 ((eq c-lit-type 'c) ; Block comment.
3871 ;; There is a comment ender, and the region includes it. If
3874 ;; "=====*/" counts as a comment ender here, but "===== */"
3881 (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
3886 ;; The comment ender IS on its own line. Exclude
3890 ;; The comment ender is hanging. Replace all space between it
3895 ;; afterwards. The effect of this is to glue the comment
3896 ;; ender to the last word in the comment during filling.
3914 (forward-line -1) ; last line of the comment
3916 c-current-comment-prefix
3919 ;; The comment ender is prefixed by nothing but a
3920 ;; comment line prefix. IS THIS POSSIBLE? (ACM,
3965 ;; The region includes the comment starter.
3968 (if (looking-at (concat "\\(" comment-start-skip "\\)$"))
4025 ;; Temporarily insert the fill prefix after the comment
4027 ;; comment line in the narrowed region.
4031 c-current-comment-prefix
4034 ;; Oops, the prefix doesn't match the comment prefix
4041 Warning: Regexp from `c-comment-prefix-regexp' doesn't match the comment prefix %S"
4050 c-current-comment-prefix
4051 comment-start-skip))
4073 ;; Kludge: If the function that adapts the fill prefix
4074 ;; doesn't produce the required comment starter for
4094 ;; called function.
4099 ;; actual function.
4136 If any of the current line is a comment or within a comment, fill the
4137 comment or the paragraph of it that point is in, preserving the
4138 comment indentation or line-starting decorations (see the
4139 `c-comment-prefix-regexp' and `c-block-comment-prefix' variables for
4155 (let ((fill-paragraph-function
4157 (if (not (eq fill-paragraph-function 'c-fill-paragraph))
4158 fill-paragraph-function)))
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
4182 `c-comment-prefix-regexp' and `c-block-comment-prefix' variables for
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
4191 ;; filling to break the line more than once. Since this function is
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
4250 ;; Some sort of comment.
4251 (if (or comment-multi-line
4256 ;; Inside a comment that should be continued.
4264 (comment-text-end
4281 ;; If we have an empty comment, /* */, the next
4288 (if (and (> (point) comment-text-end)
4292 ;; comment; insert the fill prefix at bol
4300 ;; Don't break in the middle of a comment starter
4302 (cond ((> (point) comment-text-end)
4303 (goto-char comment-text-end))
4311 ;; Inside a comment that should be broken.
4312 (let ((comment-start comment-start)
4313 (comment-end comment-end)
4316 (unless (string-match "[ \t]*/\\*" comment-start)
4317 (setq comment-start "/* " comment-end " */"))
4318 (unless (string-match "[ \t]*//" comment-start)
4319 (setq comment-start "// " comment-end "")))
4324 (when (and comment-end (not (equal comment-end "")))
4326 (insert-and-inherit comment-end)
4328 ;; c-comment-indent may look at the current
4331 (indent-to col)
4332 (insert-and-inherit comment-start)
4333 (indent-for-comment))))
4341 ;; doesn't indent the next line syntactically, and otoh a
4344 (c-newline-and-indent (if allow-auto-fill nil 1)))
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)
4361 (defadvice indent-new-comment-line (around c-line-break-advice
4363 "Call `c-indent-new-comment-line' if in CC Mode."
4368 (c-indent-new-comment-line (ad-get-arg 0))))))
4373 When point is outside a comment or macro, insert a newline and indent
4383 When point is inside a comment, continue it with the appropriate
4384 comment prefix (see the `c-comment-prefix-regexp' and
4385 `c-block-comment-prefix' variables for details). The end of a
4386 C++-style line comment doesn't count as inside it.
4404 (and (eq c-lit-type 'c++) ; C++ comment, but not at the very end of it.
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
4441 (indent-to col))
4442 (indent-according-to-mode)))))