]> code.delx.au - gnu-emacs-elpa/commitdiff
align: Support vfuncs
authorDaiki Ueno <ueno@gnu.org>
Sun, 17 Jan 2016 00:35:58 +0000 (09:35 +0900)
committerDaiki Ueno <ueno@gnu.org>
Sun, 17 Jan 2016 00:35:58 +0000 (09:35 +0900)
gobject-align.el
gobject-tests.el

index 3042fedf2c88da34b6936c0a9755aa0054704eba..8db4f9dadeb0d45642e5bec8c8ce4ee420ed094e 100644 (file)
       (let (arglist-start
            arglist-end
            identifier-start
-           identifier-end)
+           identifier-end
+           vfunc-p)
        (goto-char (point-min))
        (c-forward-syntactic-ws)
        (unless (looking-at
-                "typedef\\|#\\|G_DECLARE_\\(?:\\(?:FINAL\\|DECLARATIVE\\)_TYPE\\|INTERFACE\\)")
+                "typedef\\|#\\|G_\\(?:DECLARE\\|DEFINE\\)")
          (while (and (not (eobp))
                      (not (eq (char-after) ?\()))
            (c-forward-token-2)
            (c-forward-syntactic-ws))
+         ;; Identifier is vfunc.
+         (when (looking-at "(\\s-*\\*")
+           (c-forward-sexp)
+           (c-forward-syntactic-ws)
+           (setq vfunc-p t))
          (when (eq (char-after) ?\()
            (setq arglist-start (point-marker))
            (c-backward-syntactic-ws)
            (setq identifier-end (point-marker))
-           (c-backward-token-2)
+           (if vfunc-p
+               (c-backward-sexp)
+             (c-backward-token-2))
            (setq identifier-start (point-marker))
            (goto-char arglist-start)
            (c-forward-sexp)
index c06c0a5efaff0bb3243048d65f528c4db0840782..e0ec75027d1d99205673c5ff9c5f4392b22115f7 100644 (file)
@@ -45,6 +45,18 @@ GDK_AVAILABLE_IN_3_16
 const gchar **          gtk_widget_list_action_prefixes (GtkWidget             *widget);
 ")
 
+(defconst gobject-test-program-3 "\
+  /* overridable methods */
+  void       (*set_property)            (GObject        *object,
+                                         guint           property_id,
+                                         const GValue   *value,
+                                         GParamSpec     *pspec);
+  void       (*get_property)            (GObject        *object,
+                                         guint           property_id,
+                                         GValue         *value,
+                                         GParamSpec     *pspec);
+")
+
 (ert-deftest gobject-test-align--compute-optimal-columns ()
   "Tests the `gobject-align--compute-optimal-columns'."
   (with-temp-buffer
@@ -64,7 +76,7 @@ const gchar **          gtk_widget_list_action_prefixes (GtkWidget             *
     (gobject-align-region (point-min) (point-max))
     (should (equal (buffer-string) gobject-test-program-1-aligned))))
 
-(ert-deftest gobject-test-align-guess-columns ()
+(ert-deftest gobject-test-align-guess-columns-1 ()
   "Tests the `gobject-align-guess-columns'."
   (with-temp-buffer
     (insert gobject-test-program-2)
@@ -73,3 +85,13 @@ const gchar **          gtk_widget_list_action_prefixes (GtkWidget             *
     (should (= gobject-align-identifier-start-column 24))
     (should (= gobject-align-arglist-start-column 56))
     (should (= gobject-align-arglist-identifier-start-column 80))))
+
+(ert-deftest gobject-test-align-guess-columns-2 ()
+  "Tests the `gobject-align-guess-columns'."
+  (with-temp-buffer
+    (insert gobject-test-program-3)
+    (c-mode)
+    (gobject-align-guess-columns (point-min) (point-max))
+    (should (= gobject-align-identifier-start-column 13))
+    (should (= gobject-align-arglist-start-column 40))
+    (should (= gobject-align-arglist-identifier-start-column 57))))