diff options
| author | Glenn Morris | 2012-05-31 00:22:33 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-05-31 00:22:33 -0700 |
| commit | 32d72c2f5d7554ee2f1d37bb8aa210ee07165f25 (patch) | |
| tree | 062e0193098ce370be6f7cfb59cb247b89e9088a | |
| parent | ca34e0be92d5e715c5d65b990917d2ecd15da318 (diff) | |
| download | emacs-32d72c2f5d7554ee2f1d37bb8aa210ee07165f25.tar.gz emacs-32d72c2f5d7554ee2f1d37bb8aa210ee07165f25.zip | |
Add option imagemagick-types-enable
* lisp/image.el: For clarity, call imagemagick-register-types at
top-level, rather than relying on a custom :initialize.
(imagemagick-types-enable): New option.
(imagemagick-register-types): Respect imagemagick-types-inhibit.
If disabling support, remove elements altogether rather
than using an impossible regexp.
(imagemagick-types-inhibit): Give it the default init function.
* src/image.c (Fimagemagick_types): Doc fix.
* etc/NEWS: Mention this.
Fixes: debbugs:11557
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/image.el | 96 | ||||
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/image.c | 6 |
5 files changed, 98 insertions, 24 deletions
| @@ -60,12 +60,16 @@ name, group names known to the system (where possible). | |||
| 60 | ** ImageMagick support, if available, is automatically enabled. | 60 | ** ImageMagick support, if available, is automatically enabled. |
| 61 | It is no longer necessary to call `imagemagick-register-types' | 61 | It is no longer necessary to call `imagemagick-register-types' |
| 62 | explicitly to install ImageMagick image types; that function is called | 62 | explicitly to install ImageMagick image types; that function is called |
| 63 | automatically at startup or when customizing `imagemagick-types-inhibit'. | 63 | automatically at startup, or when customizing imagemagick-types-enable |
| 64 | or imagemagick-types-inhibit. | ||
| 64 | 65 | ||
| 65 | *** Setting `imagemagick-types-inhibit' to t now disables the use of | 66 | *** Setting `imagemagick-types-inhibit' to t now disables the use of |
| 66 | ImageMagick to view images. You must call imagemagick-register-types | 67 | ImageMagick to view images. You must call imagemagick-register-types |
| 67 | afterwards if you do not use customize to change this. | 68 | afterwards if you do not use customize to change this. |
| 68 | 69 | ||
| 70 | *** The new variable `imagemagick-types-enable' also affects which | ||
| 71 | ImageMagick types are treated as images. | ||
| 72 | |||
| 69 | ** String values for `initial-buffer-choice' also apply to emacsclient | 73 | ** String values for `initial-buffer-choice' also apply to emacsclient |
| 70 | frames, if emacsclient is only told to open a new frame without | 74 | frames, if emacsclient is only told to open a new frame without |
| 71 | specifying any file to visit or expression to evaluate. | 75 | specifying any file to visit or expression to evaluate. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f60fcb0b14d..c2c6e0da37b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-05-31 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * image.el: For clarity, call imagemagick-register-types at | ||
| 4 | top-level, rather than relying on a custom :initialize. | ||
| 5 | (imagemagick-types-enable): New option. (Bug#11557) | ||
| 6 | (imagemagick-register-types): Respect imagemagick-types-inhibit. | ||
| 7 | If disabling support, remove elements altogether rather | ||
| 8 | than using an impossible regexp. | ||
| 9 | (imagemagick-types-inhibit): Give it the default init function. | ||
| 10 | |||
| 1 | 2012-05-31 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2012-05-31 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-fix-header): Handle | 13 | * emacs-lisp/bytecomp.el (byte-compile-fix-header): Handle |
diff --git a/lisp/image.el b/lisp/image.el index 087cd148dd6..9da6085ee14 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -692,38 +692,59 @@ The minimum delay between successive frames is 0.01s." | |||
| 692 | This is the extension installed into `auto-mode-alist' and | 692 | This is the extension installed into `auto-mode-alist' and |
| 693 | `image-type-file-name-regexps' by `imagemagick-register-types'.") | 693 | `image-type-file-name-regexps' by `imagemagick-register-types'.") |
| 694 | 694 | ||
| 695 | (defvar imagemagick-types-inhibit) | ||
| 696 | (defvar imagemagick-types-enable) | ||
| 697 | |||
| 695 | ;;;###autoload | 698 | ;;;###autoload |
| 696 | (defun imagemagick-register-types () | 699 | (defun imagemagick-register-types () |
| 697 | "Register file types that can be handled by ImageMagick. | 700 | "Register file types that can be handled by ImageMagick. |
| 698 | This function is called at startup, after loading the init file. | 701 | This function is called at startup, after loading the init file. |
| 699 | It registers the ImageMagick types listed in `imagemagick-types', | 702 | It registers the ImageMagick types returned by `imagemagick-types', |
| 700 | excluding those listed in `imagemagick-types-inhibit'. | 703 | including only those from `imagemagick-types-enable', and excluding |
| 704 | those from `imagemagick-types-inhibit'. | ||
| 701 | 705 | ||
| 702 | Registered image types are added to `auto-mode-alist', so that | 706 | Registered image types are added to `auto-mode-alist', so that |
| 703 | Emacs visits them in Image mode. They are also added to | 707 | Emacs visits them in Image mode. They are also added to |
| 704 | `image-type-file-name-regexps', so that the `image-type' function | 708 | `image-type-file-name-regexps', so that the `image-type' function |
| 705 | recognizes these files as having image type `imagemagick'. | 709 | recognizes these files as having image type `imagemagick'. |
| 706 | 710 | ||
| 707 | If Emacs is compiled without ImageMagick support, do nothing." | 711 | If Emacs is compiled without ImageMagick support, this does nothing." |
| 708 | (when (fboundp 'imagemagick-types) | 712 | (when (fboundp 'imagemagick-types) |
| 709 | (let ((re (if (eq imagemagick-types-inhibit t) | 713 | (let* ((include |
| 710 | ;; Use a bogus regexp to inhibit matches. | 714 | (cond ((null imagemagick-types-enable) nil) |
| 711 | "\\'a" | 715 | ((eq imagemagick-types-inhibit t) nil) |
| 712 | (let ((types)) | 716 | ((eq imagemagick-types-enable t) (imagemagick-types)) |
| 713 | (dolist (type (imagemagick-types)) | 717 | (t |
| 714 | (unless (memq type imagemagick-types-inhibit) | 718 | (delq nil |
| 715 | (push (downcase (symbol-name type)) types))) | 719 | (mapcar |
| 716 | (concat "\\." (regexp-opt types) "\\'")))) | 720 | (lambda (type) |
| 717 | (ama-elt (car (member (cons imagemagick--file-regexp 'image-mode) | 721 | (catch 'found |
| 718 | auto-mode-alist))) | 722 | (dolist (enable imagemagick-types-enable nil) |
| 719 | (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick) | 723 | (if (cond ((symbolp enable) (eq enable type)) |
| 720 | image-type-file-name-regexps)))) | 724 | ((stringp enable) |
| 721 | (if ama-elt | 725 | (string-match enable |
| 722 | (setcar ama-elt re) | 726 | (symbol-name type)))) |
| 723 | (push (cons re 'image-mode) auto-mode-alist)) | 727 | (throw 'found type))))) |
| 724 | (if itfnr-elt | 728 | (imagemagick-types)))))) |
| 725 | (setcar itfnr-elt re) | 729 | (re (let (types) |
| 726 | (push (cons re 'imagemagick) image-type-file-name-regexps)) | 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) | ||
| 735 | auto-mode-alist))) | ||
| 736 | (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick) | ||
| 737 | image-type-file-name-regexps)))) | ||
| 738 | (if (not re) | ||
| 739 | (setq auto-mode-alist (delete ama-elt auto-mode-alist) | ||
| 740 | image-type-file-name-regexps | ||
| 741 | (delete itfnr-elt image-type-file-name-regexps)) | ||
| 742 | (if ama-elt | ||
| 743 | (setcar ama-elt re) | ||
| 744 | (push (cons re 'image-mode) auto-mode-alist)) | ||
| 745 | (if itfnr-elt | ||
| 746 | (setcar itfnr-elt re) | ||
| 747 | (push (cons re 'imagemagick) image-type-file-name-regexps))) | ||
| 727 | (setq imagemagick--file-regexp re)))) | 748 | (setq imagemagick--file-regexp re)))) |
| 728 | 749 | ||
| 729 | (defcustom imagemagick-types-inhibit | 750 | (defcustom imagemagick-types-inhibit |
| @@ -743,12 +764,45 @@ has no effect." | |||
| 743 | :type '(choice (const :tag "Support all ImageMagick types" nil) | 764 | :type '(choice (const :tag "Support all ImageMagick types" nil) |
| 744 | (const :tag "Disable all ImageMagick types" t) | 765 | (const :tag "Disable all ImageMagick types" t) |
| 745 | (repeat symbol)) | 766 | (repeat symbol)) |
| 767 | :initialize 'custom-initialize-default | ||
| 746 | :set (lambda (symbol value) | 768 | :set (lambda (symbol value) |
| 747 | (set-default symbol value) | 769 | (set-default symbol value) |
| 748 | (imagemagick-register-types)) | 770 | (imagemagick-register-types)) |
| 749 | :version "24.1" | 771 | :version "24.1" |
| 750 | :group 'image) | 772 | :group 'image) |
| 751 | 773 | ||
| 774 | (defcustom imagemagick-types-enable | ||
| 775 | '("\\`BMP" DJVU "\\`GIF" "\\`ICO" "P?JPE?G" "P[BNP]M" | ||
| 776 | "\\`[MP]NG" "\\`TIFF") | ||
| 777 | "List of ImageMagick types to treat as images. | ||
| 778 | The list elements are either strings or symbols, and represent | ||
| 779 | types returned by `imagemagick-types'. A string is a regexp that | ||
| 780 | selects all types matching the regexp. | ||
| 781 | |||
| 782 | The value may also be t, meaning all the types that ImageMagick | ||
| 783 | supports; or nil, meaning no types. | ||
| 784 | |||
| 785 | The variable `imagemagick-types-inhibit' overrides this variable. | ||
| 786 | |||
| 787 | If you change this without using customize, you must call | ||
| 788 | `imagemagick-register-types' afterwards. | ||
| 789 | |||
| 790 | If Emacs is compiled without ImageMagick support, this variable | ||
| 791 | has no effect." | ||
| 792 | :type '(choice (const :tag "Support all ImageMagick types" t) | ||
| 793 | (const :tag "Disable all ImageMagick types" nil) | ||
| 794 | (repeat :tag "List of types" | ||
| 795 | (choice (symbol :tag "type") | ||
| 796 | (regexp :tag "regexp")))) | ||
| 797 | :initialize 'custom-initialize-default | ||
| 798 | :set (lambda (symbol value) | ||
| 799 | (set-default symbol value) | ||
| 800 | (imagemagick-register-types)) | ||
| 801 | :version "24.2" | ||
| 802 | :group 'image) | ||
| 803 | |||
| 804 | (imagemagick-register-types) | ||
| 805 | |||
| 752 | (provide 'image) | 806 | (provide 'image) |
| 753 | 807 | ||
| 754 | ;;; image.el ends here | 808 | ;;; image.el ends here |
diff --git a/src/ChangeLog b/src/ChangeLog index 67c100600fa..6d71346dd78 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -63,6 +63,10 @@ | |||
| 63 | and not pointers. | 63 | and not pointers. |
| 64 | * lisp.h (__executable_start): New decl. | 64 | * lisp.h (__executable_start): New decl. |
| 65 | 65 | ||
| 66 | 2012-05-31 Glenn Morris <rgm@gnu.org> | ||
| 67 | |||
| 68 | * image.c (Fimagemagick_types): Doc fix. | ||
| 69 | |||
| 66 | 2012-05-30 Jim Meyering <meyering@redhat.com> | 70 | 2012-05-30 Jim Meyering <meyering@redhat.com> |
| 67 | 71 | ||
| 68 | * callproc.c (Fcall_process_region): Include directory component | 72 | * callproc.c (Fcall_process_region): Include directory component |
diff --git a/src/image.c b/src/image.c index a3b64b74997..b6cdb6c8290 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* Functions for image support on window system. | 1 | /* Functions for image support on window system. |
| 2 | Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc. | 2 | |
| 3 | Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc. | ||
| 3 | 4 | ||
| 4 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| 5 | 6 | ||
| @@ -7987,7 +7988,8 @@ their descriptions (http://www.imagemagick.org/script/formats.php). | |||
| 7987 | You can also try the shell command: `identify -list format'. | 7988 | You can also try the shell command: `identify -list format'. |
| 7988 | 7989 | ||
| 7989 | Note that ImageMagick recognizes many file-types that Emacs does not | 7990 | Note that ImageMagick recognizes many file-types that Emacs does not |
| 7990 | recognize as images, such as C. See `imagemagick-types-inhibit'. */) | 7991 | recognize as images, such as C. See `imagemagick-types-enable' |
| 7992 | and `imagemagick-types-inhibit'. */) | ||
| 7991 | (void) | 7993 | (void) |
| 7992 | { | 7994 | { |
| 7993 | Lisp_Object typelist = Qnil; | 7995 | Lisp_Object typelist = Qnil; |