[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d608680 20/40: align: Add a room before '*' for arguments
From: |
Daiki Ueno |
Subject: |
[elpa] master d608680 20/40: align: Add a room before '*' for arguments |
Date: |
Fri, 22 Jan 2016 22:48:42 +0000 |
branch: master
commit d608680946934ec4a9f1fe73c2b86f84639f802c
Author: Daiki Ueno <address@hidden>
Commit: Daiki Ueno <address@hidden>
align: Add a room before '*' for arguments
---
gnome-align.el | 33 ++++++++++++++++++++++++---------
gnome-tests.el | 24 ++++++++++++------------
2 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/gnome-align.el b/gnome-align.el
index 7ac94aa..6e68dc8 100644
--- a/gnome-align.el
+++ b/gnome-align.el
@@ -48,15 +48,17 @@
(cl-defstruct (gnome-align--argument
(:constructor nil)
(:constructor gnome-align--make-argument (type-start
- type-end
- identifier-start
- identifier-end))
+ type-end
+ identifier-start
+ identifier-end
+ stars))
(:copier nil)
(:predicate nil))
(type-start nil :read-only t)
(type-end nil :read-only t)
(identifier-start nil :read-only t)
- (identifier-end nil :read-only t))
+ (identifier-end nil :read-only t)
+ (stars 0 :read-only t))
(defun gnome-align--marker-column (marker)
(save-excursion
@@ -78,7 +80,9 @@
(defun gnome-align--arglist-identifier-start-column (arglist start-column)
(let ((column start-column)
- argument-column)
+ argument-column
+ (stars 0)
+ argument-stars)
(dolist (argument arglist)
(setq argument-column (+ start-column
(gnome-align--argument-type-width argument)))
@@ -88,8 +92,11 @@
(when (eq (preceding-char) ? )
(setq argument-column (1+ argument-column)))))
(when (> argument-column column)
- (setq column argument-column)))
- column))
+ (setq column argument-column))
+ (setq argument-stars (gnome-align--argument-stars argument))
+ (when (> argument-stars stars)
+ (setq stars argument-stars)))
+ (+ column stars)))
(defun gnome-align--argument-identifier-width (argument)
(if (gnome-align--argument-identifier-start argument)
@@ -136,6 +143,7 @@
type-end
identifier-start
identifier-end
+ (stars 0)
arglist
last-token-start)
(goto-char (point-max))
@@ -162,9 +170,16 @@
(unless (eq (char-after) ?,)
(setq last-token-start (point-marker)))))
(c-backward-syntactic-ws))
- (setq type-start last-token-start))
+ (setq type-start last-token-start)
+ (save-excursion
+ (goto-char type-end)
+ (while (and (< type-start (point))
+ (eq (preceding-char) ?*))
+ (setq stars (1+ stars))
+ (c-backward-token-2))))
(push (gnome-align--make-argument type-start type-end
- identifier-start identifier-end)
+ identifier-start identifier-end
+ stars)
arglist))
arglist))))
diff --git a/gnome-tests.el b/gnome-tests.el
index d4e3113..47fccc4 100644
--- a/gnome-tests.el
+++ b/gnome-tests.el
@@ -20,7 +20,7 @@ void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
")
(defconst gnome-test-program-1-aligned "\
-GGpgCtx *g_gpg_ctx_new (GError **error);
+GGpgCtx *g_gpg_ctx_new (GError **error);
typedef void (*GGpgProgressCallback) (gpointer user_data,
const gchar *what,
@@ -28,16 +28,16 @@ typedef void (*GGpgProgressCallback) (gpointer user_data,
gint current,
gint total);
-void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
- GGpgProgressCallback callback,
- gpointer user_data,
- GDestroyNotify destroy_data);
-void g_gpg_ctx_add_signer (GGpgCtx *ctx,
- GGpgKey *key);
-guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
-GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
- guint index);
-void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
+void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
+ GGpgProgressCallback callback,
+ gpointer user_data,
+ GDestroyNotify destroy_data);
+void g_gpg_ctx_add_signer (GGpgCtx *ctx,
+ GGpgKey *key);
+guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
+GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
+ guint index);
+void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
")
(defconst gnome-test-program-2 "\
@@ -65,7 +65,7 @@ const gchar ** gtk_widget_list_action_prefixes
(GtkWidget *
(let ((columns (gnome-align--compute-optimal-columns (point-min)
(point-max))))
(should (= (cdr (assq 'identifier-start-column columns)) 9))
(should (= (cdr (assq 'arglist-start-column columns)) 41))
- (should (= (cdr (assq 'arglist-identifier-start-column columns)) 63)))))
+ (should (= (cdr (assq 'arglist-identifier-start-column columns)) 64)))))
(ert-deftest gnome-test-align-region ()
"Tests the `gnome-align-region'."
- [elpa] master dcb6a2e 03/40: align: Support guessing/setting alignment rules, (continued)
- [elpa] master dcb6a2e 03/40: align: Support guessing/setting alignment rules, Daiki Ueno, 2016/01/22
- [elpa] master 2f5707d 11/40: align: Fix previous commit, Daiki Ueno, 2016/01/22
- [elpa] master 870e78c 12/40: Add ERT tests, Daiki Ueno, 2016/01/22
- [elpa] master 7285abe 15/40: Reorder commands in README.md, Daiki Ueno, 2016/01/22
- [elpa] master 1ad58dc 01/40: Initial import, Daiki Ueno, 2016/01/22
- [elpa] master b4d4672 14/40: align: Support vfuncs, Daiki Ueno, 2016/01/22
- [elpa] master ae40679 18/40: Add symlink to README, Daiki Ueno, 2016/01/22
- [elpa] master 1e67806 19/40: snippet: Make options customizable, Daiki Ueno, 2016/01/22
- [elpa] master e8714b1 13/40: align: -guess-columns -> -compute-optimal-columns, Daiki Ueno, 2016/01/22
- [elpa] master abb9dd4 21/40: Revert "align: Add a room before '*' for arguments", Daiki Ueno, 2016/01/22
- [elpa] master d608680 20/40: align: Add a room before '*' for arguments,
Daiki Ueno <=
- [elpa] master 147931d 27/40: Fix typo, Daiki Ueno, 2016/01/22
- [elpa] master ec40108 23/40: align: Use `max' as much as possible, Daiki Ueno, 2016/01/22
- [elpa] master d6d27bd 22/40: align: Reimplement d6086809, Daiki Ueno, 2016/01/22
- [elpa] master ccb6062 24/40: tests: Bind `gnome-align-max-column', Daiki Ueno, 2016/01/22
- [elpa] master f339477 28/40: Add references to developer.gnome.org, Daiki Ueno, 2016/01/22
- [elpa] master 78a0cce 31/40: align: Fix `max' usage, Daiki Ueno, 2016/01/22
- [elpa] master 03f8dca 32/40: tests: Add line wrapping tests, Daiki Ueno, 2016/01/22
- [elpa] master a65924c 26/40: align: Remove spaces between two '*', Daiki Ueno, 2016/01/22
- [elpa] master 39e7fb6 29/40: Rename some commands, Daiki Ueno, 2016/01/22
- [elpa] master 570b52f 30/40: snippet: Fix indentation, Daiki Ueno, 2016/01/22