[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r107920: Call imagemagick-register-ty
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r107920: Call imagemagick-register-types automatically. |
Date: |
Mon, 16 Apr 2012 11:47:43 +0800 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 107920
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Mon 2012-04-16 11:47:43 +0800
message:
Call imagemagick-register-types automatically.
* lisp/image.el (imagemagick--extension-regexp): New variable.
(imagemagick-register-types): Use it.
(imagemagick-types-inhibit): Add :set function. Allow new value
of t to inhibit all types.
* lisp/loadup.el (fboundp): Preload regexp-opt, needed by
imagemagick-register-types.
* lisp/emacs-lisp/regexp-opt.el (regexp-opt-charset): Avoid cl macros,
so we can preload it.
modified:
etc/NEWS
lisp/ChangeLog
lisp/emacs-lisp/regexp-opt.el
lisp/image.el
lisp/loadup.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2012-04-15 09:16:50 +0000
+++ b/etc/NEWS 2012-04-16 03:47:43 +0000
@@ -35,6 +35,14 @@
** 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
+
* Editing Changes in Emacs 24.2
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-04-15 15:11:06 +0000
+++ b/lisp/ChangeLog 2012-04-16 03:47:43 +0000
@@ -1,3 +1,16 @@
+2012-04-16 Chong Yidong <address@hidden>
+
+ * image.el (imagemagick--extension-regexp): New variable.
+ (imagemagick-register-types): Use it.
+ (imagemagick-types-inhibit): Add :set function. Allow new value
+ of t to inhibit all types.
+
+ * emacs-lisp/regexp-opt.el (regexp-opt-charset): Avoid cl macros,
+ so we can preload it.
+
+ * loadup.el (fboundp): Preload regexp-opt, needed by
+ imagemagick-register-types.
+
2012-04-15 Chong Yidong <address@hidden>
* frame.el (scrolling): Remove nearly unused customization group.
=== modified file 'lisp/emacs-lisp/regexp-opt.el'
--- a/lisp/emacs-lisp/regexp-opt.el 2012-02-28 08:17:21 +0000
+++ b/lisp/emacs-lisp/regexp-opt.el 2012-04-16 03:47:43 +0000
@@ -136,9 +136,6 @@
;;; 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.
@@ -248,15 +245,15 @@
;;
;; 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
@@ -268,14 +265,14 @@
(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)
@@ -283,7 +280,7 @@
(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 ""))
=== modified file 'lisp/image.el'
--- a/lisp/image.el 2012-04-10 02:34:57 +0000
+++ b/lisp/image.el 2012-04-16 03:47:43 +0000
@@ -685,26 +685,16 @@
image n count time-elapsed limit))))
-(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
@@ -714,14 +704,45 @@
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)
=== modified file 'lisp/loadup.el'
--- a/lisp/loadup.el 2012-04-08 01:54:52 +0000
+++ b/lisp/loadup.el 2012-04-16 03:47:43 +0000
@@ -193,6 +193,8 @@
(if (fboundp 'x-create-frame)
(progn
(load "fringe")
+ ;; Needed by `imagemagick-register-types'
+ (load "emacs-lisp/regexp-opt")
(load "image")
(load "international/fontset")
(load "dnd")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r107920: Call imagemagick-register-types automatically.,
Chong Yidong <=