emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master b4d4672 14/40: align: Support vfuncs


From: Daiki Ueno
Subject: [elpa] master b4d4672 14/40: align: Support vfuncs
Date: Fri, 22 Jan 2016 22:48:39 +0000

branch: master
commit b4d4672477cf591293a723ec544cb940cbc34c05
Author: Daiki Ueno <address@hidden>
Commit: Daiki Ueno <address@hidden>

    align: Support vfuncs
---
 gobject-align.el |   14 +++++++++++---
 gobject-tests.el |   24 +++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/gobject-align.el b/gobject-align.el
index 3042fed..8db4f9d 100644
--- a/gobject-align.el
+++ b/gobject-align.el
@@ -269,20 +269,28 @@
       (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)
diff --git a/gobject-tests.el b/gobject-tests.el
index c06c0a5..e0ec750 100644
--- a/gobject-tests.el
+++ b/gobject-tests.el
@@ -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))))



reply via email to

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