Mercurial > emacs
changeset 19804:37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
handle M-e moving forward into a comment when looking at preceding
whitespace, and M-a moving backward into comment when looking at
following whitespace.
(c-comment-line-break-function): Don't break line in the middle of a string.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 08 Sep 1997 03:20:02 +0000 |
parents | 7573e51f9c41 |
children | e804ac04eec1 |
files | lisp/progmodes/cc-cmds.el |
diffstat | 1 files changed, 36 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/cc-cmds.el Sun Sep 07 18:32:49 1997 +0000 +++ b/lisp/progmodes/cc-cmds.el Mon Sep 08 03:20:02 1997 +0000 @@ -7,7 +7,7 @@ ;; 1985 Richard M. Stallman ;; Maintainer: cc-mode-help@python.org ;; Created: 22-Apr-1997 (split from cc-mode.el) -;; Version: 5.16 +;; Version: 5.17 ;; Keywords: c languages oop ;; This file is part of GNU Emacs. @@ -617,11 +617,17 @@ (if (and sentence-flag (or (nth 3 state) (nth 4 state) -; (looking-at (concat "[ \t]*" comment-start-skip)) - (save-excursion - (skip-chars-backward " \t") - (goto-char (- (point) 2)) - (looking-at "\\*/")))) + ;; skipping forward into a comment? + (and (> 0 count) + (save-excursion + (skip-chars-forward " \t\n") + (or (eobp) + (looking-at comment-start-skip)))) + (and (< 0 count) + (save-excursion + (skip-chars-backward " \t\n") + (goto-char (- (point) 2)) + (looking-at "\\*/"))))) (forward-sentence (- count)) (while (> count 0) (c-beginning-of-statement-1 lim) @@ -747,28 +753,33 @@ comment-column)) ))))) + ;; for proposed new variable comment-line-break-function (defun c-comment-line-break-function (&optional soft) ;; we currently don't do anything with soft line breaks - (if (or (not c-comment-continuation-stars) - (not (c-in-literal))) - (indent-new-comment-line soft) - (let ((here (point)) - (leader c-comment-continuation-stars)) - (back-to-indentation) - ;; are we looking at a block or lines style comment? - (if (and (looking-at (concat "\\(" c-comment-start-regexp "\\)[ \t]+")) - (string-equal (match-string 1) "//")) - ;; line style - (setq leader "// ")) - (goto-char here) - (delete-region (progn (skip-chars-backward " \t") (point)) - (progn (skip-chars-forward " \t") (point))) - (newline) - ;; to avoid having an anchored comment that c-indent-line will - ;; trip up on - (insert " " leader) - (c-indent-line)))) + (let ((literal (c-in-literal))) + (cond + ((eq literal 'string)) + ((or (not c-comment-continuation-stars) + (not literal)) + (indent-new-comment-line soft)) + (t (let ((here (point)) + (leader c-comment-continuation-stars)) + (back-to-indentation) + ;; are we looking at a block or lines style comment? + (if (and (looking-at (concat "\\(" c-comment-start-regexp + "\\)[ \t]+")) + (string-equal (match-string 1) "//")) + ;; line style + (setq leader "// ")) + (goto-char here) + (delete-region (progn (skip-chars-backward " \t") (point)) + (progn (skip-chars-forward " \t") (point))) + (newline) + ;; to avoid having an anchored comment that c-indent-line will + ;; trip up on + (insert " " leader) + (c-indent-line)))))) ;; advice for indent-new-comment-line for older Emacsen (if (boundp 'comment-line-break-function)