diff options
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/emacs-lisp/regexp-opt.el | 27 | ||||
| -rw-r--r-- | lisp/image.el | 69 | ||||
| -rw-r--r-- | lisp/loadup.el | 2 |
5 files changed, 80 insertions, 39 deletions
| @@ -35,6 +35,14 @@ been adding them there, put them somewhere else, eg site-lisp. | |||
| 35 | ** If your Emacs was built from a bzr checkout, the new variable | 35 | ** If your Emacs was built from a bzr checkout, the new variable |
| 36 | `emacs-bzr-version' contains information about which bzr revision was used. | 36 | `emacs-bzr-version' contains information about which bzr revision was used. |
| 37 | 37 | ||
| 38 | ** ImageMagick support, if available, is automatically enabled. | ||
| 39 | It is no longer necessary to call `imagemagick-register-types' | ||
| 40 | explicitly to install ImageMagick image types; that function is called | ||
| 41 | automatically when setting `imagemagick-types-inhibit'. | ||
| 42 | |||
| 43 | *** Setting `imagemagick-types-inhibit' to t now disables the use of | ||
| 44 | ImageMagick to view images, set | ||
| 45 | |||
| 38 | 46 | ||
| 39 | * Editing Changes in Emacs 24.2 | 47 | * Editing Changes in Emacs 24.2 |
| 40 | 48 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a21d5841346..f50af02a239 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2012-04-16 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * image.el (imagemagick--extension-regexp): New variable. | ||
| 4 | (imagemagick-register-types): Use it. | ||
| 5 | (imagemagick-types-inhibit): Add :set function. Allow new value | ||
| 6 | of t to inhibit all types. | ||
| 7 | |||
| 8 | * emacs-lisp/regexp-opt.el (regexp-opt-charset): Avoid cl macros, | ||
| 9 | so we can preload it. | ||
| 10 | |||
| 11 | * loadup.el (fboundp): Preload regexp-opt, needed by | ||
| 12 | imagemagick-register-types. | ||
| 13 | |||
| 1 | 2012-04-15 Chong Yidong <cyd@gnu.org> | 14 | 2012-04-15 Chong Yidong <cyd@gnu.org> |
| 2 | 15 | ||
| 3 | * frame.el (scrolling): Remove nearly unused customization group. | 16 | * frame.el (scrolling): Remove nearly unused customization group. |
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el index 6d12fe19277..72e3c398dc0 100644 --- a/lisp/emacs-lisp/regexp-opt.el +++ b/lisp/emacs-lisp/regexp-opt.el | |||
| @@ -136,9 +136,6 @@ This means the number of non-shy regexp grouping constructs | |||
| 136 | 136 | ||
| 137 | ;;; Workhorse functions. | 137 | ;;; Workhorse functions. |
| 138 | 138 | ||
| 139 | (eval-when-compile | ||
| 140 | (require 'cl)) | ||
| 141 | |||
| 142 | (defun regexp-opt-group (strings &optional paren lax) | 139 | (defun regexp-opt-group (strings &optional paren lax) |
| 143 | "Return a regexp to match a string in the sorted list STRINGS. | 140 | "Return a regexp to match a string in the sorted list STRINGS. |
| 144 | If PAREN non-nil, output regexp parentheses around returned regexp. | 141 | If PAREN non-nil, output regexp parentheses around returned regexp. |
| @@ -248,15 +245,15 @@ Merges keywords to avoid backtracking in Emacs's regexp matcher." | |||
| 248 | ;; | 245 | ;; |
| 249 | ;; Make a character map but extract character set meta characters. | 246 | ;; Make a character map but extract character set meta characters. |
| 250 | (dolist (char chars) | 247 | (dolist (char chars) |
| 251 | (case char | 248 | (cond |
| 252 | (?\] | 249 | ((eq char ?\]) |
| 253 | (setq bracket "]")) | 250 | (setq bracket "]")) |
| 254 | (?^ | 251 | ((eq char ?^) |
| 255 | (setq caret "^")) | 252 | (setq caret "^")) |
| 256 | (?- | 253 | ((eq char ?-) |
| 257 | (setq dash "-")) | 254 | (setq dash "-")) |
| 258 | (otherwise | 255 | (t |
| 259 | (aset charmap char t)))) | 256 | (aset charmap char t)))) |
| 260 | ;; | 257 | ;; |
| 261 | ;; Make a character set from the map using ranges where applicable. | 258 | ;; Make a character set from the map using ranges where applicable. |
| 262 | (map-char-table | 259 | (map-char-table |
| @@ -268,14 +265,14 @@ Merges keywords to avoid backtracking in Emacs's regexp matcher." | |||
| 268 | (setq charset (format "%s%c-%c" charset start end)) | 265 | (setq charset (format "%s%c-%c" charset start end)) |
| 269 | (while (>= end start) | 266 | (while (>= end start) |
| 270 | (setq charset (format "%s%c" charset start)) | 267 | (setq charset (format "%s%c" charset start)) |
| 271 | (incf start))) | 268 | (setq start (1+ start)))) |
| 272 | (setq start (car c) end (cdr c))) | 269 | (setq start (car c) end (cdr c))) |
| 273 | (if (= (1- c) end) (setq end c) | 270 | (if (= (1- c) end) (setq end c) |
| 274 | (if (> end (+ start 2)) | 271 | (if (> end (+ start 2)) |
| 275 | (setq charset (format "%s%c-%c" charset start end)) | 272 | (setq charset (format "%s%c-%c" charset start end)) |
| 276 | (while (>= end start) | 273 | (while (>= end start) |
| 277 | (setq charset (format "%s%c" charset start)) | 274 | (setq charset (format "%s%c" charset start)) |
| 278 | (incf start))) | 275 | (setq start (1+ start)))) |
| 279 | (setq start c end c))))) | 276 | (setq start c end c))))) |
| 280 | charmap) | 277 | charmap) |
| 281 | (when (>= end start) | 278 | (when (>= end start) |
| @@ -283,7 +280,7 @@ Merges keywords to avoid backtracking in Emacs's regexp matcher." | |||
| 283 | (setq charset (format "%s%c-%c" charset start end)) | 280 | (setq charset (format "%s%c-%c" charset start end)) |
| 284 | (while (>= end start) | 281 | (while (>= end start) |
| 285 | (setq charset (format "%s%c" charset start)) | 282 | (setq charset (format "%s%c" charset start)) |
| 286 | (incf start)))) | 283 | (setq start (1+ start))))) |
| 287 | ;; | 284 | ;; |
| 288 | ;; Make sure a caret is not first and a dash is first or last. | 285 | ;; Make sure a caret is not first and a dash is first or last. |
| 289 | (if (and (string-equal charset "") (string-equal bracket "")) | 286 | (if (and (string-equal charset "") (string-equal bracket "")) |
diff --git a/lisp/image.el b/lisp/image.el index b094f2464ec..348c208781e 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -685,26 +685,16 @@ The minimum delay between successive frames is 0.01s." | |||
| 685 | image n count time-elapsed limit)))) | 685 | image n count time-elapsed limit)))) |
| 686 | 686 | ||
| 687 | 687 | ||
| 688 | (defcustom imagemagick-types-inhibit | 688 | (defvar imagemagick--file-regexp nil |
| 689 | '(C HTML HTM TXT PDF) | 689 | "File extension regexp for ImageMagick files, if any. |
| 690 | "ImageMagick types that should not be visited in Image mode. | 690 | This is the extension installed into `auto-mode-alist' and |
| 691 | This should be a list of symbols, each of which should be one of | 691 | `image-type-file-name-regexps' by `imagemagick-register-types'.") |
| 692 | the ImageMagick types listed in `imagemagick-types'. These image | ||
| 693 | types are not registered by `imagemagick-register-types'. | ||
| 694 | |||
| 695 | If Emacs is compiled without ImageMagick support, this variable | ||
| 696 | has no effect." | ||
| 697 | :type '(choice (const :tag "Let ImageMagick handle all types it can" nil) | ||
| 698 | (repeat symbol)) | ||
| 699 | ;; Ideally, would have a :set function that checks if we already did | ||
| 700 | ;; imagemagick-register-types, and if so undoes it, then redoes it. | ||
| 701 | :version "24.1" | ||
| 702 | :group 'image) | ||
| 703 | 692 | ||
| 704 | ;;;###autoload | 693 | ;;;###autoload |
| 705 | (defun imagemagick-register-types () | 694 | (defun imagemagick-register-types () |
| 706 | "Register file types that can be handled by ImageMagick. | 695 | "Register file types that can be handled by ImageMagick. |
| 707 | This registers the ImageMagick types listed in `imagemagick-types', | 696 | This function is called at startup, after loading the init file. |
| 697 | It registers the ImageMagick types listed in `imagemagick-types', | ||
| 708 | excluding those listed in `imagemagick-types-inhibit'. | 698 | excluding those listed in `imagemagick-types-inhibit'. |
| 709 | 699 | ||
| 710 | Registered image types are added to `auto-mode-alist', so that | 700 | Registered image types are added to `auto-mode-alist', so that |
| @@ -714,14 +704,45 @@ recognizes these files as having image type `imagemagick'. | |||
| 714 | 704 | ||
| 715 | If Emacs is compiled without ImageMagick support, do nothing." | 705 | If Emacs is compiled without ImageMagick support, do nothing." |
| 716 | (when (fboundp 'imagemagick-types) | 706 | (when (fboundp 'imagemagick-types) |
| 717 | (let ((im-types '())) | 707 | (let ((re (if (eq imagemagick-types-inhibit t) |
| 718 | (dolist (im-type (imagemagick-types)) | 708 | ;; Use a bogus regexp to inhibit matches. |
| 719 | (unless (memq im-type imagemagick-types-inhibit) | 709 | "\\'a" |
| 720 | (push (downcase (symbol-name im-type)) im-types))) | 710 | (let ((types)) |
| 721 | (let ((extension (concat "\\." (regexp-opt im-types) "\\'"))) | 711 | (dolist (type (imagemagick-types)) |
| 722 | (push (cons extension 'image-mode) auto-mode-alist) | 712 | (unless (memq type imagemagick-types-inhibit) |
| 723 | (push (cons extension 'imagemagick) | 713 | (push (downcase (symbol-name type)) types))) |
| 724 | 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. | ||
| 730 | This should be a list of symbols, each of which should be one of | ||
| 731 | the ImageMagick types listed in `imagemagick-types'. The listed | ||
| 732 | image types are not registered by `imagemagick-register-types'. | ||
| 733 | |||
| 734 | If the value is t, inhibit the use of ImageMagick for images. | ||
| 735 | |||
| 736 | If Emacs is compiled without ImageMagick support, this variable | ||
| 737 | has 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) | ||
| 725 | 746 | ||
| 726 | (provide 'image) | 747 | (provide 'image) |
| 727 | 748 | ||
diff --git a/lisp/loadup.el b/lisp/loadup.el index 2ba24c8fe37..f7ffa27a9ed 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el | |||
| @@ -193,6 +193,8 @@ | |||
| 193 | (if (fboundp 'x-create-frame) | 193 | (if (fboundp 'x-create-frame) |
| 194 | (progn | 194 | (progn |
| 195 | (load "fringe") | 195 | (load "fringe") |
| 196 | ;; Needed by `imagemagick-register-types' | ||
| 197 | (load "emacs-lisp/regexp-opt") | ||
| 196 | (load "image") | 198 | (load "image") |
| 197 | (load "international/fontset") | 199 | (load "international/fontset") |
| 198 | (load "dnd") | 200 | (load "dnd") |