(save-excursion
(beginning-of-line)
(looking-at (if line-cont-backslash
- "\\(\\s *\\)\\\\$"
- "\\(\\s *\\)$")))
+ ;; Don't use "\\s " - ^L doesn't count as WS
+ ;; here
+ "\\([ \t]*\\)\\\\$"
+ "\\([ \t]*\\)$")))
(<= (point) (match-end 1)))
;; Delete all whitespace after point if there's only whitespace
;; on the line, so that any code that does back-to-indentation
(narrow-to-region (point-min) (point))
(back-to-indentation)
(looking-at (concat c-current-comment-prefix "[ \t]*$")))))
- (kill-region (progn (forward-line 0) (point))
- (progn (end-of-line) (point)))
+ (delete-region (progn (forward-line 0) (point))
+ (progn (end-of-line) (point)))
(insert-char ?* 1)) ; the / comes later. ; Do I need a t (retain sticky properties) here?
(setq indentp (and (not arg)
(backward-char)
(skip-chars-backward " \t")
(setq beg (point))
- (c-save-buffer-state () (c-on-identifier))
- ;; Don't add a space into #define FOO()....
- (not (and (c-beginning-of-macro)
- (c-forward-over-cpp-define-id)
- (eq (point) beg)))))
+ (and (c-save-buffer-state () (c-on-identifier))
+ ;; Don't add a space into #define FOO()....
+ (not (and (c-beginning-of-macro)
+ (c-forward-over-cpp-define-id)
+ (eq (point) beg))))))
(save-excursion
(delete-region beg end)
(goto-char beg)
(and c-opt-block-decls-with-vars-key
(save-excursion
(c-syntactic-skip-backward "^;}" lim)
- (and (eq (char-before) ?\})
- (eq (car (c-beginning-of-decl-1 lim)) 'previous)
- (looking-at c-opt-block-decls-with-vars-key)
- (point)))))
+ (let ((eo-block (point))
+ bod)
+ (and (eq (char-before) ?\})
+ (eq (car (c-beginning-of-decl-1 lim)) 'previous)
+ (setq bod (point))
+ ;; Look for struct or union or ... If we find one, it might
+ ;; be the return type of a function, or the like. Exclude
+ ;; this case.
+ (c-syntactic-re-search-forward
+ (concat "[;=\(\[{]\\|\\("
+ c-opt-block-decls-with-vars-key
+ "\\)")
+ eo-block t t t)
+ (match-beginning 1) ; Is there a "struct" etc., somewhere?
+ (not (eq (char-before) ?_))
+ (c-syntactic-re-search-forward "[;=\(\[{]" eo-block t t t)
+ (eq (char-before) ?\{)
+ bod)))))
(defun c-where-wrt-brace-construct ()
;; Determine where we are with respect to functions (or other brace
;;
;; This function might do hidden buffer changes.
(save-excursion
- (let* (pos
- kluge-start
+ (let* (kluge-start
decl-result brace-decl-p
(start (point))
(paren-state (c-parse-state))
(setq kluge-start (point))
(setq decl-result
(car (c-beginning-of-decl-1
+ ;; NOTE: If we're in a K&R region, this might be the start
+ ;; of a parameter declaration, not the actual function.
(and least-enclosing ; LIMIT for c-b-of-decl-1
(c-safe-position least-enclosing paren-state)))))
;; Has the declaration we've gone back to got braces?
- (setq pos (point)) ; the search limit for c-recognize-knr-p
(setq brace-decl-p
(save-excursion
(and (c-syntactic-re-search-forward "[;{]" nil t t)
;; ';' in a K&R argdecl. In
;; that case the declaration
;; should contain a block.
- (c-in-knr-argdecl pos))))))
+ (c-in-knr-argdecl))))))
(cond
((= (point) kluge-start) ; might be BOB or unbalanced parens.
(c-syntactic-re-search-forward "{")
(backward-char)
(setq n (1- n)))
- (;; (or (eq where 'at-header) (eq where 'outwith-function)
-;; (eq where 'at-function-end) (eq where 'in-trailer))
- (memq where '(at-header outwith-function at-function-end in-trailer))
+ ((memq where '(at-header outwith-function at-function-end in-trailer))
(c-syntactic-skip-backward "^}")
(when (eq (char-before) ?\})
(backward-sexp)
(or arg (setq arg 1))
(c-save-buffer-state
- ((start (point))
+ (beginning-of-defun-function end-of-defun-function
+ (start (point))
where paren-state pos)
;; Move back out of any macro/comment/string we happen to be in.
(if (< arg 0)
;; Move forward to the closing brace of a function.
(progn
- (if ;; (or (eq where 'at-function-end) (eq where 'outwith-function))
- (memq where '(at-function-end outwith-function))
+ (if (memq where '(at-function-end outwith-function))
(setq arg (1+ arg)))
(if (< arg 0)
(setq arg (c-forward-to-nth-EOF-} (- arg) where)))
;; Move forward to the next opening brace....
(when (and (= arg 0)
- (c-syntactic-re-search-forward "{" nil t))
+ (c-syntactic-re-search-forward "{" nil 'eob))
(backward-char)
;; ... and backward to the function header.
(c-beginning-of-decl-1)
((eq where 'in-trailer)
(c-syntactic-skip-backward "^}")
(setq n (1- n)))
- (;; (or (eq where 'at-function-end) (eq where 'outwith-function)
-;; (eq where 'at-header) (eq where 'in-header))
- (memq where '(at-function-end outwith-function at-header in-header))
- (c-syntactic-re-search-forward "{")
- (backward-char)
- (forward-sexp)
- (setq n (1- n)))
+ ((memq where '(at-function-end outwith-function at-header in-header))
+ (when (c-syntactic-re-search-forward "{" nil 'eob)
+ (backward-char)
+ (forward-sexp)
+ (setq n (1- n))))
(t (error "c-forward-to-nth-EOF-}: `where' is %s" where)))
;; Each time round the loop, go forward to a "}" at the outermost level.
(or arg (setq arg 1))
(c-save-buffer-state
- ((start (point))
+ (beginning-of-defun-function end-of-defun-function
+ (start (point))
where paren-state pos)
;; Move back out of any macro/comment/string we happen to be in.
(if (< arg 0)
;; Move backwards to the } of a function
(progn
- (if ;; (or (eq where 'at-header) (eq where 'outwith-function))
- (memq where '(at-header outwith-function))
+ (if (memq where '(at-header outwith-function))
(setq arg (1+ arg)))
(if (< arg 0)
(setq arg (c-backward-to-nth-BOF-{ (- arg) where)))
- (when (and (= arg 0)
- (c-syntactic-skip-backward "^}")
- (eq (char-before) ?\}))
- t))
+ (if (= arg 0)
+ (c-syntactic-skip-backward "^}")))
;; Move forward to the } of a function
(if (> arg 0)
(c-collect-line-comments c-lit-limits))
c-lit-type)))
(pos (point))
+ (start-col (current-column))
(comment-text-end
(or (and (eq c-lit-type 'c)
(save-excursion
;;
;; If point is on the 'B' then the line will be
;; broken after "Bla b".
+ ;;
+ ;; If we have an empty comment, /* */, the next
+ ;; lot of code pushes point to the */. We fix
+ ;; this by never allowing point to end up to the
+ ;; right of where it started.
(while (and (< (current-column) (cdr fill))
(not (eolp)))
(forward-char 1))
((< (point) (+ (car c-lit-limits) 2))
(goto-char (+ (car c-lit-limits) 2))))
(funcall do-line-break)
- (insert-and-inherit (car fill))))
+ (insert-and-inherit (car fill))
+ (if (> (current-column) start-col)
+ (move-to-column start-col)))) ; can this hit the
+ ; middle of a TAB?
;; Inside a comment that should be broken.
(let ((comment-start comment-start)
(comment-end comment-end)