emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/gnus/gnus-picon.el,v


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/gnus/gnus-picon.el,v
Date: Sun, 28 Oct 2007 09:19:13 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Miles Bader <miles>     07/10/28 09:18:40

Index: lisp/gnus/gnus-picon.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/gnus-picon.el,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- lisp/gnus/gnus-picon.el     26 Jul 2007 05:26:58 -0000      1.9
+++ lisp/gnus/gnus-picon.el     28 Oct 2007 09:18:30 -0000      1.10
@@ -74,6 +74,15 @@
   :type '(repeat string)
   :group 'gnus-picon)
 
+(defcustom gnus-picon-style 'inline
+  "How should picons be displayed.
+If `inline', the textual representation is replaced.  If `right', picons are
+added right to the textual representation."
+  ;; FIXME: `right' needs improvement for XEmacs.
+  :type '(choice (const inline)
+                (const right))
+  :group 'gnus-picon)
+
 (defface gnus-picon-xbm '((t (:foreground "black" :background "white")))
   "Face to show xbm picon in."
   :group 'gnus-picon)
@@ -139,14 +148,17 @@
        file
       nil)))
 
-(defun gnus-picon-insert-glyph (glyph category)
+(defun gnus-picon-insert-glyph (glyph category &optional nostring)
   "Insert GLYPH into the buffer.
-GLYPH can be either a glyph or a string."
+GLYPH can be either a glyph or a string.  When NOSTRING, no textual
+replacement is added."
+  ;; Using NOSTRING prevents wrong BBDB entries with `gnus-picon-style' set to
+  ;; 'right.
   (if (stringp glyph)
       (insert glyph)
     (gnus-add-wash-type category)
     (gnus-add-image category (car glyph))
-    (gnus-put-image (car glyph) (cdr glyph) category)))
+    (gnus-put-image (car glyph) (unless nostring (cdr glyph)) category)))
 
 (defun gnus-picon-create-glyph (file)
   (or (cdr (assoc file gnus-picon-glyph-alist))
@@ -166,7 +178,7 @@
               (mail-encode-encoded-word-string
                (or (mail-fetch-field header) "")))
             (mail-fetch-field header))))
-         spec file point cache)
+        spec file point cache len)
       (dolist (address addresses)
        (setq address (car address))
        (when (and (stringp address)
@@ -197,6 +209,26 @@
 
          (gnus-article-goto-header header)
          (mail-header-narrow-to-field)
+        (case gnus-picon-style
+              (right
+               (when (= (length addresses) 1)
+                 (setq len (apply '+ (mapcar (lambda (x)
+                                               (condition-case nil
+                                                   (car (image-size (car x)))
+                                                 (error 0))) spec)))
+                 (when (> len 0)
+                   (goto-char (point-at-eol))
+                   (insert (propertize
+                            " " 'display
+                            (cons 'space
+                                  (list :align-to (- (window-width) 1 len))))))
+                 (goto-char (point-at-eol))
+                 (setq point (point-at-eol))
+                 (dolist (image spec)
+                   (unless (stringp image)
+                     (goto-char point)
+                     (gnus-picon-insert-glyph image category 'nostring)))))
+              (inline
          (when (search-forward address nil t)
            (delete-region (match-beginning 0) (match-end 0))
            (setq point (point))
@@ -206,7 +238,7 @@
                  (insert ".")
                (if (= (length spec) 2)
                  (insert "@")))
-             (gnus-picon-insert-glyph (pop spec) category))))))))
+                    (gnus-picon-insert-glyph (pop spec) category))))))))))
 
 (defun gnus-picon-transform-newsgroups (header)
   (interactive)
@@ -253,8 +285,7 @@
     (gnus-with-article-buffer
       (if (and wash-picon-p (memq 'from-picon gnus-article-wash-types))
          (gnus-delete-images 'from-picon)
-       (gnus-picon-transform-address "from" 'from-picon)))
-    ))
+       (gnus-picon-transform-address "from" 'from-picon)))))
 
 ;;;###autoload
 (defun gnus-treat-mail-picon ()
@@ -266,8 +297,7 @@
       (if (and wash-picon-p (memq 'mail-picon gnus-article-wash-types))
          (gnus-delete-images 'mail-picon)
        (gnus-picon-transform-address "cc" 'mail-picon)
-       (gnus-picon-transform-address "to" 'mail-picon)))
-    ))
+       (gnus-picon-transform-address "to" 'mail-picon)))))
 
 ;;;###autoload
 (defun gnus-treat-newsgroups-picon ()
@@ -279,8 +309,7 @@
       (if (and wash-picon-p (memq 'newsgroups-picon gnus-article-wash-types))
          (gnus-delete-images 'newsgroups-picon)
        (gnus-picon-transform-newsgroups "newsgroups")
-       (gnus-picon-transform-newsgroups "followup-to")))
-    ))
+       (gnus-picon-transform-newsgroups "followup-to")))))
 
 (provide 'gnus-picon)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]