(gnus-auto-select-part): New variable.
authorReiner Steib <Reiner.Steib@gmx.de>
Mon, 29 Aug 2005 12:26:51 +0000 (12:26 +0000)
committerReiner Steib <Reiner.Steib@gmx.de>
Mon, 29 Aug 2005 12:26:51 +0000 (12:26 +0000)
(gnus-article-jump-to-part): New function.
(gnus-article-edit-part, gnus-mime-save-part-and-strip)
(gnus-mime-delete-part): Allow selecting specified part after
deleting or stripping parts.

lisp/ChangeLog
lisp/gnus-art.el

index 31e2f6e..5c8e312 100644 (file)
@@ -3,6 +3,11 @@
        * gnus-art.el (gnus-mime-save-part-and-strip): Don't prompt.
        (gnus-mime-delete-part): Don't prompt if `gnus-expert-user' is
        non-nil.
+       (gnus-auto-select-part): New variable.
+       (gnus-article-jump-to-part): New function.
+       (gnus-article-edit-part, gnus-mime-save-part-and-strip)
+       (gnus-mime-delete-part): Allow selecting specified part after
+       deleting or stripping parts.
 
 2005-08-22  Karl Chen  <quarl@cs.berkeley.edu>  (tiny change)
 
index 0c8444b..ff985de 100644 (file)
@@ -934,6 +934,19 @@ used."
   :type '(repeat (cons (string :tag "name")
                       (function))))
 
+(defcustom gnus-auto-select-part 1
+  "Advance to next MIME part when deleting or stripping parts.
+
+When 0, point will be placed on the same part as before.  When
+positive (negative), move point forward (backwards) this many
+parts.  When nil, redisplay article."
+  :version "23.0" ;; No Gnus
+  :group 'gnus-article-mime
+  :type '(choice (const nil :tag "Redisplay article.")
+                (const 1 :tag "Next part.")
+                (const 0 :tag "Current part.")
+                integer))
+
 ;;;
 ;;; The treatment variables
 ;;;
@@ -4093,8 +4106,23 @@ General format specifiers can also be used.  See Info node
          (delete-region (point) (point-max))
          (mm-display-parts handles))))))
 
+(defun gnus-article-jump-to-part (n)
+  "Jump to MIME part N."
+  (interactive "P")
+  (pop-to-buffer gnus-article-buffer)
+  (let ((parts (length gnus-article-mime-handle-alist)))
+    (while (not (and (integerp n) (<= n parts) (>= n 1)))
+      (setq n (read-number
+              (concat
+               (if n
+                   (format "`%s' is not a valid part.  " n)
+                 "")
+               (format "Jump to part (2..%s): " parts))
+              parts)))
+    (gnus-article-goto-part n)))
+
 (eval-when-compile
-  (defsubst gnus-article-edit-part (handles)
+  (defsubst gnus-article-edit-part (handles &optional current-id)
     "Edit an article in order to delete a mime part.
 This function is exclusively used by `gnus-mime-save-part-and-strip'
 and `gnus-mime-delete-part', and not provided at run-time normally."
@@ -4136,7 +4164,10 @@ and `gnus-mime-delete-part', and not provided at run-time normally."
         ,gnus-summary-buffer no-highlight)))
     (gnus-article-edit-done)
     (gnus-summary-expand-window)
-    (gnus-summary-show-article)))
+    (gnus-summary-show-article)
+    (when (and current-id (integerp gnus-auto-select-part))
+      (gnus-article-jump-to-part
+       (+ current-id gnus-auto-select-part)))))
 
 (defun gnus-mime-save-part-and-strip ()
   "Save the MIME part under point then replace it with an external body."
@@ -4148,6 +4179,7 @@ and `gnus-mime-delete-part', and not provided at run-time normally."
     (error "\
 The current article has a complicated MIME structure, giving up..."))
   (let* ((data (get-text-property (point) 'gnus-data))
+        (id (get-text-property (point) 'gnus-part))
         file param
         (handles gnus-article-mime-handles))
     (setq file (and data (mm-save-part data)))
@@ -4166,8 +4198,8 @@ The current article has a complicated MIME structure, giving up..."))
                                   `("message/external-body"
                                     (access-type . "LOCAL-FILE")
                                     (name . ,file)))))
-      (set-buffer gnus-summary-buffer)
-      (gnus-article-edit-part handles))))
+      ;; (set-buffer gnus-summary-buffer)
+      (gnus-article-edit-part handles id))))
 
 (defun gnus-mime-delete-part ()
   "Delete the MIME part under point.
@@ -4183,6 +4215,7 @@ The current article has a complicated MIME structure, giving up..."))
            (gnus-yes-or-no-p "\
 Deleting parts may malfunction or destroy the article; continue? "))
     (let* ((data (get-text-property (point) 'gnus-data))
+          (id (get-text-property (point) 'gnus-part))
           (handles gnus-article-mime-handles)
           (none "(none)")
           (description
@@ -4213,8 +4246,8 @@ Deleting parts may malfunction or destroy the article; continue? "))
                        nil `("text/plain") nil nil
                        (list "attachment")
                        (format "Deleted attachment (%s bytes)" bsize))))))
-      (set-buffer gnus-summary-buffer)
-      (gnus-article-edit-part handles))))
+      ;; (set-buffer gnus-summary-buffer)
+      (gnus-article-edit-part handles id))))
 
 (defun gnus-mime-save-part ()
   "Save the MIME part under point."