还差 IMAP IDLE,mu4e 就算完美了

加了个可以通过 SPC f o 来通过 OS X Mail.app 来打开 rich-text 邮件的功能:

(defun open-message-with-mail-app ()
  (interactive)
  (let* ((msg-path (plist-get (mu4e-message-at-point) :path))
         (temp (make-temp-file "mu4e-message-" nil ".eml")))
    (shell-command-to-string (format "cp '%s' '%s'; open '%s' -a Mail; l/bin/rm '%s'" msg-path temp temp temp))))

(advice-add
 'spacemacs/open-in-external-app :override
 #'(lambda ()
     (interactive)
     (let ((file-path (if (eq major-mode 'dired-mode)
                          (dired-get-file-for-visit)
                        (buffer-file-name))))
       (if file-path
           (cond
            ((spacemacs/system-is-mswindows) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\\\" file-path)))
            ((spacemacs/system-is-mac) (shell-command (format "open \"%s\"" file-path)))
            ((spacemacs/system-is-linux) (let ((process-connection-type nil))
                                           (start-process "" nil "xdg-open" file-path))))
         (if (or (eq 'mu4e-headers-mode major-mode) (eq 'mu4e-view-mode major-mode) (eq 'mu4e-org-mode major-mode))
             (open-message-with-mail-app)
           (message "No file associated to this buffer."))))))

3 个赞

发一张用 Org Mode 写邮件的效果:

3 个赞

I use crontab + mbsync for every 2 minutes. It’s okay.

早呢,还差中文搜索呢

中文是 xapian 的问题,设置 XAPIAN_CJK_NGRAM 环境变量后,暂时手动加下 s:, b: 算是可以用

你好,我按照spacemacs mu4elayer的设定,还是没有办法成功。。。请问你有什么参考嘛?谢谢

具体什么无法成功?没法发信?没法收信?imap 离线同步工具用的是什么?

这个用org-mode写HTML邮件的配置能否共享一下啊

(defun mu4e-toggle-org-mode ()
  (interactive)
  (cond
   ((eq major-mode 'mu4e-view-mode) (mu4e-org-mode))
   ((eq major-mode 'mu4e-org-mode) (mu4e-view-mode))
   ((eq major-mode 'mu4e-compose-mode) (org-mu4e-compose-org-mode))
   ((eq major-mode 'org-mu4e-compose-org-mode) (mu4e-compose-mode))))


(with-eval-after-load 'mu4e-view
  (spacemacs/set-leader-keys-for-major-mode 'mu4e-view-mode
    "to" 'mu4e-toggle-org-mode))


(with-eval-after-load 'mu4e-utils
  (spacemacs/set-leader-keys-for-major-mode 'mu4e-org-mode
    "to" 'mu4e-toggle-org-mode))

(with-eval-after-load 'mu4e-compose
  (spacemacs/set-leader-keys-for-major-mode 'mu4e-compose-mode "to" 'mu4e-toggle-org-mode))


(with-eval-after-load 'org-mu4e
  (setq org-mu4e-convert-to-html t)
  (spacemacs/set-leader-keys-for-major-mode 'org-mu4e-compose-org-mode "to" 'mu4e-toggle-org-mode)
  (defun org~mu4e-mime-convert-to-html ()
    "Convert the current body to html."
    (unless (fboundp 'org-export-string-as)
      (mu4e-error "require function 'org-export-string-as not found."))
    (let* ((begin
            (save-excursion
              (goto-char (point-min))
              (search-forward mail-header-separator)))
           (end (point-max))
           (raw-body (buffer-substring begin end))
           (tmp-file (make-temp-name (expand-file-name "mail"
                                                       temporary-file-directory)))
           (org-export-skip-text-before-1st-heading nil)
           (org-export-htmlize-output-type 'inline-css)
           (org-export-preserve-breaks t)
           (org-export-with-LaTeX-fragments
            (if (executable-find "dvipng") 'dvipng
              (mu4e-message "Cannot find dvipng, ignore inline LaTeX") nil))
           (html-and-images
            (org~mu4e-mime-replace-images
             (org-export-string-as raw-body 'html nil)
             tmp-file))
           (html-images (cdr html-and-images))
           (html (car html-and-images)))
      (delete-region begin end)
      (save-excursion
        (goto-char begin)
        (newline)
        (insert (org~mu4e-mime-multipart
                 raw-body html (mapconcat 'identity html-images "\n")))))))
2 个赞

看起来很cool,我一直希望在email中利用org OR markdown格式来进行格式输出。 我曾试过配置mu4e,太过于麻烦了,在mac中有个程序装不上,后来就放弃了。

请问下这个变量应该设置为什么呢?

export XAPIAN_CJK_NGRAM=1

谢谢,搞定了。

export XAPIAN_CJK_NGRAM=1

设置后,command line的mu可以搜中文。

我在emacs中也设置了:

(setenv "XAPIAN_CJK_NGRAM" "1")

这下mu4e也可以搜中文了。

1 个赞

IMAP IDLE 可以用 imapnotify,缺点是要安装 nodejs。

org-mu4e-compose-mode 怎么发带颜色的邮件,没研究出来,能设置css和js的么?像org-mode导出html文件 可以在org文件前面加描述信息,org-mu4e-compose-mode可以实现这样的效果么?

#+HTML_HEAD: