]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-align.el
Updated to IDLWAVE v5.7 (see idlwave.org), and variable cleanup
[gnu-emacs] / lisp / progmodes / cc-align.el
index 2f1625854a130aadd889fea92e44b5939248ad33..849e98053ad6261df8d12d8fac6a0cead7d64185 100644 (file)
@@ -24,9 +24,9 @@
 ;; GNU General Public License for more details.
 
 ;; 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.
+;; along with this program; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -121,7 +121,7 @@ Works with: arglist-cont-nonempty, arglist-close."
     ;; like "({".
     (when c-special-brace-lists
       (let ((special-list (c-looking-at-special-brace-list)))
-       (when special-list
+       (when (and special-list (< (car (car special-list)) (point)))
          (goto-char (+ (car (car special-list)) 2)))))
 
     (let ((savepos (point))
@@ -158,7 +158,7 @@ foo (xyz, aaa + bbb + ccc
 Only continuation lines like this are touched, nil is returned on lines
 which are the start of an argument.
 
-Within a gcc asm block, \":\" is recognised as an argument separator,
+Within a gcc asm block, \":\" is recognized as an argument separator,
 but of course only between operand specifications, not in the expressions
 for the operands.
 
@@ -175,7 +175,8 @@ Works with: arglist-cont, arglist-cont-nonempty."
       (let ((open-paren (elt c-syntactic-element 2))
            (paren-state (c-parse-state)))
        (while (not (eq (car paren-state) open-paren))
-         (goto-char (car paren-state))
+         (unless (consp (car paren-state)) ;; ignore matched braces
+           (goto-char (car paren-state)))
          (setq paren-state (cdr paren-state)))))
 
     (let ((start (point)) c)
@@ -380,9 +381,7 @@ Works with: inher-cont, member-init-cont."
     (back-to-indentation)
     (let* ((eol (c-point 'eol))
           (here (point))
-          (char-after-ip (progn
-                           (skip-chars-forward " \t")
-                           (char-after))))
+          (char-after-ip (char-after)))
       (if (cdr langelem) (goto-char (cdr langelem)))
 
       ;; This kludge is necessary to support both inher-cont and
@@ -392,13 +391,12 @@ Works with: inher-cont, member-init-cont."
        (backward-char)
        (c-backward-syntactic-ws))
 
-      (skip-chars-forward "^:" eol)
-      (if (eq char-after-ip ?,)
-         (skip-chars-forward " \t" eol)
-       (skip-chars-forward " \t:" eol))
-      (if (or (eolp)
-             (looking-at c-comment-start-regexp))
-         (c-forward-syntactic-ws here))
+      (c-syntactic-re-search-forward ":" eol 'move)
+      (if (looking-at c-syntactic-eol)
+         (c-forward-syntactic-ws here)
+       (if (eq char-after-ip ?,)
+           (backward-char)
+         (skip-chars-forward " \t" eol)))
       (if (< (point) here)
          (vector (current-column)))
       )))
@@ -708,18 +706,20 @@ arglist-cont-nonempty."
       (save-excursion
        (beginning-of-line)
        (when (c-syntactic-re-search-forward
-              ;; This regexp avoids matches on ==.
-              "\\(\\=\\|[^=]\\)=\\([^=]\\|$\\)"
-              (c-point 'eol) t t)
-         (setq equalp (- (match-beginning 2) (c-point 'boi))))))
+              c-assignment-op-regexp
+              (c-point 'eol) t t t)
+         (setq equalp (- (or (match-beginning 1)
+                             (match-end 0))
+                         (c-point 'boi))))))
 
     (save-excursion
       (goto-char startpos)
       (if (or (if (c-syntactic-re-search-forward
-                  "\\(\\=\\|[^=]\\)=\\([^=]\\|$\\)"
-                  (min endpos (c-point 'eol)) t t)
+                  c-assignment-op-regexp
+                  (min endpos (c-point 'eol)) t t t)
                  (progn
-                   (goto-char (match-beginning 2))
+                   (goto-char (or (match-beginning 1)
+                                  (match-end 0)))
                    nil)
                t)
              (save-excursion
@@ -950,11 +950,17 @@ Works with: defun-close, defun-block-intro, block-close,
 brace-list-close, brace-list-intro, statement-block-intro and all in*
 symbols, e.g. inclass and inextern-lang."
   (save-excursion
-    (goto-char (cdr langelem))
-    (back-to-indentation)
-    (if (eq (char-syntax (char-after)) ?\()
-       0
-      c-basic-offset)))
+    (+ (progn
+        (back-to-indentation)
+        (if (eq (char-syntax (char-after)) ?\()
+            c-basic-offset
+          0))
+       (progn
+        (goto-char (cdr langelem))
+        (back-to-indentation)
+        (if (eq (char-syntax (char-after)) ?\()
+            0
+          c-basic-offset)))))
 
 (defun c-lineup-cpp-define (langelem)
   "Line up macro continuation lines according to the indentation of
@@ -1119,35 +1125,20 @@ ACTION associated with `block-close' syntax."
        '(before after)))))
 
 (defun c-gnu-impose-minimum ()
-  "Imposes a minimum indentation for lines inside a top-level construct.
+  "Imposes a minimum indentation for lines inside code blocks.
 The variable `c-label-minimum-indentation' specifies the minimum
 indentation amount."
 
-  ;; Don't adjust macro or comment-only lines.
-  (unless (or (assq 'cpp-macro c-syntactic-context)
-             (assq 'comment-intro c-syntactic-context))
-
-    (let ((paren-state (save-excursion
-                        ;; Get the parenthesis state, but skip past
-                        ;; an initial closing paren on the line since
-                        ;; the close brace of a block shouldn't be
-                        ;; considered to be inside the block.
-                        (back-to-indentation)
-                        (when (looking-at "\\s\)")
-                          (forward-char))
-                        (c-parse-state))))
-
-      ;; Search for an enclosing brace on paren-state.
-      (while (and paren-state
-                 (not (and (integer-or-marker-p (car paren-state))
-                           (eq (char-after (car paren-state)) ?{))))
-       (setq paren-state (cdr paren-state)))
-
-      (when paren-state
-       (save-excursion
-         (back-to-indentation)
-         (if (zerop (current-column))
-             (insert-char ?\  c-label-minimum-indentation t)))))))
+  (when (and (not
+             ;; Don't adjust macro or comment-only lines.
+             (or (assq 'cpp-macro c-syntactic-context)
+                 (assq 'comment-intro c-syntactic-context)))
+            (c-intersect-lists c-inside-block-syms c-syntactic-context)
+            (save-excursion
+              (back-to-indentation)
+              (< (current-column) c-label-minimum-indentation)))
+    (c-shift-line-indentation (- c-label-minimum-indentation
+                                (current-indentation)))))
 
 \f
 ;; Useful for c-hanging-semi&comma-criteria
@@ -1181,6 +1172,7 @@ Otherwise, no determination is made."
             ;;(/= (point-max)
             ;;    (save-excursion (skip-syntax-forward " ") (point))
             (zerop (forward-line 1))
+            (bolp)                     ; forward-line has funny behavior at eob.
             (not (looking-at "^[ \t]*$")))
        'stop
       nil)))
@@ -1206,4 +1198,5 @@ For other semicolon contexts, no determination is made."
 \f
 (cc-provide 'cc-align)
 
+;;; arch-tag: 4d71ed28-bf51-4509-a148-f39669669a2e
 ;;; cc-align.el ends here