From 041a79fdb587f4872dadd1c10d273d12dda4efb4 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 7 Jun 2015 21:07:59 +0300 Subject: [PATCH] mu4e: add NEWS(.org) as a main menu item --- mu4e/mu4e-main.el | 2 ++ mu4e/mu4e-meta.el.in | 3 +++ mu4e/mu4e-utils.el | 48 +++++++++++++++++++++++--------------------- mu4e/mu4e-vars.el | 12 ++++++----- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el index 623ee1a6..d62fe5e8 100644 --- a/mu4e/mu4e-main.el +++ b/mu4e/mu4e-main.el @@ -57,6 +57,7 @@ (define-key map "$" 'mu4e-show-log) (define-key map "A" 'mu4e-about) + (define-key map "N" 'mu4e-news) (define-key map "H" 'mu4e-display-manual) map) @@ -146,6 +147,7 @@ clicked." (mu4e~main-view-queue) "") "\n" + (mu4e~main-action-str "\t* [N]ews\n" 'mu4e-news) (mu4e~main-action-str "\t* [A]bout mu4e\n" 'mu4e-about) (mu4e~main-action-str "\t* [H]elp\n" 'mu4e-display-manual) (mu4e~main-action-str "\t* [q]uit\n" 'mu4e-quit)) diff --git a/mu4e/mu4e-meta.el.in b/mu4e/mu4e-meta.el.in index 91f52726..47d242db 100644 --- a/mu4e/mu4e-meta.el.in +++ b/mu4e/mu4e-meta.el.in @@ -5,4 +5,7 @@ (defconst mu4e-builddir "@abs_top_builddir@" "Top-level build directory.") +(defconst mu4e-doc-dir "@MU_DOC_DIR@" + "Mu4e's data-dir.") + (provide 'mu4e-meta) diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index 93437880..6c39e821 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -32,7 +32,7 @@ (eval-when-compile (require 'org nil 'noerror)) (require 'mu4e-vars) -(require 'mu4e-about) +(require 'mu4e-meta) (require 'mu4e-lists) (require 'doc-view) @@ -1060,32 +1060,34 @@ displaying it). Do _not_ bury the current buffer, though." (apply 'encode-time (mu4e-parse-time-string timestr)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defconst mu4e~main-about-buffer-name "*mu4e-about*" - "Name for the mu4e-about buffer.") +(define-derived-mode mu4e-org-mode org-mode "mu4e:org" + "Major mode for mu4e documents, derived from + `org-mode'.") -(define-derived-mode mu4e-about-mode org-mode "mu4e:about" - "Major mode for the mu4e About page, derived from `org-mode'.") +(defun mu4e-info (path) + "Show a buffer with the information (an org-file) at PATH." + (interactive) + (unless (file-exists-p path) + (mu4e-error "Cannot find %s" path)) + (lexical-let ((curbuf (current-buffer))) + (find-file path) + (mu4e-org-mode) + (setq buffer-read-only t) + (define-key mu4e-org-mode-map (kbd "q") + (lambda () + (interactive) + (bury-buffer) + (switch-to-buffer curbuf))))) (defun mu4e-about () - "Show a buffer with the mu4e-about text." + "Show the mu4e 'about' page." (interactive) - (lexical-let ((oldbuf (current-buffer))) - (with-current-buffer - (get-buffer-create mu4e~main-about-buffer-name) - (define-key mu4e-about-mode-map (kbd "q") - (lambda () ;; XXX it seems unnecessarily hard to do this... - (interactive) - (bury-buffer) - (when (buffer-live-p oldbuf) - (switch-to-buffer oldbuf)))) - (let ((inhibit-read-only t)) - (erase-buffer) - (insert mu4e-about) - (mu4e-about-mode) - (show-all)))) - (switch-to-buffer mu4e~main-about-buffer-name) - (setq buffer-read-only t) - (goto-char (point-min))) + (mu4e-info (concat mu4e-doc-dir "/mu4e-about.org"))) + +(defun mu4e-news () + "Show the mu4e 'about' page." + (interactive) + (mu4e-info (concat mu4e-doc-dir "/NEWS.org"))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun mu4e-refresh-message (path maildir) diff --git a/mu4e/mu4e-vars.el b/mu4e/mu4e-vars.el index 8ddcbd0e..060e1ea5 100644 --- a/mu4e/mu4e-vars.el +++ b/mu4e/mu4e-vars.el @@ -57,11 +57,13 @@ link." (defcustom mu4e-get-mail-command "true" "Shell command to run to retrieve new mail. -Common values are \"offlineimap\", \"fetchmail\" and \"mbsync\", -but you use arbitrary shell-commands. If you set it to -\"true\" (the default), the command won't don't anything, which is -useful if you get your mail without the need to explicitly run any -scripts, for example when running your own mail-server." +Common values are \"offlineimap\", \"fetchmail\" or \"mbsync\", but +arbitrary shell-commands can be used. + +When set to \"true\" (the default), the command simply finishes +succesfully (running the 'true' command) without retrieving any +mail. This can be useful when mail is already retrieved in another +way." :type 'string :group 'mu4e :safe 'stringp)