mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
notmuch.el: Hide email headers by default.
The display of the header can be toggled with the 'h' key.
This commit is contained in:
parent
a81849b5e2
commit
f2a4c3e565
2 changed files with 49 additions and 2 deletions
4
TODO
4
TODO
|
@ -2,8 +2,8 @@ Emacs interface (notmuch.el)
|
||||||
----------------------------
|
----------------------------
|
||||||
Add support to compose a reply to the current messaage.
|
Add support to compose a reply to the current messaage.
|
||||||
|
|
||||||
Selectively hide headers and bodies in notmuch-show mode. (for
|
Selectively hide bodies in notmuch-show mode. (for example, for read
|
||||||
example, for read messages).
|
messages).
|
||||||
|
|
||||||
Remove "unread" tag from messages as they are read.
|
Remove "unread" tag from messages as they are read.
|
||||||
|
|
||||||
|
|
47
notmuch.el
47
notmuch.el
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
(defvar notmuch-show-mode-map
|
(defvar notmuch-show-mode-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(define-key map "h" 'notmuch-show-toggle-headers-visible)
|
||||||
(define-key map "n" 'notmuch-show-next-message)
|
(define-key map "n" 'notmuch-show-next-message)
|
||||||
(define-key map "p" 'notmuch-show-previous-message)
|
(define-key map "p" 'notmuch-show-previous-message)
|
||||||
(define-key map "q" 'kill-this-buffer)
|
(define-key map "q" 'kill-this-buffer)
|
||||||
|
@ -42,6 +43,11 @@
|
||||||
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
|
(fset 'notmuch-show-mode-map notmuch-show-mode-map)
|
||||||
|
|
||||||
(defvar notmuch-show-message-begin-regexp "message{")
|
(defvar notmuch-show-message-begin-regexp "message{")
|
||||||
|
(defvar notmuch-show-message-end-regexp "message}")
|
||||||
|
(defvar notmuch-show-header-begin-regexp "header{")
|
||||||
|
(defvar notmuch-show-header-end-regexp "header}")
|
||||||
|
|
||||||
|
(defvar notmuch-show-headers-visible t)
|
||||||
|
|
||||||
(defun notmuch-show-next-message ()
|
(defun notmuch-show-next-message ()
|
||||||
"Advance point to the beginning of the next message in the buffer."
|
"Advance point to the beginning of the next message in the buffer."
|
||||||
|
@ -65,11 +71,51 @@
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(recenter 0))
|
(recenter 0))
|
||||||
|
|
||||||
|
(defun notmuch-show-markup-this-header ()
|
||||||
|
(if (re-search-forward notmuch-show-header-begin-regexp nil t)
|
||||||
|
(progn
|
||||||
|
(overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
|
||||||
|
'invisible 'notmuch-show-marker)
|
||||||
|
(next-line 1)
|
||||||
|
(beginning-of-line)
|
||||||
|
(let ((beg (point)))
|
||||||
|
(if (re-search-forward notmuch-show-header-end-regexp nil t)
|
||||||
|
(progn
|
||||||
|
(overlay-put (make-overlay beg (match-beginning 0))
|
||||||
|
'invisible 'notmuch-show-header)
|
||||||
|
(overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
|
||||||
|
'invisible 'notmuch-show-marker)))))
|
||||||
|
(goto-char (point-max))))
|
||||||
|
|
||||||
|
(defun notmuch-show-markup-headers ()
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (not (eobp))
|
||||||
|
(notmuch-show-markup-this-header))))
|
||||||
|
|
||||||
|
(defun notmuch-show-toggle-headers-visible ()
|
||||||
|
"Toggle visibility of header fields"
|
||||||
|
(interactive)
|
||||||
|
(if notmuch-show-headers-visible
|
||||||
|
(progn
|
||||||
|
(add-to-invisibility-spec 'notmuch-show-header)
|
||||||
|
(set 'notmuch-show-headers-visible nil)
|
||||||
|
; Need to force the redisplay for some reason
|
||||||
|
(force-window-update)
|
||||||
|
(redisplay t))
|
||||||
|
(remove-from-invisibility-spec 'notmuch-show-header)
|
||||||
|
(set 'notmuch-show-headers-visible t)
|
||||||
|
(force-window-update)
|
||||||
|
(redisplay t)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun notmuch-show-mode ()
|
(defun notmuch-show-mode ()
|
||||||
"Major mode for handling the output of \"notmuch show\""
|
"Major mode for handling the output of \"notmuch show\""
|
||||||
(interactive)
|
(interactive)
|
||||||
(kill-all-local-variables)
|
(kill-all-local-variables)
|
||||||
|
(set (make-local-variable 'notmuch-show-headers-visible) t)
|
||||||
|
(notmuch-show-toggle-headers-visible)
|
||||||
|
(add-to-invisibility-spec 'notmuch-show-marker)
|
||||||
(use-local-map notmuch-show-mode-map)
|
(use-local-map notmuch-show-mode-map)
|
||||||
(setq major-mode 'notmuch-show-mode
|
(setq major-mode 'notmuch-show-mode
|
||||||
mode-name "notmuch-show")
|
mode-name "notmuch-show")
|
||||||
|
@ -90,6 +136,7 @@
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(call-process "notmuch" nil t nil "show" thread-id)
|
(call-process "notmuch" nil t nil "show" thread-id)
|
||||||
|
(notmuch-show-markup-headers)
|
||||||
)
|
)
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue