aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2012-05-31 20:08:56 +0200
committerJoakim Verona2012-05-31 20:08:56 +0200
commit5259b41aab32e82ff06d977877f2e456541b3c0b (patch)
treedb8ef83b4175e69cd8b23cb25febad793a3962a9
parentfc1f1f2ea1ceac41f81855e14a490db107d88681 (diff)
parent43f5c7ae53b9afbda100ec26758ff0fb3eadfb48 (diff)
downloademacs-5259b41aab32e82ff06d977877f2e456541b3c0b.tar.gz
emacs-5259b41aab32e82ff06d977877f2e456541b3c0b.zip
upstream
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/image.el57
3 files changed, 35 insertions, 29 deletions
diff --git a/etc/NEWS b/etc/NEWS
index ff662a70c1c..f152228ec96 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -68,7 +68,9 @@ ImageMagick to view images. You must call imagemagick-register-types
68afterwards if you do not use customize to change this. 68afterwards if you do not use customize to change this.
69 69
70*** The new variable `imagemagick-types-enable' also affects which 70*** The new variable `imagemagick-types-enable' also affects which
71ImageMagick types are treated as images. 71ImageMagick types are treated as images. The function
72`imagemagick-filter-types' returns the list of types that will be
73treated as images.
72 74
73** String values for `initial-buffer-choice' also apply to emacsclient 75** String values for `initial-buffer-choice' also apply to emacsclient
74frames, if emacsclient is only told to open a new frame without 76frames, if emacsclient is only told to open a new frame without
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c2c6e0da37b..b70008fb821 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,7 +3,8 @@
3 * image.el: For clarity, call imagemagick-register-types at 3 * image.el: For clarity, call imagemagick-register-types at
4 top-level, rather than relying on a custom :initialize. 4 top-level, rather than relying on a custom :initialize.
5 (imagemagick-types-enable): New option. (Bug#11557) 5 (imagemagick-types-enable): New option. (Bug#11557)
6 (imagemagick-register-types): Respect imagemagick-types-inhibit. 6 (imagemagick-filter-types): New function. (Bug#7406)
7 (imagemagick-register-types): Use imagemagick-filter-types.
7 If disabling support, remove elements altogether rather 8 If disabling support, remove elements altogether rather
8 than using an impossible regexp. 9 than using an impossible regexp.
9 (imagemagick-types-inhibit): Give it the default init function. 10 (imagemagick-types-inhibit): Give it the default init function.
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)