-(defun gnus-add-minor-mode (mode name map)
- (if (fboundp 'add-minor-mode)
- (add-minor-mode mode name map)
- (set (make-local-variable mode) t)
- (unless (assq mode minor-mode-alist)
- (push `(,mode ,name) minor-mode-alist))
- (unless (assq mode minor-mode-map-alist)
- (push (cons mode map)
- minor-mode-map-alist))))
-
-(defun gnus-x-splash ()
- "Show a splash screen using a pixmap in the current buffer."
- (let ((dir (nnheader-find-etc-directory "gnus"))
- pixmap file height beg i)
- (save-excursion
- (switch-to-buffer (gnus-get-buffer-create gnus-group-buffer))
- (let ((buffer-read-only nil))
- (erase-buffer)
- (when (and dir
- (file-exists-p (setq file (concat dir "x-splash"))))
- (with-temp-buffer
- (insert-file-contents file)
- (goto-char (point-min))
- (ignore-errors
- (setq pixmap (read (current-buffer))))))
- (when pixmap
- (unless (facep 'gnus-splash)
- (make-face 'gnus-splash))
- (setq height (/ (car pixmap) (frame-char-height))
- width (/ (cadr pixmap) (frame-char-width)))
- (set-face-foreground 'gnus-splash "Brown")
- (set-face-stipple 'gnus-splash pixmap)
- (insert-char ?\n (* (/ (window-height) 2 height) height))
- (setq i height)
- (while (> i 0)
- (insert-char ? (* (/ (window-width) 2 width) width))
- (setq beg (point))
- (insert-char ? width)
- (set-text-properties beg (point) '(face gnus-splash))
- (insert "\n")
- (decf i))
- (goto-char (point-min))
- (sit-for 0))))))
-
-(defun gnus-article-display-xface (beg end)
- "Display an XFace header from between BEG and END in the current article.
-This requires support for XPM or XBM images in your Emacs and the
-external programs `uncompface', `icontopbm' and either `ppmtoxpm' (for
-XPM support) or `ppmtoxbm' (for XBM support). On a GNU/Linux system
-these might be in packages with names like `compface' or `faces-xface'
-and `netpbm' or `libgr-progs', for instance.
-
-This function is for Emacs 21+. See `gnus-xmas-article-display-xface'
-for XEmacs."
- (save-excursion
- (let ((cur (current-buffer))
- image type)
- (when (and (fboundp 'image-type-available-p)
- (cond ((image-type-available-p 'xpm) (setq type 'xpm))
- ((image-type-available-p 'xbm) (setq type 'xbm))))
- (with-temp-buffer
- (insert-buffer-substring cur beg end)
- (call-process-region (point-min) (point-max) "uncompface"
- 'delete '(t nil))
- (goto-char (point-min))
- (insert "/* Width=48, Height=48 */\n")
- (and (eq 0 (call-process-region (point-min) (point-max) "icontopbm"
- 'delete '(t nil)))
- (eq 0 (call-process-region (point-min) (point-max)
- (if (eq type 'xpm)
- "ppmtoxpm"
- "pbmtoxbm")
- 'delete '(t nil)))
- (setq image (create-image (buffer-string) type t))))
- (when image
- (goto-char (point-min))
- (re-search-forward "^From:" nil 'move)
- (insert-image image " "))))))
+(defun gnus-mark-active-p ()
+ "Non-nil means the mark and region are currently active in this buffer."
+ mark-active) ; aliased to region-exists-p in XEmacs.
+
+(autoload 'gnus-alive-p "gnus-util")
+(autoload 'mm-disable-multibyte "mm-util")
+
+;;; Image functions.
+
+(defun gnus-image-type-available-p (type)
+ (and (fboundp 'image-type-available-p)
+ (if (fboundp 'display-images-p)
+ (display-images-p)
+ t)
+ (image-type-available-p type)))
+
+(defun gnus-create-image (file &optional type data-p &rest props)
+ (let ((face (plist-get props :face)))
+ (when face
+ (setq props (plist-put props :foreground (face-foreground face)))
+ (setq props (plist-put props :background (face-background face))))
+ (ignore-errors
+ (apply 'create-image file type data-p props))))
+
+(defun gnus-put-image (glyph &optional string category)
+ (let ((point (point)))
+ (insert-image glyph (or string " "))
+ (put-text-property point (point) 'gnus-image-category category)
+ (unless string
+ (put-text-property (1- (point)) (point)
+ 'gnus-image-text-deletable t))
+ glyph))
+
+(defun gnus-remove-image (image &optional category)
+ "Remove the image matching IMAGE and CATEGORY found first."
+ (let ((start (point-min))
+ val end)
+ (while (and (not end)
+ (or (setq val (get-text-property start 'display))
+ (and (setq start
+ (next-single-property-change start 'display))
+ (setq val (get-text-property start 'display)))))
+ (setq end (or (next-single-property-change start 'display)
+ (point-max)))
+ (if (and (equal val image)
+ (equal (get-text-property start 'gnus-image-category)
+ category))
+ (progn
+ (put-text-property start end 'display nil)
+ (when (get-text-property start 'gnus-image-text-deletable)
+ (delete-region start end)))
+ (unless (= end (point-max))
+ (setq start end
+ end nil))))))
+
+(defmacro gnus-string-mark-left-to-right (string)
+ (if (fboundp 'bidi-string-mark-left-to-right)
+ `(bidi-string-mark-left-to-right ,string)
+ string))