mu4e: special-case empty hostnames

Fixes #1108
This commit is contained in:
djcb
2017-08-27 15:44:23 +03:00
parent ceb7f0a8b4
commit e09419f85b

View File

@ -302,15 +302,16 @@ separator is never written to the message file. Also see
;; search for the first empty line ;; search for the first empty line
(goto-char (point-min)) (goto-char (point-min))
(if (search-forward-regexp "^$" nil t) (if (search-forward-regexp "^$" nil t)
(progn (progn
(replace-match sepa) (replace-match sepa)
;; `message-narrow-to-headers` searches for a `mail-header-separator` followed by a new ;; `message-narrow-to-headers` searches for a
;; line. Therefore, we must insert a newline if on the last line of the buffer. ;; `mail-header-separator` followed by a new line. Therefore, we
(when (= (point) (point-max)) ;; must insert a newline if on the last line of the buffer.
(insert "\n"))) (when (= (point) (point-max))
(progn ;; no empty line? then prepend one (insert "\n")))
(goto-char (point-max)) (progn ;; no empty line? then prepend one
(insert "\n" sepa)))))) (goto-char (point-max))
(insert "\n" sepa))))))
(defun mu4e~draft-remove-mail-header-separator () (defun mu4e~draft-remove-mail-header-separator ()
"Remove `mail-header-separator; we do this before saving a "Remove `mail-header-separator; we do this before saving a
@ -345,9 +346,10 @@ It looks something like
<time>-<random>.<hostname>:2, <time>-<random>.<hostname>:2,
You can append flags." You can append flags."
(let* ((sysname (if (fboundp 'system-name) (let* ((sysname (if (fboundp 'system-name)
(system-name) (system-name)
(with-no-warnings system-name))) (with-no-warnings system-name)))
(hostname (downcase (sysname (if (string= sysname "") "localhost" sysname))
(hostname (downcase
(save-match-data (save-match-data
(substring sysname (substring sysname
(string-match "^[^.]+" sysname) (string-match "^[^.]+" sysname)