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
This commit is contained in:
6
etc/NEWS
6
etc/NEWS
@@ -60,12 +60,16 @@ name, group names known to the system (where possible).
|
||||
** ImageMagick support, if available, is automatically enabled.
|
||||
It is no longer necessary to call `imagemagick-register-types'
|
||||
explicitly to install ImageMagick image types; that function is called
|
||||
automatically at startup or when customizing `imagemagick-types-inhibit'.
|
||||
automatically at startup, or when customizing imagemagick-types-enable
|
||||
or imagemagick-types-inhibit.
|
||||
|
||||
*** Setting `imagemagick-types-inhibit' to t now disables the use of
|
||||
ImageMagick to view images. You must call imagemagick-register-types
|
||||
afterwards if you do not use customize to change this.
|
||||
|
||||
*** The new variable `imagemagick-types-enable' also affects which
|
||||
ImageMagick types are treated as images.
|
||||
|
||||
** String values for `initial-buffer-choice' also apply to emacsclient
|
||||
frames, if emacsclient is only told to open a new frame without
|
||||
specifying any file to visit or expression to evaluate.
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2012-05-31 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* image.el: For clarity, call imagemagick-register-types at
|
||||
top-level, rather than relying on a custom :initialize.
|
||||
(imagemagick-types-enable): New option. (Bug#11557)
|
||||
(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.
|
||||
|
||||
2012-05-31 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
* emacs-lisp/bytecomp.el (byte-compile-fix-header): Handle
|
||||
|
||||
@@ -692,38 +692,59 @@ The minimum delay between successive frames is 0.01s."
|
||||
This is the extension installed into `auto-mode-alist' and
|
||||
`image-type-file-name-regexps' by `imagemagick-register-types'.")
|
||||
|
||||
(defvar imagemagick-types-inhibit)
|
||||
(defvar imagemagick-types-enable)
|
||||
|
||||
;;;###autoload
|
||||
(defun imagemagick-register-types ()
|
||||
"Register file types that can be handled by ImageMagick.
|
||||
This function is called at startup, after loading the init file.
|
||||
It registers the ImageMagick types listed in `imagemagick-types',
|
||||
excluding those listed in `imagemagick-types-inhibit'.
|
||||
It registers the ImageMagick types returned by `imagemagick-types',
|
||||
including only those from `imagemagick-types-enable', and excluding
|
||||
those from `imagemagick-types-inhibit'.
|
||||
|
||||
Registered image types are added to `auto-mode-alist', so that
|
||||
Emacs visits them in Image mode. They are also added to
|
||||
`image-type-file-name-regexps', so that the `image-type' function
|
||||
recognizes these files as having image type `imagemagick'.
|
||||
|
||||
If Emacs is compiled without ImageMagick support, do nothing."
|
||||
If Emacs is compiled without ImageMagick support, this does nothing."
|
||||
(when (fboundp 'imagemagick-types)
|
||||
(let ((re (if (eq imagemagick-types-inhibit t)
|
||||
;; Use a bogus regexp to inhibit matches.
|
||||
"\\'a"
|
||||
(let ((types))
|
||||
(dolist (type (imagemagick-types))
|
||||
(unless (memq type imagemagick-types-inhibit)
|
||||
(push (downcase (symbol-name type)) types)))
|
||||
(concat "\\." (regexp-opt types) "\\'"))))
|
||||
(ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
|
||||
auto-mode-alist)))
|
||||
(itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick)
|
||||
image-type-file-name-regexps))))
|
||||
(if ama-elt
|
||||
(setcar ama-elt re)
|
||||
(push (cons re 'image-mode) auto-mode-alist))
|
||||
(if itfnr-elt
|
||||
(setcar itfnr-elt re)
|
||||
(push (cons re 'imagemagick) image-type-file-name-regexps))
|
||||
(let* ((include
|
||||
(cond ((null imagemagick-types-enable) nil)
|
||||
((eq imagemagick-types-inhibit t) nil)
|
||||
((eq imagemagick-types-enable t) (imagemagick-types))
|
||||
(t
|
||||
(delq nil
|
||||
(mapcar
|
||||
(lambda (type)
|
||||
(catch 'found
|
||||
(dolist (enable imagemagick-types-enable nil)
|
||||
(if (cond ((symbolp enable) (eq enable type))
|
||||
((stringp enable)
|
||||
(string-match enable
|
||||
(symbol-name type))))
|
||||
(throw 'found type)))))
|
||||
(imagemagick-types))))))
|
||||
(re (let (types)
|
||||
(dolist (type include)
|
||||
(unless (memq type imagemagick-types-inhibit)
|
||||
(push (downcase (symbol-name type)) types)))
|
||||
(if types (concat "\\." (regexp-opt types) "\\'"))))
|
||||
(ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
|
||||
auto-mode-alist)))
|
||||
(itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick)
|
||||
image-type-file-name-regexps))))
|
||||
(if (not re)
|
||||
(setq auto-mode-alist (delete ama-elt auto-mode-alist)
|
||||
image-type-file-name-regexps
|
||||
(delete itfnr-elt image-type-file-name-regexps))
|
||||
(if ama-elt
|
||||
(setcar ama-elt re)
|
||||
(push (cons re 'image-mode) auto-mode-alist))
|
||||
(if itfnr-elt
|
||||
(setcar itfnr-elt re)
|
||||
(push (cons re 'imagemagick) image-type-file-name-regexps)))
|
||||
(setq imagemagick--file-regexp re))))
|
||||
|
||||
(defcustom imagemagick-types-inhibit
|
||||
@@ -743,12 +764,45 @@ has no effect."
|
||||
:type '(choice (const :tag "Support all ImageMagick types" nil)
|
||||
(const :tag "Disable all ImageMagick types" t)
|
||||
(repeat symbol))
|
||||
:initialize 'custom-initialize-default
|
||||
:set (lambda (symbol value)
|
||||
(set-default symbol value)
|
||||
(imagemagick-register-types))
|
||||
:version "24.1"
|
||||
:group 'image)
|
||||
|
||||
(defcustom imagemagick-types-enable
|
||||
'("\\`BMP" DJVU "\\`GIF" "\\`ICO" "P?JPE?G" "P[BNP]M"
|
||||
"\\`[MP]NG" "\\`TIFF")
|
||||
"List of ImageMagick types to treat as images.
|
||||
The list elements are either strings or symbols, and represent
|
||||
types returned by `imagemagick-types'. A string is a regexp that
|
||||
selects all types matching the regexp.
|
||||
|
||||
The value may also be t, meaning all the types that ImageMagick
|
||||
supports; or nil, meaning no types.
|
||||
|
||||
The variable `imagemagick-types-inhibit' overrides this variable.
|
||||
|
||||
If you change this without using customize, you must call
|
||||
`imagemagick-register-types' afterwards.
|
||||
|
||||
If Emacs is compiled without ImageMagick support, this variable
|
||||
has no effect."
|
||||
:type '(choice (const :tag "Support all ImageMagick types" t)
|
||||
(const :tag "Disable all ImageMagick types" nil)
|
||||
(repeat :tag "List of types"
|
||||
(choice (symbol :tag "type")
|
||||
(regexp :tag "regexp"))))
|
||||
:initialize 'custom-initialize-default
|
||||
:set (lambda (symbol value)
|
||||
(set-default symbol value)
|
||||
(imagemagick-register-types))
|
||||
:version "24.2"
|
||||
:group 'image)
|
||||
|
||||
(imagemagick-register-types)
|
||||
|
||||
(provide 'image)
|
||||
|
||||
;;; image.el ends here
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
and not pointers.
|
||||
* lisp.h (__executable_start): New decl.
|
||||
|
||||
2012-05-31 Glenn Morris <rgm@gnu.org>
|
||||
|
||||
* image.c (Fimagemagick_types): Doc fix.
|
||||
|
||||
2012-05-30 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
* callproc.c (Fcall_process_region): Include directory component
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* Functions for image support on window system.
|
||||
Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc.
|
||||
|
||||
Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
@@ -7987,7 +7988,8 @@ their descriptions (http://www.imagemagick.org/script/formats.php).
|
||||
You can also try the shell command: `identify -list format'.
|
||||
|
||||
Note that ImageMagick recognizes many file-types that Emacs does not
|
||||
recognize as images, such as C. See `imagemagick-types-inhibit'. */)
|
||||
recognize as images, such as C. See `imagemagick-types-enable'
|
||||
and `imagemagick-types-inhibit'. */)
|
||||
(void)
|
||||
{
|
||||
Lisp_Object typelist = Qnil;
|
||||
|
||||
Reference in New Issue
Block a user