aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/image.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el72
1 files changed, 47 insertions, 25 deletions
diff --git a/lisp/image.el b/lisp/image.el
index be1b1ef8f48..348c208781e 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -412,7 +412,8 @@ means display it in the right marginal area."
412 (prop (if (null area) image (list (list 'margin area) image)))) 412 (prop (if (null area) image (list (list 'margin area) image))))
413 (put-text-property 0 (length string) 'display prop string) 413 (put-text-property 0 (length string) 'display prop string)
414 (overlay-put overlay 'put-image t) 414 (overlay-put overlay 'put-image t)
415 (overlay-put overlay 'before-string string)))) 415 (overlay-put overlay 'before-string string)
416 overlay)))
416 417
417 418
418;;;###autoload 419;;;###autoload
@@ -684,26 +685,16 @@ The minimum delay between successive frames is 0.01s."
684 image n count time-elapsed limit)))) 685 image n count time-elapsed limit))))
685 686
686 687
687(defcustom imagemagick-types-inhibit 688(defvar imagemagick--file-regexp nil
688 '(C HTML HTM TXT PDF) 689 "File extension regexp for ImageMagick files, if any.
689 "ImageMagick types that should not be visited in Image mode. 690This is the extension installed into `auto-mode-alist' and
690This should be a list of symbols, each of which should be one of 691`image-type-file-name-regexps' by `imagemagick-register-types'.")
691the ImageMagick types listed in `imagemagick-types'. These image
692types are not registered by `imagemagick-register-types'.
693
694If Emacs is compiled without ImageMagick support, this variable
695has no effect."
696 :type '(choice (const :tag "Let ImageMagick handle all types it can" nil)
697 (repeat symbol))
698 ;; Ideally, would have a :set function that checks if we already did
699 ;; imagemagick-register-types, and if so undoes it, then redoes it.
700 :version "24.1"
701 :group 'image)
702 692
703;;;###autoload 693;;;###autoload
704(defun imagemagick-register-types () 694(defun imagemagick-register-types ()
705 "Register file types that can be handled by ImageMagick. 695 "Register file types that can be handled by ImageMagick.
706This registers the ImageMagick types listed in `imagemagick-types', 696This function is called at startup, after loading the init file.
697It registers the ImageMagick types listed in `imagemagick-types',
707excluding those listed in `imagemagick-types-inhibit'. 698excluding those listed in `imagemagick-types-inhibit'.
708 699
709Registered image types are added to `auto-mode-alist', so that 700Registered image types are added to `auto-mode-alist', so that
@@ -713,14 +704,45 @@ recognizes these files as having image type `imagemagick'.
713 704
714If Emacs is compiled without ImageMagick support, do nothing." 705If Emacs is compiled without ImageMagick support, do nothing."
715 (when (fboundp 'imagemagick-types) 706 (when (fboundp 'imagemagick-types)
716 (let ((im-types '())) 707 (let ((re (if (eq imagemagick-types-inhibit t)
717 (dolist (im-type (imagemagick-types)) 708 ;; Use a bogus regexp to inhibit matches.
718 (unless (memq im-type imagemagick-types-inhibit) 709 "\\'a"
719 (push (downcase (symbol-name im-type)) im-types))) 710 (let ((types))
720 (let ((extension (concat "\\." (regexp-opt im-types) "\\'"))) 711 (dolist (type (imagemagick-types))
721 (push (cons extension 'image-mode) auto-mode-alist) 712 (unless (memq type imagemagick-types-inhibit)
722 (push (cons extension 'imagemagick) 713 (push (downcase (symbol-name type)) types)))
723 image-type-file-name-regexps))))) 714 (concat "\\." (regexp-opt types) "\\'"))))
715 (ama-elt (car (member (cons imagemagick--file-regexp 'image-mode)
716 auto-mode-alist)))
717 (itfnr-elt (car (member (cons imagemagick--file-regexp 'imagemagick)
718 image-type-file-name-regexps))))
719 (if ama-elt
720 (setcar ama-elt re)
721 (push (cons re 'image-mode) auto-mode-alist))
722 (if itfnr-elt
723 (setcar itfnr-elt re)
724 (push (cons re 'imagemagick) image-type-file-name-regexps))
725 (setq imagemagick--file-regexp re))))
726
727(defcustom imagemagick-types-inhibit
728 '(C HTML HTM TXT PDF)
729 "List of ImageMagick types that should not be treated as images.
730This should be a list of symbols, each of which should be one of
731the ImageMagick types listed in `imagemagick-types'. The listed
732image types are not registered by `imagemagick-register-types'.
733
734If the value is t, inhibit the use of ImageMagick for images.
735
736If Emacs is compiled without ImageMagick support, this variable
737has no effect."
738 :type '(choice (const :tag "Support all ImageMagick types" nil)
739 (const :tag "Disable all ImageMagick types" t)
740 (repeat symbol))
741 :set (lambda (symbol value)
742 (set-default symbol value)
743 (imagemagick-register-types))
744 :version "24.1"
745 :group 'image)
724 746
725(provide 'image) 747(provide 'image)
726 748