]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-cmds.el
(grep-regexp-alist): Replace complex regexp
[gnu-emacs] / lisp / progmodes / cc-cmds.el
index d0056183d515e4c0377cab09256b0104b12a3059..039ef3ccebfe666bf5886702bedd8528cf631c73 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-cmds.el --- user level commands for CC Mode
 
-;; Copyright (C) 1985,1987,1992-2003 Free Software Foundation, Inc.
+;; Copyright (C) 1985,1987,1992-2003, 2004, 2005 Free Software Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
@@ -25,8 +25,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 \f
 (defvar c-fix-backslashes t)
 
-(defun c-shift-line-indentation (shift-amt)
-  ;; This function does not do any hidden buffer changes.
-  (let ((pos (- (point-max) (point)))
-       (c-macro-start c-macro-start)
-       tmp-char-inserted)
-    (if (zerop shift-amt)
-       nil
-      (when (and (c-query-and-set-macro-start)
-                (looking-at "[ \t]*\\\\$")
-                (save-excursion
-                  (skip-chars-backward " \t")
-                  (bolp)))
-       (insert ?x)
-       (backward-char)
-       (setq tmp-char-inserted t))
-      (unwind-protect
-         (let ((col (current-indentation)))
-           (delete-region (c-point 'bol) (c-point 'boi))
-           (beginning-of-line)
-           (indent-to (+ col shift-amt)))
-       (when tmp-char-inserted
-         (delete-char 1))))
-    ;; If initial point was within line's indentation and we're not on
-    ;; a line with a line continuation in a macro, position after the
-    ;; indentation.  Else stay at same point in text.
-    (if (and (< (point) (c-point 'boi))
-            (not tmp-char-inserted))
-       (back-to-indentation)
-      (if (> (- (point-max) pos) (point))
-         (goto-char (- (point-max) pos))))))
-
 (defun c-indent-line (&optional syntax quiet ignore-point-pos)
   "Indent the current line according to the syntactic context,
 if `c-syntactic-indentation' is non-nil.  Optional SYNTAX is the
@@ -510,7 +479,11 @@ This function does various newline cleanups based on the value of
          ;; end up before it.
          (setq delete-temp-newline
                (cons (save-excursion
-                       (c-backward-syntactic-ws)
+                       (end-of-line 0)
+                       (if (eq (char-before) ?\\)
+                           ;; Ignore a line continuation.
+                           (backward-char))
+                       (skip-chars-backward " \t")
                        (copy-marker (point) t))
                      (point-marker))))
        (unwind-protect
@@ -1519,7 +1492,7 @@ more \"DWIM:ey\"."
                                     (save-excursion
                                       (beginning-of-line)
                                       (or (not (re-search-backward
-                                                sentence-end
+                                                (sentence-end)
                                                 (c-point 'bopl)
                                                 t))
                                           (< (match-end 0)
@@ -2002,8 +1975,7 @@ If `c-tab-always-indent' is t, always just indent the current line.
 If nil, indent the current line only if point is at the left margin or
 in the line's indentation; otherwise insert some whitespace[*].  If
 other than nil or t, then some whitespace[*] is inserted only within
-literals (comments and strings) and inside preprocessor directives,
-but the line is always reindented.
+literals (comments and strings), but the line is always reindented.
 
 If `c-syntactic-indentation' is t, indentation is done according to
 the syntactic context.  A numeric argument, regardless of its value,
@@ -2469,7 +2441,8 @@ command to conveniently insert and align the necessary backslashes."
                      (delete-region (point) end)
                      (indent-to column 1)))
 
-              (= (forward-line 1) 0))))
+              (zerop (forward-line 1)))
+            (bolp)))                   ; forward-line has funny behavior at eob.
 
       ;; Make sure there are backslashes with at least one space in
       ;; front of them.
@@ -2494,7 +2467,8 @@ command to conveniently insert and align the necessary backslashes."
                   (insert ?\\)
                 (insert ?\  ?\\)))
 
-            (= (forward-line 1) 0)))))))
+            (zerop (forward-line 1)))
+          (bolp))))))                  ; forward-line has funny behavior at eob.
 
 (defun c-delete-backslashes-forward (to-mark point-pos)
   ;; This function does not do any hidden buffer changes.
@@ -2509,7 +2483,8 @@ command to conveniently insert and align the necessary backslashes."
                         (skip-chars-backward " \t" (if (>= (point) point-pos)
                                                        point-pos))
                         (point))))
-            (= (forward-line 1) 0)))))
+            (zerop (forward-line 1)))
+          (bolp))))                    ; forward-line has funny behavior at eob.
 
 
 \f