unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 0/5] emacs: Part command improvements
Date: Wed, 29 May 2013 21:13:43 -0400	[thread overview]
Message-ID: <1369876428-13537-1-git-send-email-amdragon@mit.edu> (raw)

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."

             reply	other threads:[~2013-05-30  1:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30  1:13 Austin Clements [this message]
2013-05-30  1:13 ` [PATCH v2 1/5] emacs: Retain text properties when toggling buttons Austin Clements
2013-05-30  1:13 ` [PATCH v2 2/5] emacs: Record part p-list in a text property Austin Clements
2013-05-30  1:13 ` [PATCH v2 3/5] emacs: Simplify MIME part command implementation Austin Clements
2013-05-30  1:13 ` [PATCH v2 4/5] emacs: Bind MIME part commands to "." submap Austin Clements
2013-05-30  1:13 ` [PATCH v2 5/5] News for Emacs part handling changes Austin Clements
2013-05-30 14:33 ` [PATCH v2 0/5] emacs: Part command improvements Mark Walters
2013-05-31  0:26 ` Jameson Graef Rollins
2013-06-01  1:05 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369876428-13537-1-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).