Function: imagemagick-register-types

imagemagick-register-types is an autoloaded and byte-compiled function defined in image.el.gz.

Signature

(imagemagick-register-types)

Documentation

Register file types that can be handled by ImageMagick.

This function is called at startup, after loading the init file. It registers the ImageMagick types returned by imagemagick-filter-types.

Registered image types are added to auto-mode-alist, so that Emacs visits them in Image mode. They are also added to image-type-file-name-regexps, so that the image-type(var)/image-type(fun) function recognizes these files as having image type imagemagick.

If Emacs is compiled without ImageMagick support, this does nothing.

Probably introduced at or before Emacs version 24.1.

Source Code

;; Defined in /usr/src/emacs/lisp/image.el.gz
;;;###autoload
(defun imagemagick-register-types ()
  "Register file types that can be handled by ImageMagick.
This function is called at startup, after loading the init file.
It registers the ImageMagick types returned by `imagemagick-filter-types'.

Registered image types are added to `auto-mode-alist', so that
Emacs visits them in Image mode.  They are also added to
`image-type-file-name-regexps', so that the `image-type' function
recognizes these files as having image type `imagemagick'.

If Emacs is compiled without ImageMagick support, this does nothing."
  (when (fboundp 'imagemagick-types)
    (let* ((types (mapcar (lambda (type) (downcase (symbol-name type)))
			  (imagemagick-filter-types)))
	   (re (if types (concat "\\." (regexp-opt types) "\\'")))
	   (ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
				 auto-mode-alist)))
	   (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick)
				   image-type-file-name-regexps))))
      (if (not re)
	  (setq auto-mode-alist (delete ama-elt auto-mode-alist)
		image-type-file-name-regexps
		(delete itfnr-elt image-type-file-name-regexps))
	(if ama-elt
	    (setcar ama-elt re)
	  (push (cons re 'image-mode) auto-mode-alist))
	(if itfnr-elt
	    (setcar itfnr-elt re)
	  ;; Append to `image-type-file-name-regexps', so that we
	  ;; preferentially use specialized image libraries.
	  (add-to-list 'image-type-file-name-regexps
	               (cons re 'imagemagick) t)))
      (setq imagemagick--file-regexp re))))