(defmacro with-no-warnings (&rest body)
`(progn ,@body))))
-(defcustom gnus-completing-read-function
- #'gnus-std-completing-read
- "Function to do a completing read."
+(defcustom gnus-completing-read-function 'gnus-emacs-completing-read
+ "Function use to do completing read."
+ :version "24.1"
:group 'gnus-meta
- :type `(radio (function-item
- :doc "Use Emacs' standard `completing-read' function."
- gnus-std-completing-read)
- ,@(unless (featurep 'xemacs)
- '((function-item
- :doc "Use iswitchb's completing-read function."
- gnus-icompleting-read)
- (function-item
- :doc "Use ido's completing-read function."
- gnus-ido-completing-read)))
- (function)))
+ :type '(radio (function-item
+ :doc "Use Emacs standard `completing-read' function."
+ gnus-emacs-completing-read)
+ (function-item
+ :doc "Use `ido-completing-read' function."
+ gnus-ido-completing-read)
+ (function-item
+ :doc "Use iswitchb based completing-read function."
+ gnus-iswitchb-completing-read)))
(defcustom gnus-completion-styles
(if (and (boundp 'completion-styles-alist)
;; XEmacs. In Emacs we don't need to call `make-local-hook' first.
;; It's harmless, though, so the main purpose of this alias is to shut
;; up the byte compiler.
-(defalias 'gnus-make-local-hook
- (if (eq (get 'make-local-hook 'byte-compile)
- 'byte-compile-obsolete)
- 'ignore ; Emacs
- 'make-local-hook)) ; XEmacs
+(defalias 'gnus-make-local-hook (if (featurep 'xemacs)
+ 'make-local-hook
+ 'ignore))
(defun gnus-delete-first (elt list)
"Delete by side effect the first occurrence of ELT as a member of LIST."
`(,(car spec) ,@(mapcar 'gnus-make-predicate-1 (cdr spec)))
(error "Invalid predicate specifier: %s" spec)))))
-(defun gnus-std-completing-read (prompt collection &optional require-match
- initial-input history def)
- (completing-read prompt collection nil require-match
- initial-input history def))
+(defun gnus-completing-read (prompt collection &optional require-match
+ initial-input history def)
+ "Call `gnus-completing-read-function'."
+ (funcall gnus-completing-read-function
+ (concat prompt (when def
+ (concat " (default " def ")"))
+ ": ")
+ collection require-match initial-input history def))
+
+(defun gnus-emacs-completing-read (prompt collection &optional require-match
+ initial-input history def)
+ "Call standard `completing-read-function'."
+ (let ((completion-styles gnus-completion-styles))
+ (completing-read prompt collection nil require-match initial-input history def)))
-(defvar iswitchb-mode)
-(defvar iswitchb-temp-buflist)
-(declare-function iswitchb-read-buffer "iswitchb"
- (prompt &optional default require-match start matches-set))
+(defun gnus-ido-completing-read (prompt collection &optional require-match
+ initial-input history def)
+ "Call `ido-completing-read-function'."
+ (require 'ido)
+ (ido-completing-read prompt collection nil require-match initial-input history def))
-(defun gnus-icompleting-read (prompt collection &optional require-match
- initial-input history def)
+(defun gnus-iswitchb-completing-read (prompt collection &optional require-match
+ initial-input history def)
+ "`iswitchb' based completing-read function."
(require 'iswitchb)
(let ((iswitchb-make-buflist-hook
(lambda ()
(setq iswitchb-temp-buflist
- (let ((choices (append (list)
- (when initial-input (list initial-input))
- (symbol-value history) collection))
+ (let ((choices (append
+ (when initial-input (list initial-input))
+ (symbol-value history) collection))
filtered-choices)
- (while choices
- (when (and (car choices) (not (member (car choices) filtered-choices)))
- (setq filtered-choices (cons (car choices) filtered-choices)))
- (setq choices (cdr choices)))
+ (dolist (x choices)
+ (setq filtered-choices (adjoin x filtered-choices)))
(nreverse filtered-choices))))))
(unwind-protect
(progn
(when (not iswitchb-mode)
(remove-hook 'minibuffer-setup-hook 'iswitchb-minibuffer-setup)))))
-(defun gnus-ido-completing-read (prompt collection &optional require-match
- initial-input history def)
- (require 'ido)
- (ido-completing-read prompt collection nil require-match
- initial-input history def))
-
-(defun gnus-completing-read (prompt collection &optional require-match
- initial-input history def)
- "Do a completing read with the configured `gnus-completing-read-function'."
- (let ((completion-styles gnus-completion-styles))
- (funcall
- gnus-completing-read-function
- (concat prompt (when def
- (concat " (default " def ")"))
- ": ")
- collection require-match initial-input history def)))
-
(defun gnus-graphic-display-p ()
(if (featurep 'xemacs)
(device-on-window-system-p)
(get-char-table ,character ,display-table)))
`(aref ,display-table ,character)))
+(defun gnus-rescale-image (image size)
+ "Rescale IMAGE to SIZE if possible.
+SIZE is in format (WIDTH . HEIGHT). Return a new image.
+Sizes are in pixels."
+ (if (or (not (fboundp 'imagemagick-types))
+ (not (get-buffer-window (current-buffer))))
+ image
+ (let ((new-width (car size))
+ (new-height (cdr size)))
+ (when (> (cdr (image-size image t)) new-height)
+ (setq image (or (create-image (plist-get (cdr image) :data) 'imagemagick t
+ :height new-height)
+ image)))
+ (when (> (car (image-size image t)) new-width)
+ (setq image (or
+ (create-image (plist-get (cdr image) :data) 'imagemagick t
+ :width new-width)
+ image)))
+ image)))
+
(provide 'gnus-util)
;;; gnus-util.el ends here