mirror of https://github.com/djcb/mu.git
* mm updates
This commit is contained in:
parent
cc7a09bd93
commit
9ee6fec7ea
|
@ -208,18 +208,20 @@ after the end of the search results."
|
|||
;; navigation
|
||||
(define-key map "n" 'mm/next-header)
|
||||
(define-key map "p" 'mm/prev-header)
|
||||
(define-key map "j" 'mm/jump-to-maildir)
|
||||
|
||||
|
||||
;; marking/unmarking/executing
|
||||
(define-key map "m" 'mm/mark-for-move)
|
||||
|
||||
|
||||
(define-key map (kbd "<backspace>") 'mm/mark-for-trash)
|
||||
(define-key map "d" 'mm/mark-for-trash)
|
||||
|
||||
(define-key map (kbd "<delete>") 'mm/mark-for-delete)
|
||||
(define-key map "D" 'mm/mark-for-delete)
|
||||
(define-key map "a" 'mm/mark-for-move-quick)
|
||||
|
||||
(define-key map "j" 'mm/jump-to-maildir)
|
||||
(define-key map "m" 'mm/mark-for-move)
|
||||
|
||||
(define-key map "u" 'mm/unmark)
|
||||
(define-key map "U" 'mm/unmark-all)
|
||||
(define-key map "x" 'mm/execute-marks)
|
||||
|
@ -573,7 +575,10 @@ the new docid. Otherwise, return nil."
|
|||
(interactive)
|
||||
(with-current-buffer mm/hdrs-buffer
|
||||
(when (= 0 (forward-line 1))
|
||||
(or (mm/hdrs-get-docid) (mm/next-header))))) ;; skip non-headers
|
||||
(or (mm/hdrs-get-docid) (mm/next-header)) ;; skip non-headers
|
||||
;; trick to move point, even if this function is called when this window
|
||||
;; is not visible
|
||||
(set-window-point (get-buffer-window mm/hdrs-buffer) (point)))))
|
||||
|
||||
(defun mm/prev-header ()
|
||||
"Move point to the previous message header. If this succeeds,
|
||||
|
@ -581,11 +586,15 @@ return the new docid. Otherwise, return nil."
|
|||
(interactive)
|
||||
(with-current-buffer mm/hdrs-buffer
|
||||
(when (= 0 (forward-line -1))
|
||||
(or (mm/hdrs-get-docid) (mm/prev-header))))) ;; skip non-headers
|
||||
(or (mm/hdrs-get-docid) (mm/prev-header)) ;; skip non-headers
|
||||
;; trick to move point, even if this function is called when this window
|
||||
;; is not visible
|
||||
(set-window-point (get-buffer-window mm/hdrs-buffer) (point)))))
|
||||
|
||||
|
||||
(defun mm/jump-to-maildir ()
|
||||
"Show the messages in one of the standard folders."
|
||||
"Show the messages in maildir TARGET. If TARGET is not provided,
|
||||
ask user for it."
|
||||
(interactive)
|
||||
(let ((fld (mm/ask-maildir "Jump to maildir: ")))
|
||||
(mm/hdrs-search (concat "maildir:" fld))))
|
||||
|
@ -596,7 +605,7 @@ return the new docid. Otherwise, return nil."
|
|||
not provided, function asks for it."
|
||||
(interactive)
|
||||
(with-current-buffer mm/hdrs-buffer
|
||||
(let* ((target (or target (mm/ask-maildir "Target maildir for move: ")))
|
||||
(let* ((target (or target (mm/ask-maildir "Move message to: ")))
|
||||
(fulltarget (concat mm/maildir target)))
|
||||
(when (or (file-directory-p fulltarget)
|
||||
(and (yes-or-no-p
|
||||
|
@ -606,30 +615,6 @@ not provided, function asks for it."
|
|||
(mm/next-header)))))
|
||||
|
||||
|
||||
(defun mm/mark-for-move-quick ()
|
||||
"Mark message at point (or all messages in region) for moving to
|
||||
a folder; see `mm/move-quick-targets'."
|
||||
(interactive)
|
||||
(unless mm/move-quick-targets
|
||||
(error "`mm/move-quick-targets' has not been defined"))
|
||||
(let* ((fnames
|
||||
(mapconcat
|
||||
(lambda (item)
|
||||
(concat
|
||||
"["
|
||||
(propertize (make-string 1 (cdr item)) 'face 'mm/view-link-face)
|
||||
"]"
|
||||
(car item)))
|
||||
mm/move-quick-targets ", "))
|
||||
(kar (read-char (concat "Move to: " fnames)))
|
||||
(targetitem
|
||||
(find-if (lambda (item) (= kar (cdr item))) mm/move-quick-targets))
|
||||
(target (and targetitem (car targetitem))))
|
||||
;; if the target is not found, we simply exit
|
||||
(when target
|
||||
(mm/mark-for-move target))))
|
||||
|
||||
|
||||
(defun mm/mark-for-trash ()
|
||||
"Mark message at point for moving to the trash
|
||||
folder (`mm/trash-folder')."
|
||||
|
|
|
@ -213,8 +213,9 @@ or if not available, :body-html converted to text)."
|
|||
(define-key map (kbd "<delete>") 'mm/view-mark-for-delete)
|
||||
(define-key map "D" 'mm/view-mark-for-delete)
|
||||
(define-key map "a" 'mm/mark-for-move-quick)
|
||||
|
||||
(define-key map "m" 'mm/view-mark-for-move)
|
||||
|
||||
|
||||
;; misc
|
||||
(define-key map "w" 'mm/view-toggle-wrap-lines)
|
||||
(define-key map "h" 'mm/view-toggle-hide-cited)
|
||||
|
@ -395,9 +396,9 @@ removing '^M' etc."
|
|||
(defun mm/view-quit-buffer ()
|
||||
"Quit the message view and return to the headers."
|
||||
(interactive)
|
||||
(let ((inhibit-read-only t))
|
||||
(kill-buffer)
|
||||
(switch-to-buffer mm/hdrs-buffer)))
|
||||
(if (buffer-live-p mm/hdrs-buffer)
|
||||
(switch-to-buffer mm/hdrs-buffer)
|
||||
(kill-buffer)))
|
||||
|
||||
(defun mm/view-next-header ()
|
||||
"View the next header."
|
||||
|
|
|
@ -116,17 +116,16 @@ PATH, you can specifiy the full path."
|
|||
:group 'mm/folders)
|
||||
|
||||
|
||||
(defcustom mm/move-quick-targets nil
|
||||
"A list of targets quickly moving messages towards (i.e.,
|
||||
archiving or refiling). The list contains elements of the form
|
||||
(foldername . shortcut), where FOLDERNAME is a maildir (such as
|
||||
(defcustom mm/maildir-shortcuts nil
|
||||
"A list of maildir shortcuts to enable quickly going to the
|
||||
particular for, or quickly moving messages towards them (i.e.,
|
||||
archiving or refiling). The list contains elements of the form
|
||||
(maildir . shortcut), where MAILDIR is a maildir (such as
|
||||
\"/archive/\"), and shortcut a single shortcut character. With
|
||||
this, in the header buffer and view buffer you can execute
|
||||
`mm/mark-for-move-quick' (or 'a', by default) followed by the designated
|
||||
character for the target folder, and the message at point (or all
|
||||
the messages in the region) will be marked for moving to the target
|
||||
folder.")
|
||||
|
||||
`mm/mark-for-move-quick' (or 'm', by default) or
|
||||
`mm/jump-to-maildir-quick' (or 'j', by default), followed by the
|
||||
designated shortcut character for the maildir.")
|
||||
|
||||
;; the headers view
|
||||
(defgroup mm/headers nil
|
||||
|
@ -444,17 +443,31 @@ in which case it will be equal to `:to'.)")
|
|||
(map 'list (lambda (dir) (concat "/" dir)) maildirs)))
|
||||
|
||||
|
||||
|
||||
(defun mm/ask-maildir (prompt)
|
||||
"Ask user with PROMPT for a maildir name, if fullpath is
|
||||
non-nill, return the fulpath (i.e., `mm/maildir' prepended to the
|
||||
chosen folder)."
|
||||
(unless (and mm/inbox-folder mm/drafts-folder mm/sent-folder)
|
||||
(error "`mm/inbox-folder', `mm/drafts-folder' and
|
||||
`mm/sent-folder' must be set"))
|
||||
(unless mm/maildir (error "`mm/maildir' must be set"))
|
||||
(interactive)
|
||||
(ido-completing-read prompt (mm/get-sub-maildirs mm/maildir)))
|
||||
"Ask the user for a shortcut as defined in
|
||||
`mm/maildir-shortcuts', then return the corresponding folder
|
||||
name. If the special shortcut 'o' (for _o_ther) is used, or if
|
||||
`mm/maildir-shortcuts is not defined, let user choose from all
|
||||
maildirs under `mm/maildir."
|
||||
(unless mm/maildir (error "`mm/maildir' is not defined"))
|
||||
(if (not mm/maildir-shortcuts)
|
||||
(ido-completing-read prompt (mm/get-sub-maildirs mm/maildir))
|
||||
(let* ((mlist (append mm/maildir-shortcuts '(("ther" . ?o))))
|
||||
(fnames
|
||||
(mapconcat
|
||||
(lambda (item)
|
||||
(message "%S" item)
|
||||
(concat
|
||||
"["
|
||||
(propertize (make-string 1 (cdr item)) 'face 'mm/view-link-face)
|
||||
"]"
|
||||
(car item)))
|
||||
mlist ", "))
|
||||
(kar (read-char (concat prompt fnames))))
|
||||
(if (= kar ?o) ;; user chose 'other'?
|
||||
(ido-completing-read prompt (mm/get-sub-maildirs mm/maildir))
|
||||
(car-safe
|
||||
(find-if (lambda (item) (= kar (cdr item))) mm/maildir-shortcuts))))))
|
||||
|
||||
|
||||
(defun mm/new-buffer (bufname)
|
||||
|
@ -528,5 +541,4 @@ Also see `mu/flags-to-string'.
|
|||
(mm/string-to-flags-1 (substring str 1))))))
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(provide 'mm)
|
||||
|
|
Loading…
Reference in New Issue