bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pike mode and compound return types (patch)


From: Paul Pogonyshev
Subject: Pike mode and compound return types (patch)
Date: Sat, 30 Aug 2003 05:37:59 +0000
User-agent: KMail/1.5.9

Consider the following Pike program (indented with current Emacs):

array(string)
  drop_first_element(array(string) elements)
{
  return elements[1..];
}

int
main(int argc, array(string) argv)
{
  write(drop_first_element(argv) * "\n" + "\n");
}

Note that the name of the first function (`drop_first_element') is
indented incorrectly.  This problem can be seen with any function
that has a return type which includes parens.

The patch below fixes it.  It seems like not breaking anything, but
shold certainly be checked by someone more skilled in elisp than me.
Since function `c-on-identifier' returns `int', the return type of
`c-just-after-func-arglist-p' changed from `t/nil' to `non-nil/nil'.
I don't know if it is considered bad for some reason.



2003-08-30  Paul Pogonyshev  <address@hidden>

        * progmodes/cc-engine.el (c-just-after-func-arglist-p): Fix bug in
        indenting names of functions with compound return
        types (e.g. `array(string)') in Pike.  As a side effect, this
        function now returns non-nil, not t.



--- cc-engine.el.~1.34.~        2003-08-27 02:00:50.000000000 +0000
+++ cc-engine.el        2003-08-30 05:15:48.000000000 +0000
@@ -4251,11 +4251,11 @@ brace."
        (c-search-uplist-for-classkey paren-state))))
 
 (defun c-just-after-func-arglist-p (&optional lim)
-  ;; Return t if we are between a function's argument list closing
-  ;; paren and its opening brace.  Note that the list close brace
-  ;; could be followed by a "const" specifier or a member init hanging
-  ;; colon.  LIM is used as bound for some backward buffer searches;
-  ;; the search might continue past it.
+  ;; Return non-nil if we are between a function's argument list
+  ;; closing paren and its opening brace.  Note that the list close
+  ;; brace could be followed by a "const" specifier or a member init
+  ;; hanging colon.  LIM is used as bound for some backward buffer
+  ;; searches; the search might continue past it.
   ;;
   ;; Note: This test is easily fooled.  It only works reasonably well
   ;; in the situations where `c-guess-basic-syntax' uses it.
@@ -4311,7 +4311,18 @@ brace."
                          (progn
                            (c-forward-sexp -2)
                            (looking-at c-class-key))
-                         )))))
+                         ))))
+          ;; Pike has compound types that include parens,
+          ;; e.g. `array(string)', but doesn't allow omitting
+          ;; function type.  Note that `c-on-identifier' is enough in
+          ;; this function, because it is run only in certain
+          ;; positions.
+          (or (not (c-major-mode-is 'pike-mode))
+              (progn
+                (c-forward-sexp -1)
+                (forward-char -1)
+                (c-backward-syntactic-ws lim)
+                (c-on-identifier))))
       )))
 
 (defun c-in-knr-argdecl (&optional lim)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]