# HG changeset patch # User Richard M. Stallman # Date 712021729 0 # Node ID 34b6b37092c72e4e0977ad2a01e509907d42885c # Parent 1b3af6ad85be88f99fa3e5f8f28c179d2c01b1f2 *** empty log message *** diff -r 1b3af6ad85be -r 34b6b37092c7 lisp/progmodes/c-mode.el --- a/lisp/progmodes/c-mode.el Fri Jul 24 22:37:33 1992 +0000 +++ b/lisp/progmodes/c-mode.el Fri Jul 24 23:48:49 1992 +0000 @@ -764,19 +764,27 @@ (defun c-beginning-of-statement (count) "Go to the beginning of the innermost C statement. With prefix arg, go back N - 1 statements. If already at the beginning of a -statement then go to the beginning of the preceeding one." +statement then go to the beginning of the preceeding one. +If within a string or comment, move by sentences instead of statements." (interactive "p") - (while (> count 0) - (c-beginning-of-statement-1) - (setq count (1- count))) - (while (< count 0) - (c-end-of-statement-1) - (setq count (1+ count)))) + (let ((here (point)) state) + (save-excursion + (beginning-of-defun) + (setq state (parse-partial-sexp (point) here nil nil))) + (if (or (nth 3 state) (nth 4 state)) + (forward-sentence (- count)) + (while (> count 0) + (c-beginning-of-statement-1) + (setq count (1- count))) + (while (< count 0) + (c-end-of-statement-1) + (setq count (1+ count)))))) (defun c-end-of-statement (count) "Go to the end of the innermost C statement. -With prefix arg, go forward N - 1 statements. Moves forward to end of the -next statement if already at end." +With prefix arg, go forward N - 1 statements. +Move forward to end of the next statement if already at end. +If within a string or comment, move by sentences instead of statements." (interactive "p") (c-beginning-of-statement (- count)))