** If your Emacs was built from a bzr checkout, the new variable
`emacs-bzr-version' contains information about which bzr revision was used.
+** 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 when setting `imagemagick-types-inhibit'.
+
+*** Setting `imagemagick-types-inhibit' to t now disables the use of
+ImageMagick to view images, set
+
\f
* Editing Changes in Emacs 24.2
\f
;;; Workhorse functions.
-(eval-when-compile
- (require 'cl))
-
(defun regexp-opt-group (strings &optional paren lax)
"Return a regexp to match a string in the sorted list STRINGS.
If PAREN non-nil, output regexp parentheses around returned regexp.
;;
;; Make a character map but extract character set meta characters.
(dolist (char chars)
- (case char
- (?\]
- (setq bracket "]"))
- (?^
- (setq caret "^"))
- (?-
- (setq dash "-"))
- (otherwise
- (aset charmap char t))))
+ (cond
+ ((eq char ?\])
+ (setq bracket "]"))
+ ((eq char ?^)
+ (setq caret "^"))
+ ((eq char ?-)
+ (setq dash "-"))
+ (t
+ (aset charmap char t))))
;;
;; Make a character set from the map using ranges where applicable.
(map-char-table
(setq charset (format "%s%c-%c" charset start end))
(while (>= end start)
(setq charset (format "%s%c" charset start))
- (incf start)))
+ (setq start (1+ start))))
(setq start (car c) end (cdr c)))
(if (= (1- c) end) (setq end c)
(if (> end (+ start 2))
(setq charset (format "%s%c-%c" charset start end))
(while (>= end start)
(setq charset (format "%s%c" charset start))
- (incf start)))
+ (setq start (1+ start))))
(setq start c end c)))))
charmap)
(when (>= end start)
(setq charset (format "%s%c-%c" charset start end))
(while (>= end start)
(setq charset (format "%s%c" charset start))
- (incf start))))
+ (setq start (1+ start)))))
;;
;; Make sure a caret is not first and a dash is first or last.
(if (and (string-equal charset "") (string-equal bracket ""))
image n count time-elapsed limit))))
\f
-(defcustom imagemagick-types-inhibit
- '(C HTML HTM TXT PDF)
- "ImageMagick types that should not be visited in Image mode.
-This should be a list of symbols, each of which should be one of
-the ImageMagick types listed in `imagemagick-types'. These image
-types are not registered by `imagemagick-register-types'.
-
-If Emacs is compiled without ImageMagick support, this variable
-has no effect."
- :type '(choice (const :tag "Let ImageMagick handle all types it can" nil)
- (repeat symbol))
- ;; Ideally, would have a :set function that checks if we already did
- ;; imagemagick-register-types, and if so undoes it, then redoes it.
- :version "24.1"
- :group 'image)
+(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'.")
;;;###autoload
(defun imagemagick-register-types ()
"Register file types that can be handled by ImageMagick.
-This registers the ImageMagick types listed in `imagemagick-types',
+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'.
Registered image types are added to `auto-mode-alist', so that
If Emacs is compiled without ImageMagick support, do nothing."
(when (fboundp 'imagemagick-types)
- (let ((im-types '()))
- (dolist (im-type (imagemagick-types))
- (unless (memq im-type imagemagick-types-inhibit)
- (push (downcase (symbol-name im-type)) im-types)))
- (let ((extension (concat "\\." (regexp-opt im-types) "\\'")))
- (push (cons extension 'image-mode) auto-mode-alist)
- (push (cons extension 'imagemagick)
- image-type-file-name-regexps)))))
+ (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))
+ (setq imagemagick--file-regexp re))))
+
+(defcustom imagemagick-types-inhibit
+ '(C HTML HTM TXT PDF)
+ "List of ImageMagick types that should not be treated as images.
+This should be a list of symbols, each of which should be one of
+the ImageMagick types listed in `imagemagick-types'. The listed
+image types are not registered by `imagemagick-register-types'.
+
+If the value is t, inhibit the use of ImageMagick for images.
+
+If Emacs is compiled without ImageMagick support, this variable
+has no effect."
+ :type '(choice (const :tag "Support all ImageMagick types" nil)
+ (const :tag "Disable all ImageMagick types" t)
+ (repeat symbol))
+ :set (lambda (symbol value)
+ (set-default symbol value)
+ (imagemagick-register-types))
+ :version "24.1"
+ :group 'image)
(provide 'image)