(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)
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
(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)
(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))))