aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/image.el
diff options
context:
space:
mode:
authorJoakim Verona2012-05-31 20:08:56 +0200
committerJoakim Verona2012-05-31 20:08:56 +0200
commit5259b41aab32e82ff06d977877f2e456541b3c0b (patch)
treedb8ef83b4175e69cd8b23cb25febad793a3962a9 /lisp/image.el
parentfc1f1f2ea1ceac41f81855e14a490db107d88681 (diff)
parent43f5c7ae53b9afbda100ec26758ff0fb3eadfb48 (diff)
downloademacs-5259b41aab32e82ff06d977877f2e456541b3c0b.tar.gz
emacs-5259b41aab32e82ff06d977877f2e456541b3c0b.zip
upstream
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el57
1 files changed, 30 insertions, 27 deletions
diff --git a/lisp/image.el b/lisp/image.el
index 9da6085ee14..e5357742769 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -687,21 +687,42 @@ The minimum delay between successive frames is 0.01s."
687 image n count time-elapsed limit)))) 687 image n count time-elapsed limit))))
688 688
689 689
690(defvar imagemagick-types-inhibit)
691(defvar imagemagick-types-enable)
692
693(defun imagemagick-filter-types ()
694 "Return a list of the ImageMagick types to be treated as images, or nil.
695This is the result of `imagemagick-types', including only elements
696that match `imagemagick-types-enable' and do not match
697`imagemagick-types-inhibit'."
698 (when (fboundp 'imagemagick-types)
699 (cond ((null imagemagick-types-enable) nil)
700 ((eq imagemagick-types-inhibit t) nil)
701 (t
702 (delq nil
703 (mapcar
704 (lambda (type)
705 (unless (memq type imagemagick-types-inhibit)
706 (if (eq imagemagick-types-enable t) type
707 (catch 'found
708 (dolist (enable imagemagick-types-enable nil)
709 (if (cond ((symbolp enable) (eq enable type))
710 ((stringp enable)
711 (string-match enable
712 (symbol-name type))))
713 (throw 'found type)))))))
714 (imagemagick-types)))))))
715
690(defvar imagemagick--file-regexp nil 716(defvar imagemagick--file-regexp nil
691 "File extension regexp for ImageMagick files, if any. 717 "File extension regexp for ImageMagick files, if any.
692This is the extension installed into `auto-mode-alist' and 718This is the extension installed into `auto-mode-alist' and
693`image-type-file-name-regexps' by `imagemagick-register-types'.") 719`image-type-file-name-regexps' by `imagemagick-register-types'.")
694 720
695(defvar imagemagick-types-inhibit)
696(defvar imagemagick-types-enable)
697
698;;;###autoload 721;;;###autoload
699(defun imagemagick-register-types () 722(defun imagemagick-register-types ()
700 "Register file types that can be handled by ImageMagick. 723 "Register file types that can be handled by ImageMagick.
701This function is called at startup, after loading the init file. 724This function is called at startup, after loading the init file.
702It registers the ImageMagick types returned by `imagemagick-types', 725It registers the ImageMagick types returned by `imagemagick-filter-types'.
703including only those from `imagemagick-types-enable', and excluding
704those from `imagemagick-types-inhibit'.
705 726
706Registered image types are added to `auto-mode-alist', so that 727Registered image types are added to `auto-mode-alist', so that
707Emacs visits them in Image mode. They are also added to 728Emacs visits them in Image mode. They are also added to
@@ -710,27 +731,9 @@ recognizes these files as having image type `imagemagick'.
710 731
711If Emacs is compiled without ImageMagick support, this does nothing." 732If Emacs is compiled without ImageMagick support, this does nothing."
712 (when (fboundp 'imagemagick-types) 733 (when (fboundp 'imagemagick-types)
713 (let* ((include 734 (let* ((types (mapcar (lambda (type) (downcase (symbol-name type)))
714 (cond ((null imagemagick-types-enable) nil) 735 (imagemagick-filter-types)))
715 ((eq imagemagick-types-inhibit t) nil) 736 (re (if types (concat "\\." (regexp-opt types) "\\'")))
716 ((eq imagemagick-types-enable t) (imagemagick-types))
717 (t
718 (delq nil
719 (mapcar
720 (lambda (type)
721 (catch 'found
722 (dolist (enable imagemagick-types-enable nil)
723 (if (cond ((symbolp enable) (eq enable type))
724 ((stringp enable)
725 (string-match enable
726 (symbol-name type))))
727 (throw 'found type)))))
728 (imagemagick-types))))))
729 (re (let (types)
730 (dolist (type include)
731 (unless (memq type imagemagick-types-inhibit)
732 (push (downcase (symbol-name type)) types)))
733 (if types (concat "\\." (regexp-opt types) "\\'"))))
734 (ama-elt (car (member (cons imagemagick--file-regexp 'image-mode) 737 (ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
735 auto-mode-alist))) 738 auto-mode-alist)))
736 (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick) 739 (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick)