未加星标

Pragmatic Emacs: Customise the reply quote string in mu4e

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

You know the bit of text that appears before the quoted email when you reply to someone? Of course you can customise this inmu4e. By default a quoted reply will be preceded with something like

"On Mon, 30 Jan 2017, Joe Bloggs wrote:"

I wanted to include the time and email address of the sender, so I customised the variable message-citation-line-format as follows

;; customize the reply-quote-string (setq message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n") ;; choose to use the formatted string (setq message-citation-line-function 'message-insert-formatted-citation-line)

which translates to something like this

On Mon 30 Jan 2017 at 19:17, Joe Bloggs <[email protected]> wrote:

The formatting options can be found by looking up the help for the variable with C-h v message-citation-line-format .

Sadly, this change broke myfunction to extract the sender name for my email template. Here is an updated version:

;; function to return first name of email recipients ;; used by yasnippet ;; inspired by ;;http://blog.binchen.org/posts/how-to-use-yasnippets-to-produce-email-templates-in-emacs.html (defun bjm/mu4e-get-names-for-yasnippet () "Return comma separated string of names for an email" (interactive) (let ((email-name "") str email-string email-list email-name2 tmpname) (save-excursion (goto-char (point-min)) ;; first line in email could be some hidden line containing NO to field (setq str (buffer-substring-no-properties (point-min) (point-max)))) ;; take name from TO field - match series of names (when (string-match "^To: \"?\\(.+\\)" str) (setq email-string (match-string 1 str))) ;;split to list by comma (setq email-list (split-string email-string " *, *")) ;;loop over emails (dolist (tmpstr email-list) ;;get first word of email string (setq tmpname (car (split-string tmpstr " "))) ;;remove whitespace or "" (setq tmpname (replace-regexp-in-string "[ \"]" "" tmpname)) ;;join to string (setq email-name (concat email-name ", " tmpname))) ;;remove initial comma (setq email-name (replace-regexp-in-string "^, " "" email-name)) ;;see if we want to use the name in the FROM field ;;get name in FROM field if available, but only if there is only ;;one name in TO field (if (< (length email-list) 2) (when (string-match "^On.+, \\([^ ,\n]+\\).+wrote:$" str) (progn (setq email-name2 (match-string 1 str)) ;;prefer name in FROM field if TO field has "@" (when (string-match "@" email-name) (setq email-name email-name2)) ))) email-name))

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

分页:12
转载请注明
本文标题:Pragmatic Emacs: Customise the reply quote string in mu4e
本站链接:http://www.codesec.net/view/530913.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(47)