Gnus development mailing list
 help / color / mirror / Atom feed
* show attachments on the top
@ 2013-11-01 10:32 Katsumi Yamaoka
  2013-11-01 11:27 ` Julien Danjou
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Katsumi Yamaoka @ 2013-11-01 10:32 UTC (permalink / raw)
  To: ding

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-03-05 17:42 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01 10:32 show attachments on the top Katsumi Yamaoka
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

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