mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-06 14:22:31 -07:00
CC Mode: Fix positioning of point whilst inserting comments without non-ws
* lisp/progmodes/cc-cmds.el (c-guess-fill-prefix): When determining a new block comment prefix (i.e. there isn't one already there to copy), and that prefix is hard up against a comment closer, ensure there are at least two spaces before the closer. (c-indent-new-comment-line): Amend the strategy for ensuring that point isn't left hard up against the comment closer after M-j.
This commit is contained in:
parent
4e271a6c36
commit
25ed447b7b
1 changed files with 18 additions and 9 deletions
|
|
@ -4083,14 +4083,18 @@ command to conveniently insert and align the necessary backslashes."
|
|||
;; `comment-prefix' on a line and indent it to find the
|
||||
;; correct column and the correct mix of tabs and spaces.
|
||||
(setq res
|
||||
(let (tmp-pre tmp-post)
|
||||
(let (tmp-pre tmp-post at-close)
|
||||
(unwind-protect
|
||||
(progn
|
||||
|
||||
(goto-char (car lit-limits))
|
||||
(if (looking-at comment-start-regexp)
|
||||
(goto-char (min (match-end 0)
|
||||
comment-text-end))
|
||||
(progn
|
||||
(goto-char (min (match-end 0)
|
||||
comment-text-end))
|
||||
(setq
|
||||
at-close
|
||||
(looking-at c-block-comment-ender-regexp)))
|
||||
(forward-char 2)
|
||||
(skip-chars-forward " \t"))
|
||||
|
||||
|
|
@ -4106,8 +4110,13 @@ command to conveniently insert and align the necessary backslashes."
|
|||
(save-excursion
|
||||
(skip-chars-backward " \t")
|
||||
(point))
|
||||
(point)))))
|
||||
|
||||
(point))))
|
||||
;; If hard up against the comment ender, the
|
||||
;; prefix must end in at least two spaces.
|
||||
(when at-close
|
||||
(or (string-match "\\s \\s +\\'" comment-prefix)
|
||||
(setq comment-prefix
|
||||
(concat comment-prefix " ")))))
|
||||
(setq tmp-pre (point-marker))
|
||||
|
||||
;; We insert an extra non-whitespace character
|
||||
|
|
@ -4776,7 +4785,6 @@ If a fill prefix is specified, it overrides all the above."
|
|||
(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
|
||||
|
|
@ -4821,9 +4829,10 @@ If a fill prefix is specified, it overrides all the above."
|
|||
(goto-char (+ (car c-lit-limits) 2))))
|
||||
(funcall do-line-break)
|
||||
(insert-and-inherit (car fill))
|
||||
(if (> (current-column) start-col)
|
||||
(move-to-column start-col)))) ; can this hit the
|
||||
; middle of a TAB?
|
||||
(if (and (looking-at c-block-comment-ender-regexp)
|
||||
(memq (char-before) '(?\ ?\t)))
|
||||
(backward-char)))) ; can this hit the
|
||||
; middle of a TAB?
|
||||
;; Inside a comment that should be broken.
|
||||
(let ((comment-start comment-start)
|
||||
(comment-end comment-end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue