[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: image.el doesn't associate image-mode with .JPG files
From: |
Kim F. Storm |
Subject: |
Re: image.el doesn't associate image-mode with .JPG files |
Date: |
Sun, 17 Dec 2006 01:28:04 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux) |
"Juanma Barranquero" <address@hidden> writes:
> image.el already defines `image-type-header-regexps' and
> `image-type-from-buffer', so it seems wasteful to recreate that. It
> would be better IMHO to simply use `image-type-from-buffer' from
> `set-auto-mode'. Other than changes to docstrings and info files, the
> path is as simple as this, and works quite well.
I think your idea is really good -- and simple!
Another way is the following one which does exactly the same as your
patch, but in a more generic way:
*** files.el 11 Dec 2006 09:41:20 +0100 1.868
--- files.el 17 Dec 2006 01:24:31 +0100
***************
*** 2115,2121 ****
associated with that interpreter in `interpreter-mode-alist'.")
(defvar magic-mode-alist
! `(;; The < comes before the groups (but the first) to reduce backtracking.
;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
;; We use [ \t\n] instead of `\\s ' to make regex overflow less likely.
(,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
--- 2115,2122 ----
associated with that interpreter in `interpreter-mode-alist'.")
(defvar magic-mode-alist
! `((image-type-from-buffer . image-mode)
! ;; The < comes before the groups (but the first) to reduce backtracking.
;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
;; We use [ \t\n] instead of `\\s ' to make regex overflow less likely.
(,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
***************
*** 2134,2143 ****
("%![^V]" . ps-mode)
("# xmcd " . conf-unix-mode))
"Alist of buffer beginnings vs. corresponding major mode functions.
! Each element looks like (REGEXP . FUNCTION). After visiting a file,
! if REGEXP matches the text at the beginning of the buffer,
! `normal-mode' will call FUNCTION rather than allowing `auto-mode-alist'
! to decide the buffer's major mode.
If FUNCTION is nil, then it is not called. (That is a way of saying
\"allow `auto-mode-alist' to decide for these files.\")")
--- 2135,2145 ----
("%![^V]" . ps-mode)
("# xmcd " . conf-unix-mode))
"Alist of buffer beginnings vs. corresponding major mode functions.
! Each element looks like (REGEXP . FUNCTION) or (MATCH-FUNCTION . FUNCTION).
! After visiting a file, if REGEXP matches the text at the beginning of the
! buffer, or calling MATCH-FUNCTION returns non-nil, `normal-mode' will
! call FUNCTION rather than allowing `auto-mode-alist' to decide the buffer's
! major mode.
If FUNCTION is nil, then it is not called. (That is a way of saying
\"allow `auto-mode-alist' to decide for these files.\")")
***************
*** 2224,2230 ****
(+ (point-min)
magic-mode-regexp-match-limit)))
(assoc-default nil magic-mode-alist
(lambda (re dummy)
! (looking-at re))))))
(set-auto-mode-0 done keep-mode-if-same)
;; Compare the filename against the entries in auto-mode-alist.
(if buffer-file-name
--- 2226,2234 ----
(+ (point-min)
magic-mode-regexp-match-limit)))
(assoc-default nil magic-mode-alist
(lambda (re dummy)
! (if (functionp re)
! (funcall re)
! (looking-at re)))))))
(set-auto-mode-0 done keep-mode-if-same)
;; Compare the filename against the entries in auto-mode-alist.
(if buffer-file-name
--
Kim F. Storm <address@hidden> http://www.cua.dk
- Re: image.el doesn't associate image-mode with .JPG files, (continued)
- Message not available
- Re: image.el doesn't associate image-mode with .JPG files, Stefan Monnier, 2006/12/19
- Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/20
- Re: image.el doesn't associate image-mode with .JPG files, Stefan Monnier, 2006/12/20
- Re: image.el doesn't associate image-mode with .JPG files, Miles Bader, 2006/12/20
- Re: image.el doesn't associate image-mode with .JPG files, Stefan Monnier, 2006/12/21
- Re: image.el doesn't associate image-mode with .JPG files, Jason Rumney, 2006/12/13
- Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/14
- Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/14
- Re: image.el doesn't associate image-mode with .JPG files, Juanma Barranquero, 2006/12/15
- Re: image.el doesn't associate image-mode with .JPG files, Juanma Barranquero, 2006/12/15
- Re: image.el doesn't associate image-mode with .JPG files,
Kim F. Storm <=
- Re: image.el doesn't associate image-mode with .JPG files, Juanma Barranquero, 2006/12/16
- Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/17
- Re: image.el doesn't associate image-mode with .JPG files, Juanma Barranquero, 2006/12/17
- Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/18
- Re: image.el doesn't associate image-mode with .JPG files, Juanma Barranquero, 2006/12/18
- Re: image.el doesn't associate image-mode with .JPG files, Kim F. Storm, 2006/12/19
- Re: image.el doesn't associate image-mode with .JPG files, Juanma Barranquero, 2006/12/19
- Re: image.el doesn't associate image-mode with .JPG files, Kim F. Storm, 2006/12/19
- Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/20
Re: image.el doesn't associate image-mode with .JPG files, Richard Stallman, 2006/12/12