* mu4e-main.el: make clicks on bookmarks work as well
This commit is contained in:
@ -67,16 +67,25 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-action-str (str &optional func)
|
(defun mu4e-action-str (str &optional func-or-shortcut)
|
||||||
"Highlight the first occurence of [..] in STR. Also, optionally
|
"Highlight the first occurence of [..] in STR. If
|
||||||
set FUNC to be called with the STR is clicked."
|
FUNC-OR-SHORTCUT is non-nil and if it is a function, call it when
|
||||||
|
STR is clicked (using RET or mouse-2); if FUNC-OR-SHORTCUT is a
|
||||||
|
string, execute the corresponding keyboard action when it is
|
||||||
|
clicked."
|
||||||
(let ((newstr
|
(let ((newstr
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
"\\[\\(\\w+\\)\\]"
|
"\\[\\(\\w+\\)\\]"
|
||||||
(lambda(m)
|
(lambda(m)
|
||||||
(format "[%s]"
|
(format "[%s]"
|
||||||
(propertize (match-string 1 str) 'face 'mu4e-highlight-face))) str))
|
(propertize (match-string 1 str) 'face 'mu4e-highlight-face))) str))
|
||||||
(map (make-sparse-keymap)))
|
(map (make-sparse-keymap))
|
||||||
|
(func (if (functionp func-or-shortcut)
|
||||||
|
func-or-shortcut
|
||||||
|
(if (stringp func-or-shortcut)
|
||||||
|
(lexical-let ((macro func-or-shortcut))
|
||||||
|
(lambda()(interactive)
|
||||||
|
(execute-kbd-macro macro)))))))
|
||||||
(define-key map [mouse-2] func)
|
(define-key map [mouse-2] func)
|
||||||
(define-key map (kbd "RET") func)
|
(define-key map (kbd "RET") func)
|
||||||
(put-text-property 0 (length newstr) 'keymap map newstr)
|
(put-text-property 0 (length newstr) 'keymap map newstr)
|
||||||
@ -102,13 +111,14 @@ set FUNC to be called with the STR is clicked."
|
|||||||
(mu4e-action-str "\t* [C]ompose a new message\n" 'mu4e-compose-new)
|
(mu4e-action-str "\t* [C]ompose a new message\n" 'mu4e-compose-new)
|
||||||
"\n"
|
"\n"
|
||||||
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
|
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
|
||||||
|
;; TODO: it's a bit uncool to hard-code the "b" shortcut...
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (bm)
|
(lambda (bm)
|
||||||
(let* ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm)))
|
(let* ((query (nth 0 bm)) (title (nth 1 bm)) (key (nth 2 bm)))
|
||||||
(mu4e-action-str
|
(mu4e-action-str
|
||||||
(concat "\t* [b" (make-string 1 key) "] " title))))
|
(concat "\t* [b" (make-string 1 key) "] " title)
|
||||||
|
(concat "b" (make-string 1 key)))))
|
||||||
mu4e-bookmarks "\n")
|
mu4e-bookmarks "\n")
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user