(gnus-random-x-face): Renamed.
[gnus] / lisp / gnus-fun.el
1 ;;; gnus-fun.el --- various frivoluos extension functions to Gnus
2 ;; Copyright (C) 2002 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (defcustom gnus-x-face-directory (expand-file-name "x-faces" gnus-directory)
29   "*Directory where X-Face PBM files are stored."
30   :group 'gnus-fun
31   :type 'directory)
32
33 (defcustom gnus-convert-pbm-to-x-face-command "pbmtoxbm '%s' | compface"
34   "Command for converting a PBM to an X-Face."
35   :group 'gnus-fun
36   :type 'string)
37
38 (defcustom gnus-convert-image-to-x-face-command "giftopnm '%s' | ppmnorm 2>/dev/null | pnmscale -width 48 -height 48 | ppmtopgm | pgmtopbm | pbmtoxbm | compface"
39   "Command for converting a PBM to an X-Face."
40   :group 'gnus-fun
41   :type 'string)
42
43 ;;;###autoload
44 (defun gnus-random-x-face ()
45   "Insert a random X-Face header from `gnus-x-face-directory'."
46   (interactive)
47   (when (file-exists-p gnus-x-face-directory)
48     (let* ((files (directory-files gnus-x-face-directory t "\\.pbm$"))
49            (file (nth (random (length files)) files)))
50       (when file
51         (shell-command-to-string
52          (format gnus-convert-pbm-to-x-face-command file))))))
53
54 ;;;###autoload
55 (defun gnus-x-face-from-file (file)
56   "Insert an X-Face header based on an image file."
57   (interactive "fImage file name:" )
58   (when (file-exists-p file)
59     (shell-command-to-string
60      (format gnus-convert-image-to-x-face-command file))))
61     
62
63 (provide 'gnus-fun)
64
65 ;;; gnus-fun.el ends here