diff options
| author | Chong Yidong | 2007-06-04 20:40:53 +0000 |
|---|---|---|
| committer | Chong Yidong | 2007-06-04 20:40:53 +0000 |
| commit | ada9718d0fac370e92650e914f43f099f07a0753 (patch) | |
| tree | 04f8e7de4f128c96a27b51ab20475c34986ecef7 | |
| parent | b647fc0734847b9e2b8f6c78e09c090482dec3fb (diff) | |
| download | emacs-ada9718d0fac370e92650e914f43f099f07a0753.tar.gz emacs-ada9718d0fac370e92650e914f43f099f07a0753.zip | |
(image-type-auto-detected-p): Don't scan auto-mode-alist.
| -rw-r--r-- | lisp/image.el | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/lisp/image.el b/lisp/image.el index c9269abce3e..60d9c4db39c 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -343,30 +343,15 @@ Image types are symbols like `xbm' or `jpeg'." | |||
| 343 | ;;;###autoload | 343 | ;;;###autoload |
| 344 | (defun image-type-auto-detected-p () | 344 | (defun image-type-auto-detected-p () |
| 345 | "Return t iff the current buffer contains an auto-detectable image. | 345 | "Return t iff the current buffer contains an auto-detectable image. |
| 346 | This function is intended to be used from `magic-mode-alist' (which see). | 346 | This function is intended to be used from `magic-fallback-mode-alist'. |
| 347 | 347 | ||
| 348 | First, compare the beginning of the buffer with `image-type-header-regexps'. | 348 | The buffer is considered to contain an auto-detectable image if |
| 349 | If an appropriate image type is found, check if that image type can be | 349 | its beginning matches an image type in `image-type-header-regexps', |
| 350 | autodetected using the variable `image-type-auto-detectable'. Finally, | 350 | and that image type is present in `image-type-auto-detectable'." |
| 351 | if `buffer-file-name' is non-nil, check if it matches another major mode | ||
| 352 | in `auto-mode-alist' apart from `image-mode'; if there is another match, | ||
| 353 | the autodetection is considered to have failed. Return t if all the above | ||
| 354 | steps succeed." | ||
| 355 | (let* ((type (image-type-from-buffer)) | 351 | (let* ((type (image-type-from-buffer)) |
| 356 | (auto (and type (cdr (assq type image-type-auto-detectable))))) | 352 | (auto (and type (cdr (assq type image-type-auto-detectable))))) |
| 357 | (and auto | 353 | (and auto |
| 358 | (or (eq auto t) (image-type-available-p type)) | 354 | (or (eq auto t) (image-type-available-p type))))) |
| 359 | (or (null buffer-file-name) | ||
| 360 | (not (assoc-default | ||
| 361 | buffer-file-name | ||
| 362 | (delq nil (mapcar | ||
| 363 | (lambda (elt) | ||
| 364 | (unless (memq (or (car-safe (cdr elt)) | ||
| 365 | (cdr elt)) | ||
| 366 | '(image-mode image-mode-maybe)) | ||
| 367 | elt)) | ||
| 368 | auto-mode-alist)) | ||
| 369 | 'string-match)))))) | ||
| 370 | 355 | ||
| 371 | 356 | ||
| 372 | ;;;###autoload | 357 | ;;;###autoload |