[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ec40108 23/40: align: Use `max' as much as possible
From: |
Daiki Ueno |
Subject: |
[elpa] master ec40108 23/40: align: Use `max' as much as possible |
Date: |
Fri, 22 Jan 2016 22:48:43 +0000 |
branch: master
commit ec40108e73eb9964b0a227ae030b501dfe8d09c9
Author: Daiki Ueno <address@hidden>
Commit: Daiki Ueno <address@hidden>
align: Use `max' as much as possible
---
gnome-align.el | 87 +++++++++++++++++++++++++-------------------------------
1 files changed, 39 insertions(+), 48 deletions(-)
diff --git a/gnome-align.el b/gnome-align.el
index 0b708d2..644c0eb 100644
--- a/gnome-align.el
+++ b/gnome-align.el
@@ -106,13 +106,7 @@
0))
(defun gnome-align--arglist-identifier-width (arglist)
- (let ((width 0)
- argument-width)
- (dolist (argument arglist)
- (setq argument-width (gnome-align--argument-identifier-width argument))
- (when (> argument-width width)
- (setq width argument-width)))
- width))
+ (apply #'max (mapcar #'gnome-align--argument-identifier-width arglist)))
(defun gnome-align--normalize-arglist-region (beg end)
(save-excursion
@@ -233,17 +227,19 @@
(arglist nil :read-only t))
(defun gnome-align--decls-identifier-start-column (decls start-column)
- (let ((column start-column)
- decl-column)
- (dolist (decl decls)
- (setq decl-column (+ start-column
- (gnome-align--marker-column
- (gnome-align--decl-identifier-start decl))))
- (when (and (or (null gnome-align-max-column)
- (<= decl-column gnome-align-max-column))
- (> decl-column column))
- (setq column decl-column)))
- column))
+ (apply #'max
+ (delq nil
+ (mapcar
+ (lambda (decl)
+ (let ((decl-column
+ (+ start-column
+ (gnome-align--marker-column
+ (gnome-align--decl-identifier-start decl)))))
+ (if (and gnome-align-max-column
+ (> decl-column gnome-align-max-column))
+ nil
+ decl-column)))
+ decls))))
(defun gnome-align--decl-identifier-width (decl)
(- (gnome-align--marker-column
@@ -252,43 +248,38 @@
(gnome-align--decl-identifier-start decl))))
(defun gnome-align--decls-arglist-start-column (decls start-column)
- (let ((column start-column)
- decl-column
- (arglist-width
+ (let ((arglist-width
(+ (gnome-align--decls-arglist-identifier-start-column decls 0)
(gnome-align--decls-arglist-identifier-width decls)
(length ");"))))
- (dolist (decl decls)
- (setq decl-column (+ start-column
- (gnome-align--decl-identifier-width decl)))
- (when (and (or (null gnome-align-max-column)
- (<= (+ decl-column arglist-width)
- gnome-align-max-column))
- (> decl-column column))
- (setq column decl-column)))
- (1+ column)))
+ (apply #'max
+ (delq nil
+ (mapcar
+ (lambda (decl)
+ (let ((decl-column
+ (+ start-column
+ (gnome-align--decl-identifier-width decl)
+ 1)))
+ (if (and gnome-align-max-column
+ (> (+ decl-column arglist-width)
+ gnome-align-max-column))
+ nil
+ decl-column)))
+ decls)))))
(defun gnome-align--decls-arglist-identifier-width (decls)
- (let ((width 0)
- decl-width)
- (dolist (decl decls)
- (setq decl-width (gnome-align--arglist-identifier-width
- (gnome-align--decl-arglist decl)))
- (when (> decl-width width)
- (setq width decl-width)))
- width))
+ (apply #'max (mapcar (lambda (decl)
+ (gnome-align--arglist-identifier-width
+ (gnome-align--decl-arglist decl)))
+ decls)))
(defun gnome-align--decls-arglist-identifier-start-column (decls start-column)
- (let ((column start-column)
- decl-column)
- (dolist (decl decls)
- (setq decl-column (gnome-align--arglist-identifier-start-column
- (gnome-align--decl-arglist decl)
- start-column))
- ;; FIXME: should wrap lines inside argument list?
- (when (> decl-column column)
- (setq column decl-column)))
- column))
+ (apply #'max (mapcar (lambda (decl)
+ ;; FIXME: should wrap lines inside argument list?
+ (gnome-align--arglist-identifier-start-column
+ (gnome-align--decl-arglist decl)
+ start-column))
+ decls)))
(defun gnome-align--parse-decl (beg end)
;; Parse at most one func declaration found in BEG END.
- [elpa] master 870e78c 12/40: Add ERT tests, (continued)
- [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, 2016/01/22
- [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 <=
- [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
- [elpa] master e84487c 35/40: snippet: Add FIXME comment, Daiki Ueno, 2016/01/22
- [elpa] master b04d18e 33/40: Change copyright holder to FSF, Daiki Ueno, 2016/01/22