Regression in `vm-find-and-set-text-of`, incorrect Message-Id parsing and thread display
I noticed that message threads were not correctly identified anymore (compared to 8.2.0b1) and ultimately debugged it to wrong Message-Id parsing.
vm-su-message-id uses vm-get-header-contents which essentially does this:
(goto-char (vm-headers-of message)) ... (while (re-search-forward regexp (vm-text-of message) t) ...)
This calls vm-text-of which in turns calls vm-find-and-set-text-of the first time a message is seen.
The problem is that in commit 8f44ff52 the function vm-text-of was modified like so:
--- lisp/vm-message.el
+++ lisp/vm-message.el
@@ -724,8 +726,7 @@
mvec ))
(defun vm-find-and-set-text-of (m)
- (save-excursion
- (set-buffer (vm-buffer-of m))
+ (with-current-buffer (vm-buffer-of m)
(save-restriction
(widen)
(goto-char (vm-headers-of m))
This does not save the current point anymore, and the re-search-forward in vm-get-header-contents gets confused.
It happens that this is called the first time for a new message for searching for the 'Message-Id:' header, which is not found. (vm then silently computes a fake one, which makes the issue quite invisible).
Reverting the above patch of commit 8f44ff52 fixes this for me.
While here, I noticed that there are a number of similar changes, replacing save-excursion + set-buffer by a sole with-current-buffer, which may introduce subtle issues.