mirror of https://github.com/djcb/mu.git
Merge pull request #1581 from thierryvolpiatto/Fix_revert_buffer
mu4e-main: Fix revert buffer
This commit is contained in:
commit
62bc45aaa7
|
@ -235,7 +235,8 @@ non-nil."
|
|||
(setq mu4e~context-current context)
|
||||
|
||||
(run-hooks 'mu4e-context-changed-hook)
|
||||
(mu4e-message "Switched context to %s" (mu4e-context-name context)))
|
||||
(mu4e-message "Switched context to %s" (mu4e-context-name context))
|
||||
(force-mode-line-update))
|
||||
context))
|
||||
|
||||
(defun mu4e~context-autoswitch (&optional msg policy)
|
||||
|
|
|
@ -1903,7 +1903,7 @@ other windows."
|
|||
;; now, all *other* windows should be gone. kill ourselves, and return
|
||||
;; to the main view
|
||||
(kill-buffer)
|
||||
(mu4e~main-view))))
|
||||
(mu4e~main-view 'refresh))))
|
||||
|
||||
;;; _
|
||||
(provide 'mu4e-headers)
|
||||
|
|
|
@ -63,19 +63,16 @@
|
|||
(define-key map "A" 'mu4e-about)
|
||||
(define-key map "N" 'mu4e-news)
|
||||
(define-key map "H" 'mu4e-display-manual)
|
||||
(define-key map "g" 'mu4e)
|
||||
map)
|
||||
|
||||
"Keymap for the *mu4e-main* buffer.")
|
||||
(fset 'mu4e-main-mode-map mu4e-main-mode-map)
|
||||
|
||||
(defvar mu4e-main-mode-abbrev-table nil)
|
||||
(define-derived-mode mu4e-main-mode special-mode "mu4e:main"
|
||||
"Major mode for the mu4e main screen.
|
||||
\\{mu4e-main-mode-map}."
|
||||
(use-local-map mu4e-main-mode-map)
|
||||
(setq truncate-lines t)
|
||||
(setq overwrite-mode 'overwrite-mode-binary)
|
||||
(setq truncate-lines t
|
||||
overwrite-mode 'overwrite-mode-binary)
|
||||
|
||||
;; show context in mode-string
|
||||
(make-local-variable 'global-mode-string)
|
||||
|
@ -158,9 +155,23 @@ clicked."
|
|||
;; NEW This is the old `mu4e~main-view' function but without
|
||||
;; buffer switching at the end.
|
||||
(defun mu4e~main-view-real (_ignore-auto _noconfirm)
|
||||
(let ((buf (get-buffer-create mu4e~main-buffer-name))
|
||||
(inhibit-read-only t))
|
||||
(with-current-buffer buf
|
||||
"The revert buffer function for `mu4e-main-mode'."
|
||||
(mu4e~main-view-real-1 'refresh))
|
||||
|
||||
(defun mu4e~main-view-real-1 (&optional refresh)
|
||||
"Create `mu4e~main-buffer-name' and set it up.
|
||||
When REFRESH is non nil refresh infos from server."
|
||||
(let ((inhibit-read-only t)
|
||||
(pos (point)))
|
||||
;; Maybe refresh infos from server.
|
||||
(if refresh
|
||||
(mu4e~start 'mu4e~main-redraw-buffer)
|
||||
(mu4e~main-redraw-buffer))))
|
||||
|
||||
(defun mu4e~main-redraw-buffer ()
|
||||
(with-current-buffer mu4e~main-buffer-name
|
||||
(let ((inhibit-read-only t)
|
||||
(pos (point)))
|
||||
(erase-buffer)
|
||||
(insert
|
||||
"* "
|
||||
|
@ -202,7 +213,8 @@ clicked."
|
|||
(mu4e~key-val "maildir" (mu4e-root-maildir))
|
||||
(mu4e~key-val "in store"
|
||||
(format "%d" (plist-get mu4e~server-props :doccount)) "messages"))
|
||||
(mu4e-main-mode))))
|
||||
(mu4e-main-mode)
|
||||
(goto-char pos))))
|
||||
|
||||
(defun mu4e~main-view-queue ()
|
||||
"Display queue-related actions in the main view."
|
||||
|
@ -232,20 +244,29 @@ clicked."
|
|||
(count-lines (point-min) (point-max)))
|
||||
(error 0)))
|
||||
|
||||
(defun mu4e~main-view ()
|
||||
"Create the mu4e main-view, and switch to it."
|
||||
(if (eq mu4e-split-view 'single-window)
|
||||
(if (buffer-live-p (mu4e-get-headers-buffer))
|
||||
(switch-to-buffer (mu4e-get-headers-buffer))
|
||||
(mu4e~main-menu))
|
||||
(mu4e~main-view-real nil nil)
|
||||
(switch-to-buffer mu4e~main-buffer-name)
|
||||
(goto-char (point-min)))
|
||||
(add-to-list 'global-mode-string '(:eval (mu4e-context-label))))
|
||||
(defun mu4e~main-view (&optional refresh)
|
||||
"Create the mu4e main-view, and switch to it.
|
||||
|
||||
;;; Commands
|
||||
When REFRESH is non nil refresh infos from server."
|
||||
(let ((buf (get-buffer-create mu4e~main-buffer-name)))
|
||||
(if (eq mu4e-split-view 'single-window)
|
||||
(if (buffer-live-p (mu4e-get-headers-buffer))
|
||||
(switch-to-buffer (mu4e-get-headers-buffer))
|
||||
(mu4e~main-menu))
|
||||
;; `mu4e~main-view' is called from `mu4e~start', so don't call it
|
||||
;; a second time here i.e. do not refresh unless specified
|
||||
;; explicitely with REFRESH arg.
|
||||
(switch-to-buffer buf)
|
||||
(with-current-buffer buf
|
||||
(mu4e-main-mode)
|
||||
(mu4e~main-view-real-1 refresh))
|
||||
(goto-char (point-min)))
|
||||
(add-to-list 'global-mode-string '(:eval (mu4e-context-label)))))
|
||||
|
||||
;; NEW Toggle mail sending mode without switching
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Interactive functions
|
||||
;; NEW
|
||||
;; Toggle mail sending mode without switching
|
||||
(defun mu4e~main-toggle-mail-sending-mode ()
|
||||
"Toggle sending mail mode, either queued or direct."
|
||||
(interactive)
|
||||
|
@ -254,10 +275,10 @@ clicked."
|
|||
(setq smtpmail-queue-mail (not smtpmail-queue-mail))
|
||||
(message (concat "Outgoing mail will now be "
|
||||
(if smtpmail-queue-mail "queued" "sent directly")))
|
||||
(unless (eq mu4e-split-view 'single-window)
|
||||
(let ((curpos (point)))
|
||||
(mu4e~main-view-real nil nil)
|
||||
(goto-char curpos))))
|
||||
(unless (or (eq mu4e-split-view 'single-window)
|
||||
(not (buffer-live-p (get-buffer mu4e~main-buffer-name))))
|
||||
(with-current-buffer mu4e~main-buffer-name
|
||||
(revert-buffer))))
|
||||
|
||||
(defun mu4e~main-menu ()
|
||||
"mu4e main view in the minibuffer."
|
||||
|
|
|
@ -642,7 +642,8 @@ process."
|
|||
(let* ((type (plist-get info :info))
|
||||
(processed (plist-get info :processed))
|
||||
(updated (plist-get info :updated))
|
||||
(cleaned-up (plist-get info :cleaned-up)))
|
||||
(cleaned-up (plist-get info :cleaned-up))
|
||||
(mainbuf (get-buffer mu4e~main-buffer-name)))
|
||||
(cond
|
||||
((eq type 'add) t) ;; do nothing
|
||||
((eq type 'index)
|
||||
|
@ -658,7 +659,9 @@ process."
|
|||
(run-hooks 'mu4e-index-updated-hook))
|
||||
(unless (and (not (string= mu4e~contacts-tstamp "0"))
|
||||
(zerop (plist-get info :updated)))
|
||||
(mu4e~request-contacts-maybe)))))
|
||||
(mu4e~request-contacts-maybe))
|
||||
(when (and (buffer-live-p mainbuf) (get-buffer-window mainbuf))
|
||||
(mu4e~main-view 'refresh)))))
|
||||
((plist-get info :message)
|
||||
(mu4e-index-message "%s" (plist-get info :message))))))
|
||||
|
||||
|
@ -800,19 +803,10 @@ context yet, switch to the matching one, or none matches, the
|
|||
first. If mu4e is already running, execute function FUNC (if
|
||||
non-nil). Otherwise, check various requireme`'nts, then start mu4e.
|
||||
When successful, call FUNC (if non-nil) afterwards."
|
||||
;; if we're already running, simply go to the main view
|
||||
(unless (mu4e-running-p) ;; already running?
|
||||
;; when it's visible, re-draw the main view when there are changes.
|
||||
(add-hook 'mu4e-index-updated-hook
|
||||
(lambda()
|
||||
(let ((mainbuf (get-buffer mu4e~main-buffer-name)))
|
||||
(when (and (buffer-live-p mainbuf) (get-buffer-window mainbuf))
|
||||
(mu4e~start 'mu4e~main-view))))))
|
||||
|
||||
(setq mu4e-pong-func (lambda (info) (mu4e~pong-handler info func)))
|
||||
(mu4e~proc-ping
|
||||
(mapcar ;; send it a list of queries we'd like to see read/unread info
|
||||
;; for.
|
||||
(mapcar
|
||||
;; send it a list of queries we'd like to see read/unread info for.
|
||||
(lambda(bm) (plist-get bm :query))
|
||||
(seq-filter (lambda (bm) ;; exclude bookmarks that are not strings,
|
||||
;; and with these flags.
|
||||
|
|
Loading…
Reference in New Issue