From: Richard M. Stallman Date: Mon, 8 Sep 1997 03:20:02 +0000 (+0000) Subject: (c-beginning-of-statement): Fixes in sentence movement to properly X-Git-Tag: emacs-20.1~144 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd3b1ef6558975a67e1a29fb7caa9753cdf03022;p=emacs.git (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. --- diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 2f4780306f0..5f667e54e2f 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -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 @@ comment." (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." 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)