aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorGlenn Morris2012-05-31 13:14:46 -0400
committerGlenn Morris2012-05-31 13:14:46 -0400
commit60b5f1870c11723a9ee7055656bb3e3c848b86fb (patch)
tree638999ad8cdd595d6feafb14a2481f30bb3836bb /lisp
parent32d72c2f5d7554ee2f1d37bb8aa210ee07165f25 (diff)
downloademacs-60b5f1870c11723a9ee7055656bb3e3c848b86fb.tar.gz
emacs-60b5f1870c11723a9ee7055656bb3e3c848b86fb.zip
Split off imagemagick-filter-types from imagemagick-register-types
* lisp/image.el: (imagemagick-filter-types): New function. (Bug#7406) (imagemagick-register-types): Use imagemagick-filter-types. * etc/NEWS: Mention this.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/image.el56
2 files changed, 31 insertions, 28 deletions
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..394d44c21e9 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -687,21 +687,41 @@ 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 ((eq imagemagick-types-enable t) (imagemagick-types))
702 (t
703 (delq nil
704 (mapcar
705 (lambda (type)
706 (unless (memq type imagemagick-types-inhibit)
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 (symbol-name type))))
712 (throw 'found type))))))
713 (imagemagick-types)))))))
714
690(defvar imagemagick--file-regexp nil 715(defvar imagemagick--file-regexp nil
691 "File extension regexp for ImageMagick files, if any. 716 "File extension regexp for ImageMagick files, if any.
692This is the extension installed into `auto-mode-alist' and 717This is the extension installed into `auto-mode-alist' and
693`image-type-file-name-regexps' by `imagemagick-register-types'.") 718`image-type-file-name-regexps' by `imagemagick-register-types'.")
694 719
695(defvar imagemagick-types-inhibit)
696(defvar imagemagick-types-enable)
697
698;;;###autoload 720;;;###autoload
699(defun imagemagick-register-types () 721(defun imagemagick-register-types ()
700 "Register file types that can be handled by ImageMagick. 722 "Register file types that can be handled by ImageMagick.
701This function is called at startup, after loading the init file. 723This function is called at startup, after loading the init file.
702It registers the ImageMagick types returned by `imagemagick-types', 724It registers the ImageMagick types returned by `imagemagick-filter-types'.
703including only those from `imagemagick-types-enable', and excluding
704those from `imagemagick-types-inhibit'.
705 725
706Registered image types are added to `auto-mode-alist', so that 726Registered image types are added to `auto-mode-alist', so that
707Emacs visits them in Image mode. They are also added to 727Emacs visits them in Image mode. They are also added to
@@ -710,27 +730,9 @@ recognizes these files as having image type `imagemagick'.
710 730
711If Emacs is compiled without ImageMagick support, this does nothing." 731If Emacs is compiled without ImageMagick support, this does nothing."
712 (when (fboundp 'imagemagick-types) 732 (when (fboundp 'imagemagick-types)
713 (let* ((include 733 (let* ((types (mapcar (lambda (type) (downcase (symbol-name type)))
714 (cond ((null imagemagick-types-enable) nil) 734 (imagemagick-filter-types)))
715 ((eq imagemagick-types-inhibit t) nil) 735 (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) 736 (ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
735 auto-mode-alist))) 737 auto-mode-alist)))
736 (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick) 738 (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick)