aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinglu Chen <public@yoctocell.xyz>2021-04-24 13:31:39 +0200
committerXinglu Chen <public@yoctocell.xyz>2021-04-24 13:33:36 +0200
commit5db8cae2910c5fca47bdbebce8337218cb94109c (patch)
tree0201615a1b60054d8d121e5ba802351807ec364a
parent5366f2fa8e73fcf5bc11d6c176cd4a27ab2f56ad (diff)
git-email: Fix sorting function for message buffers.
‘string-greaterp’ would mess up the order if the buffer names container more-than-one digit numbers. ‘git-email-message-buffer-greaterp’ just compares the numbers in the buffer names. * git-email.el (git-email-message-buffer-greaterp): New function. (git-email-send-all): Use it.
-rw-r--r--git-email.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/git-email.el b/git-email.el
index f83f8a4..4dbb805 100644
--- a/git-email.el
+++ b/git-email.el
@@ -38,6 +38,7 @@
(require 'project)
(require 'message)
+(require 'cl-lib)
;;;; Customization options
(defgroup git-email nil
@@ -413,12 +414,23 @@ default behavior is to delete them after sending the message."
;;;; Operate on emails
+(defun git-email-message-buffer-greaterp (old new)
+ "Compare the number in the buffer name of OLD with NEW"
+ (cl-flet ((regexp (name)
+ (string-to-number
+ (replace-regexp-in-string ".*<\\([0-9]+\\)>"
+ "\\1"
+ name))))
+ (let ((old (regexp old))
+ (new (regexp new)))
+ (< old new))))
+
(defun git-email-send-all ()
"Send all unsent emails."
(interactive)
;; Sort the buffers so that [PATCH 0/N] comes first, this prevents
;; the ordering from getting messed up.
- (let ((buffers (sort (message-buffers) #'string-greaterp)))
+ (let ((buffers (sort (message-buffers) #'git-email-message-buffer-greaterp)))
(mapc (lambda (b) (switch-to-buffer b)
(funcall git-email-send-email-function))
buffers)))