This looks excellent. +1 from me. Best wishes Mark Austin Clements <amdragon@MIT.EDU> writes: > This is v2 of id:87zjvghx82.fsf@qmul.ac.uk. In addition to some > general improvements, this fixes the handling of part overlays in > indented messages, removes the special part button map entirely in > favor of the "." submap, and adds a NEWS patch. > > The diff from v1 follows > > diff --git a/NEWS b/NEWS > index a7f2ec6..23f4c6a 100644 > --- a/NEWS > +++ b/NEWS > @@ -61,6 +61,22 @@ notmuch-vim, but of course that is their decision. > Emacs Interface > --------------- > > +New keymap to view/save parts > + > + To view or save a single MIME part of a message, use the new "." > + submap (e.g., ". s" to save, ". v" to view). Previously, these keys > + were only available when point was on a part button and they did not > + have the "." prefix, so they were difficult to invoke (impossible if > + a part did not have a button) and clashed with other bindings. > + These new bindings also appear in show's help, so you don't have to > + memorize them. > + > +Default part save directory is now `mm-default-directory` > + > + Previously, notmuch offered to save parts and attachments to a mix > + of `mm-default-directory`, `mailcap-download-directory`, and `~/`. > + This has been standardized on `mm-default-directory`. > + > No Emacs 22 support > > The Emacs 22 support added late 2010 was sufficient only for a short > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el > index 09ce25e..2186783 100644 > --- a/emacs/notmuch-lib.el > +++ b/emacs/notmuch-lib.el > @@ -360,21 +360,17 @@ OBJECT." > below > string)) > > -(defun notmuch-put-text-property-if-nil (start end property value > - &optional object) > - "Like `put-text-property', but only set the property where it is nil." > +(defun notmuch-map-text-property (start end prop func &optional object) > + "Transform text property PROP using FUNC. > + > +Applies FUNC to each distinct value of the text property PROP > +between START and END of OBJECT, setting PROP to the value > +returned by FUNC." > (while (< start end) > - (let ((start-nil (text-property-any start end property nil object))) > - (if (null start-nil) > - ;; There are no more nil regions; exit the loop > - (setq start end) > - ;; Find the end of the nil region > - (let ((end-nil > - (or (text-property-not-all start-nil end property nil object) > - end))) > - ;; Set the property > - (put-text-property start-nil end-nil property value object) > - (setq start end-nil)))))) > + (let ((value (get-text-property start prop object)) > + (next (next-single-property-change start prop object end))) > + (put-text-property start next prop (funcall func value) object) > + (setq start next)))) > > (defun notmuch-logged-error (msg &optional extra) > "Log MSG and EXTRA to *Notmuch errors* and signal MSG. > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 380b144..613e666 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -466,7 +466,6 @@ message at DEPTH in the current thread." > > (define-button-type 'notmuch-show-part-button-type > 'action 'notmuch-show-part-button-default > - 'keymap 'notmuch-show-part-button-map > 'follow-link t > 'face 'message-mml > :supertype 'notmuch-button-type) > @@ -843,8 +842,15 @@ If HIDE is non-nil then initially hide this part." > (insert "\n")) > (notmuch-show-create-part-overlays msg beg (point) hide) > ;; Record part information. Since we already inserted subparts, > - ;; don't override exiting :notmuch-part properties. > - (notmuch-put-text-property-if-nil beg (point) :notmuch-part part))) > + ;; don't override existing :notmuch-part properties. > + (notmuch-map-text-property beg (point) :notmuch-part > + (lambda (v) (or v part))) > + ;; Make :notmuch-part front sticky and rear non-sticky so it stays > + ;; applied to the beginning of each line when we indent the message. > + (notmuch-map-text-property beg (point) 'front-sticky > + (lambda (v) (pushnew :notmuch-part v))) > + (notmuch-map-text-property beg (point) 'rear-nonsticky > + (lambda (v) (pushnew :notmuch-part v))))) > > (defun notmuch-show-insert-body (msg body depth) > "Insert the body BODY at depth DEPTH in the current thread." > @@ -1194,11 +1200,6 @@ reset based on the original query." > "Submap for part commands") > (fset 'notmuch-show-part-map notmuch-show-part-map) > > -(defvar notmuch-show-part-button-map > - (make-composed-keymap notmuch-show-part-map button-map) > - "Keymap for part button commands") > -(fset 'notmuch-show-part-button-map notmuch-show-part-button-map) > - > (defvar notmuch-show-mode-map > (let ((map (make-sparse-keymap))) > (define-key map "?" 'notmuch-help) > @@ -1365,7 +1366,7 @@ Some useful entries are: > (get-text-property (point) :notmuch-message-properties))) > > (defun notmuch-show-get-part-properties () > - "Return the properties of the part containing point. > + "Return the properties of the innermost part containing point. > > This is the part property list retrieved from the CLI. Signals > an error if there is no part containing point."