diff options
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/image.el | 57 |
3 files changed, 35 insertions, 29 deletions
| @@ -68,7 +68,9 @@ ImageMagick to view images. You must call imagemagick-register-types | |||
| 68 | afterwards if you do not use customize to change this. | 68 | afterwards 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 |
| 71 | ImageMagick types are treated as images. | 71 | ImageMagick types are treated as images. The function |
| 72 | `imagemagick-filter-types' returns the list of types that will be | ||
| 73 | treated 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 |
| 74 | frames, if emacsclient is only told to open a new frame without | 76 | frames, 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. | ||
| 695 | This is the result of `imagemagick-types', including only elements | ||
| 696 | that 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. |
| 692 | This is the extension installed into `auto-mode-alist' and | 718 | This 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. |
| 701 | This function is called at startup, after loading the init file. | 724 | This function is called at startup, after loading the init file. |
| 702 | It registers the ImageMagick types returned by `imagemagick-types', | 725 | It registers the ImageMagick types returned by `imagemagick-filter-types'. |
| 703 | including only those from `imagemagick-types-enable', and excluding | ||
| 704 | those from `imagemagick-types-inhibit'. | ||
| 705 | 726 | ||
| 706 | Registered image types are added to `auto-mode-alist', so that | 727 | Registered image types are added to `auto-mode-alist', so that |
| 707 | Emacs visits them in Image mode. They are also added to | 728 | Emacs visits them in Image mode. They are also added to |
| @@ -710,27 +731,9 @@ recognizes these files as having image type `imagemagick'. | |||
| 710 | 731 | ||
| 711 | If Emacs is compiled without ImageMagick support, this does nothing." | 732 | If 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) |