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.
This commit is contained in:
parent
32d72c2f5d
commit
60b5f1870c
3 changed files with 34 additions and 29 deletions
4
etc/NEWS
4
etc/NEWS
|
@ -68,7 +68,9 @@ 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.
|
||||
ImageMagick types are treated as images. The function
|
||||
`imagemagick-filter-types' returns the list of types that will be
|
||||
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
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
* 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.
|
||||
(imagemagick-filter-types): New function. (Bug#7406)
|
||||
(imagemagick-register-types): Use imagemagick-filter-types.
|
||||
If disabling support, remove elements altogether rather
|
||||
than using an impossible regexp.
|
||||
(imagemagick-types-inhibit): Give it the default init function.
|
||||
|
|
|
@ -687,21 +687,41 @@ The minimum delay between successive frames is 0.01s."
|
|||
image n count time-elapsed limit))))
|
||||
|
||||
|
||||
(defvar imagemagick-types-inhibit)
|
||||
(defvar imagemagick-types-enable)
|
||||
|
||||
(defun imagemagick-filter-types ()
|
||||
"Return a list of the ImageMagick types to be treated as images, or nil.
|
||||
This is the result of `imagemagick-types', including only elements
|
||||
that match `imagemagick-types-enable' and do not match
|
||||
`imagemagick-types-inhibit'."
|
||||
(when (fboundp 'imagemagick-types)
|
||||
(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)
|
||||
(unless (memq type imagemagick-types-inhibit)
|
||||
(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)))))))
|
||||
|
||||
(defvar imagemagick--file-regexp nil
|
||||
"File extension regexp for ImageMagick files, if any.
|
||||
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 returned by `imagemagick-types',
|
||||
including only those from `imagemagick-types-enable', and excluding
|
||||
those from `imagemagick-types-inhibit'.
|
||||
It registers the ImageMagick types returned by `imagemagick-filter-types'.
|
||||
|
||||
Registered image types are added to `auto-mode-alist', so that
|
||||
Emacs visits them in Image mode. They are also added to
|
||||
|
@ -710,27 +730,9 @@ recognizes these files as having image type `imagemagick'.
|
|||
|
||||
If Emacs is compiled without ImageMagick support, this does nothing."
|
||||
(when (fboundp 'imagemagick-types)
|
||||
(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) "\\'"))))
|
||||
(let* ((types (mapcar (lambda (type) (downcase (symbol-name type)))
|
||||
(imagemagick-filter-types)))
|
||||
(re (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)
|
||||
|
|
Loading…
Add table
Reference in a new issue