Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: ding@gnus.org
Subject: show attachments on the top
Date: Fri, 01 Nov 2013 19:32:36 +0900	[thread overview]
Message-ID: <b4mfvrgtnsr.fsf@jpl.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 5 bytes --]

Hi,


[-- Attachment #2: Type: application/octet-stream, Size: 1773 bytes --]

(defvar my-gnus-summary-show-attachments-on-top-p nil)

(defun my-gnus-summary-show-attachments-on-top ()
  "Show attachments on the top of the body."
  (interactive)
  (with-current-buffer gnus-article-buffer
    (let* ((top (progn (article-goto-body) (point)))
	   (st top)
	   (inhibit-read-only t)
	   nd parts marker)
      (while (setq st (text-property-not-all st (point-max) 'gnus-part nil))
	(setq nd (or (text-property-any st (point-max) 'gnus-part nil)
		     (point-max)))
	(if (member "attachment"
		    (mm-handle-disposition (get-text-property st 'gnus-data)))
	    (progn
	      (push (cons (buffer-substring st nd) (overlays-at st)) parts)
	      (delete-region st (if (eq (char-after nd) ?\n) (1+ nd) nd)))
	  (setq st nd)))
      (goto-char top)
      (dolist (part (nreverse parts))
	(setq st (point))
	(insert (car part))
	(unless (bolp) (insert "\n"))
	(setq nd (point))
	(dolist (ovl (cdr part))
	  (when (setq marker (plist-get (cdr (overlay-get ovl 'button)) :from))
	    (set-marker marker st))
	  (when (setq marker (plist-get (cdr (overlay-get ovl 'button)) :to))
	    (set-marker marker nd))
	  (move-overlay ovl st nd)))
      (when (and parts (not (eq (char-after) ?\n)))
	(insert "\n")))
    (set-buffer-modified-p nil)))

(defadvice gnus-article-prepare (around toggle-attachments-position activate)
  "Toggle the position where attachments are."
  (setq my-gnus-summary-show-attachments-on-top-p
	(if (eq (gnus-summary-article-number)
		(and (gnus-buffer-live-p gnus-article-buffer)
		     (with-current-buffer gnus-article-buffer
		       (cdr gnus-article-current))))
	    (not my-gnus-summary-show-attachments-on-top-p)
	  t))
  ad-do-it
  (when my-gnus-summary-show-attachments-on-top-p
    (my-gnus-summary-show-attachments-on-top)))

[-- Attachment #3: Type: text/plain, Size: 282 bytes --]

Maybe no one will add a MIME part in this way; people (or almost
mail clients) add attachments at the bottom no matter how the body
is big.  Because of this, I sometimes overlook them.

The code in this attachment makes Gnus show attachments at the top.
`g' toggles the appearance.

             reply	other threads:[~2013-11-01 10:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01 10:32 Katsumi Yamaoka [this message]
2013-11-01 11:27 ` Julien Danjou
2013-12-26 16:52 ` Lars Ingebrigtsen
2014-02-05  9:54   ` Katsumi Yamaoka
2014-02-08  6:23     ` Eric Abrahamsen
2014-02-08 10:55       ` Katsumi Yamaoka
2014-02-08 12:20         ` Eric Abrahamsen
2014-02-10  0:19           ` Katsumi Yamaoka
2014-02-10  5:46             ` Eric Abrahamsen
2014-03-05 17:42       ` Lars Ingebrigtsen
2014-01-17 18:29 ` Uwe Brauer
2014-01-18  8:13   ` Gijs Hillenius
2014-01-18 12:41   ` Katsumi Yamaoka
2014-01-19 23:30     ` Katsumi Yamaoka
2014-01-21 11:09       ` Uwe Brauer
2014-01-21 23:55         ` Katsumi Yamaoka
2014-01-22 11:18           ` Uwe Brauer
2014-01-23  2:09             ` Katsumi Yamaoka
2014-01-23  8:04               ` Gijs Hillenius
2014-01-23 10:37                 ` Katsumi Yamaoka
2014-01-23 13:46               ` Uwe Brauer

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

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

  git send-email \
    --in-reply-to=b4mfvrgtnsr.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).