Re: image.el doesn't associate image-mode with .JPG files
I've made my decision about this, and I don't want to argue it further. Does anybody agree with Richard on this one? Technically I prefer Jason's solution, but I think in practice it's an extremely minor issue. I've only ever had problems with uppercase extensions on image files, so the less general fix of simply adding appropriate entries to auto-mode-alist would suffice for me at least. Agreed. It's not necessarily important, but it would come in handy in the rare cases where your filenames have been accidentally uppercased. I also think that as maintainer, it's Richard's right to say it's good enough, let's drop this issue for now and that people should respect that unless doing so would cause real problems -- and in this case, it simply doesn't matter very much. I'd agree to that, but I understand Richard's answer to be no it would be wrong to do that, let's never again consider it. Stefan ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Date: Tue, 19 Dec 2006 16:46:19 + From: Jason Rumney [EMAIL PROTECTED] Cc: emacs-pretest-bug@gnu.org, [EMAIL PROTECTED] Discussing an idea in a useful way does not include continuing to pressure me after I've made a decision. I'm sorry if you felt pressured FWIW, I fail to see how posting a message can qualify as ``pressure'' at all. One can always ignore such messages. In the extreme case where even seeing the subject in INBOX-summary annoys, one can always configure rmail-spam-filter to filter them out completely. Either way does not run any risk of offending an active contributor by effectively telling him to shut up, when the only intent of that contributor's messages is to improve Emacs. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
BTW, as `magic-mode-alist' takes precedence over `auto-mode-alist', perhaps we should make some of the regexps in `image-type-header-regexp' somewhat less trigger-happy. I'm thinking mostly of the one for pbm, which matches any file that starts with P[1-6]. Thanks for noticing this issue. Please do install your patch. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
I don't see in which sense this is an example. After all, what harm would there be to use sh-mode for files named .BASH_PROFILE or .ZLOGIN ? Or even .bAsH_PROfilE ? It wouldn't be correct. These file names are case sensitive. I've made my decision about this, and I don't want to argue it further. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
I don't see in which sense this is an example. After all, what harm would there be to use sh-mode for files named .BASH_PROFILE or .ZLOGIN ? Or even .bAsH_PROfilE ? It wouldn't be correct. These file names are case sensitive. I've made my decision about this, and I don't want to argue it further. Does anybody agree with Richard on this one? Stefan ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Stefan Monnier [EMAIL PROTECTED] writes: I've made my decision about this, and I don't want to argue it further. Does anybody agree with Richard on this one? Technically I prefer Jason's solution, but I think in practice it's an extremely minor issue. I've only ever had problems with uppercase extensions on image files, so the less general fix of simply adding appropriate entries to auto-mode-alist would suffice for me at least. I also think that as maintainer, it's Richard's right to say it's good enough, let's drop this issue for now and that people should respect that unless doing so would cause real problems -- and in this case, it simply doesn't matter very much. -miles -- `Suppose Korea goes to the World Cup final against Japan and wins,' Moon said. `All the past could be forgiven.' [NYT] ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/19/06, Kim F. Storm [EMAIL PROTECTED] wrote: Installed. Great. BTW, as `magic-mode-alist' takes precedence over `auto-mode-alist', perhaps we should make some of the regexps in `image-type-header-regexp' somewhat less trigger-happy. I'm thinking mostly of the one for pbm, which matches any file that starts with P[1-6]. I propose the following patch (which also modifies the regexp for PNG to use the full PNG header, according to spec). /L/e/k/t/u Index: lisp/image.el === RCS file: /cvsroot/emacs/emacs/lisp/image.el,v retrieving revision 1.63 diff -u -2 -r1.63 image.el --- lisp/image.el 21 Apr 2006 20:56:06 - 1.63 +++ lisp/image.el 19 Dec 2006 10:40:53 - @@ -36,9 +36,9 @@ (defconst image-type-header-regexps '((\\`/[\t\n\r ]*\\*.*XPM.\\*/ . xpm) -(\\`P[1-6] . pbm) +(\\`P[1-6][[:space:]]+\\(?:#.*[[:space:]]+\\)*[0-9]+[[:space:]]+[0-9]+ . pbm) (\\`GIF8 . gif) -(\\`\211PNG\r\n . png) +(\\`\x89PNG\r\n\x1a\n . png) (\\`[\t\n\r ]*#define . xbm) -(\\`\\(MM\0\\*\\|II\\*\0\\) . tiff) +(\\`\\(?:MM\0\\*\\|II\\*\0\\) . tiff) (\\`[\t\n\r ]*%!PS . postscript) (\\`\xff\xd8 . (image-jpeg-p . jpeg))) ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Juanma Barranquero [EMAIL PROTECTED] writes: BTW, as `magic-mode-alist' takes precedence over `auto-mode-alist', perhaps we should make some of the regexps in `image-type-header-regexp' somewhat less trigger-happy. I'm thinking mostly of the one for pbm, which matches any file that starts with P[1-6]. I propose the following patch (which also modifies the regexp for PNG to use the full PNG header, according to spec). Yes, it seems quite necessary to do this. -- Kim F. Storm [EMAIL PROTECTED] http://www.cua.dk ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Richard Stallman wrote: The answer is no, and I've chosen a different solution. Please drop the subject. If a developers mailing list cannot be used for discussing development ideas, then I think I might as well unsubscribe. Discussing an idea in a useful way does not include continuing to pressure me after I've made a decision. I'm sorry if you felt pressured, but it seemed premature to dismiss my suggestion the first time you did so, as the only alternative proposal offered was an incomplete regexp that did not cover all jpeg files. Kim and others since refined it into a better solution, and I agree that solution is a better one for most image files. I still think there is a general underlying bug here though that is not specific to image files, but to transfer of files from sources that do not preserve case (ISO format CDs, DOS/Windows machines, SD Cards, floppy disks etc). But you seem to think it is more important not to use sh-mode for .LOGIN than it is to fix this bug, so I will leave it alone now. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Richard Stallman wrote: The answer is no, and I've chosen a different solution. Please drop the subject. If a developers mailing list cannot be used for discussing development ideas, then I think I might as well unsubscribe. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Can you point to a single instance where doing a case-insensitve match as a fallback would be harmful? There are many patterns which are meant to apply to file names used for specific conventional purposes in a GNU-like system, names which are used with specific case patterns. Here's one example. (\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\' . sh-mode) I don't see in which sense this is an example. After all, what harm would there be to use sh-mode for files named .BASH_PROFILE or .ZLOGIN ? Or even .bAsH_PROfilE ? The answer is no, and I've chosen a different solution. I think the two solutions aren't mutually exclusive. I agree with Jason that it would make a lot of sense to use a fallback where we try auto-mode-alist a second time with case-fold-search set to t if the first time didn't turn up any match. Stefan ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
I can install it, if you don't want to install Kim's change instead right now. But I think his is the way to go. Remember that I transfer mail in batches. I saw Kim's message after sending out my last message. I think his method is fine too. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/18/06, Richard Stallman [EMAIL PROTECTED] wrote: Remember that I transfer mail in batches. I know. That's why I didn't install anything ;) I think his method is fine too. Cool. /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Date: Mon, 18 Dec 2006 09:18:29 + From: Jason Rumney [EMAIL PROTECTED] Cc: emacs-pretest-bug@gnu.org, [EMAIL PROTECTED] If a developers mailing list cannot be used for discussing development ideas, then I think I might as well unsubscribe. Please don't. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
From: Miles Bader [EMAIL PROTECTED] Date: Mon, 18 Dec 2006 18:29:09 +0900 Cc: emacs-pretest-bug@gnu.org, [EMAIL PROTECTED] You might try decaf. Not really my idea of support. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Eli Zaretskii writes: From: Miles Bader [EMAIL PROTECTED] Date: Mon, 18 Dec 2006 18:29:09 +0900 Cc: emacs-pretest-bug@gnu.org, [EMAIL PROTECTED] You might try decaf. Not really my idea of support. I agree. Jason always presents a reasoned and informed point of view, and his e-mails always succinct. In a civilised debate, the thread should end when there is nothing more to add, not by decree. -- Nick http://www.inet.net.nz/~nickrob ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Eli Zaretskii [EMAIL PROTECTED] writes: You might try decaf. Not really my idea of support. I wasn't trying to support him. I don't particularly like Richard's method of handling such issues, but Jason's response was downright petulant. -MIles -- Love is a snowmobile racing across the tundra. Suddenly it flips over, pinning you underneath. At night the ice weasels come. --Nietzsche ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Cc: [EMAIL PROTECTED], emacs-pretest-bug@gnu.org, [EMAIL PROTECTED] From: Miles Bader [EMAIL PROTECTED] Date: Tue, 19 Dec 2006 12:29:27 +0900 Eli Zaretskii [EMAIL PROTECTED] writes: You might try decaf. Not really my idea of support. I wasn't trying to support him. It should be obvious that I thought you ought to. I don't particularly like Richard's method of handling such issues, but Jason's response was downright petulant. We all have our bad days, and that's when we are in dire need of support. Not before, not after, but right there and then. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Eli Zaretskii [EMAIL PROTECTED] writes: We all have our bad days, and that's when we are in dire need of support. Not before, not after, but right there and then. True... I apologize for the snide comment, Jason. -Miles -- Suppose He doesn't give a shit? Suppose there is a God but He just doesn't give a shit? [George Carlin] ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/17/06, Richard Stallman [EMAIL PROTECTED] wrote: That is smart. Please install it. I can install it, if you don't want to install Kim's change instead right now. But I think his is the way to go. /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Can you point to a single instance where doing a case-insensitve match as a fallback would be harmful? There are many patterns which are meant to apply to file names used for specific conventional purposes in a GNU-like system, names which are used with specific case patterns. Here's one example. (\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\' . sh-mode) The answer is no, and I've chosen a different solution. Please drop the subject. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Juanma Barranquero [EMAIL PROTECTED] 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.el11 Dec 2006 09:41:20 +0100 1.868 --- files.el17 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 [EMAIL PROTECTED] http://www.cua.dk ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/17/06, Kim F. Storm [EMAIL PROTECTED] wrote: Another way is the following one which does exactly the same as your patch, but in a more generic way: That is what I proposed on http://lists.gnu.org/archive/html/emacs-pretest-bug/2006-12/msg00395.html so obviously I agree it's a good answer ;-) /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Richard Stallman wrote: It would handle that one case, but it would still produce false matches. It would only produce false matches for cases where Emacs would have defaulted to Fundamental mode. Yes, and that is a mistaken outcome. There is no reason to make such mistakes happen. When an entry should match more than one case pattern, we write it to do so. That's a small amount of work, and it gives 100% correct results. Please drop this idea. The underlying problem here is that people receive files from sources that use a case-insensitve filesystem. This can happen to ANY type of file, so should we rewrite ALL our regexps? Can you point to a single instance where doing a case-insensitve match as a fallback would be harmful? Perhaps it would be easier to eliminate any such cases by explicitly adding them to auto-mode-alist. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
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. That is smart. Please install it. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Richard Stallman wrote: Perhaps this can be solved by first doing a case-sensitive scan through auto-mode-alist, then if that fails to find a match do a case-insensitive scan. Brilliant! It would handle that one case, but it would still produce false matches. It would only produce false matches for cases where Emacs would have defaulted to Fundamental mode. Is that so bad, or am I missing something? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Jason Rumney [EMAIL PROTECTED] writes: Richard Stallman wrote: Perhaps this can be solved by first doing a case-sensitive scan through auto-mode-alist, then if that fails to find a match do a case-insensitive scan. Brilliant! It would handle that one case, but it would still produce false matches. It would only produce false matches for cases where Emacs would have defaulted to Fundamental mode. Is that so bad, or am I missing something? I don't see the problem either. It would make Emacs DTRT in a lot more cases, at the expense of _potentially_ doing TWT in a few obscure cases, such as entering changelog-mode for a file named cHANGElOG. I'm 100% in favour of your proposal (and consequently in 100% disagreement with RMS -- on this issue). -- Kim F. Storm [EMAIL PROTECTED] http://www.cua.dk ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
It would handle that one case, but it would still produce false matches. It would only produce false matches for cases where Emacs would have defaulted to Fundamental mode. Yes, and that is a mistaken outcome. There is no reason to make such mistakes happen. When an entry should match more than one case pattern, we write it to do so. That's a small amount of work, and it gives 100% correct results. Please drop this idea. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/14/06, Richard Stallman [EMAIL PROTECTED] wrote: That seems like a valid reason. Would someone please install that change? It would be useful to recognize PNG and GIF as well this way. 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. /L/e/k/t/u Index: lisp/files.el === RCS file: /cvsroot/emacs/emacs/lisp/files.el,v retrieving revision 1.868 diff -c -r1.868 files.el *** lisp/files.el 11 Dec 2006 04:40:41 - 1.868 --- lisp/files.el 16 Dec 2006 02:51:21 - *** *** ,2230 (narrow-to-region (point-min) (min (point-max) (+ (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 --- ,2232 (narrow-to-region (point-min) (min (point-max) (+ (point-min) magic-mode-regexp-match-limit))) !(if (image-type-from-buffer) !'image-mode ! (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 ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/16/06, Juanma Barranquero [EMAIL PROTECTED] wrote: path is as simple as this, and works quite well. s/path/patch/ sleep /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Miles Bader wrote: I don't think they'd care in general, and might even approve. Like most people, even though I never use windows, I occasionally receive files from windows users, and there's lots of crufty old windows software that still uses DOS-like names. I think it's the special cases that you to be careful about, e.g., .c - c-mode, .C - c++-mode. Perhaps this can be solved by first doing a case-sensitive scan through auto-mode-alist, then if that fails to find a match do a case-insensitive scan. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Jason Rumney wrote: Miles Bader wrote: I don't think they'd care in general, and might even approve. Like most people, even though I never use windows, I occasionally receive files from windows users, and there's lots of crufty old windows software that still uses DOS-like names. I think it's the special cases that you to be careful about, e.g., .c - c-mode, .C - c++-mode. Perhaps this can be solved by first doing a case-sensitive scan through auto-mode-alist, then if that fails to find a match do a case-insensitive scan. Brilliant! -- Kevin ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Perhaps this can be solved by first doing a case-sensitive scan through auto-mode-alist, then if that fails to find a match do a case-insensitive scan. Brilliant! It would handle that one case, but it would still produce false matches. We're not going to change this. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Richard Stallman [EMAIL PROTECTED] writes: If .JPG/.JPEG is frequent, perhaps we should add it to `auto-mode-alist', then. Or do this: (push '(^\xFF\xD8\xFF\xE0\x00\x10JFIF . image-mode) magic-mode-alist) I am not sure which is better, but I agree we should do one or the other. I guess it is a matter of taste, but I would prefer if Emacs uses the technique above instead of looking at the file name. An example of why this is useful: From my digital camera, each time I record a movie with it I get both an avi file and a thm file (I think that was the extension but it does not matter really), and it turns out that this extra thm file is a small thumbnail of the movie, in jpeg format. So in this case, it would be good if Emacs groked the jpeg file *format* instead of looking at the file name. My 2 öre. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Mathias Dahl wrote: Richard Stallman [EMAIL PROTECTED] writes: If .JPG/.JPEG is frequent, perhaps we should add it to `auto-mode-alist', then. Or do this: (push '(^\xFF\xD8\xFF\xE0\x00\x10JFIF . image-mode) magic-mode-alist) I am not sure which is better, but I agree we should do one or the other. I guess it is a matter of taste, but I would prefer if Emacs uses the technique above instead of looking at the file name. The only problem with this method is that the actual regexp you need is more complex, as there are different versions of JFIF, and Exif to check for (most digital cameras use the latter). image-jpeg-p has a much more relaxed check, basically ^\xFF\xD8\xFF[\xE0-\xEF]..+(JFIF|Exif), but with the search for JFIF|Exif limited based on the first two bytes of the ..+ portion - which indicate the length of the file header. If you can't limit the search to the header, then the regexp may become too inefficient for use in magic-mode-alist. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/13/06, Jason Rumney [EMAIL PROTECTED] wrote: The only problem with this method is that the actual regexp you need is more complex Yes, I downloaded the spec; I was just being sloppy in discussing it. I'm not sure I like adding that to `magic-mode-alist'; why not PNG, GIF, TIFF and other easily recognizable formats? image-jpeg-p has a much more relaxed check, basically ^\xFF\xD8\xFF[\xE0-\xEF]..+(JFIF|Exif), but with the search for JFIF|Exif limited based on the first two bytes of the ..+ portion - which indicate the length of the file header. Post-22.1, perhaps `magic-mode-alist' could be extended to also allow (MATCHER . FUNCTION) pairs (MATCHER being a predicate on the text of the current buffer, starting from the point) in addition to the current (REGEXP . FUNCTION). That would allow reusing `image-jpeg-p' (once suitable adapted). /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Is there any reason not to just treat the regexps in auto-mode-alist as case insensitive? Is there any kind of file where the case of the extension matters? ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/13/06, Chris Moore [EMAIL PROTECTED] wrote: Is there any kind of file where the case of the extension matters? .Z files are compressed with compress, while .z files are from pack or early versions of gzip. Years ago it wasn't uncommon to find .C and .H for C++ source files. /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/13/06, Chris Moore [EMAIL PROTECTED] wrote: Juanma Barranquero [EMAIL PROTECTED] writes: That's a shame. It would have been an easy fix, rather than having to make all these special cases. Though I agree with you, that's a fix I wouldn't dare propose (note that I talked about `image-file-name-regexp', not `auto-mode-alist'). I get the distinct impression that some people using non-Windows environments would get really pissed if Emacs suddenly started to treat .ext and .EXT (for most values of ext) as the same thing. /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Chris Moore wrote: Is there any reason not to just treat the regexps in auto-mode-alist as case insensitive? Is there any kind of file where the case of the extension matters? .C is commonly used for c++ files where filenames are case-sensitive. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Juanma Barranquero [EMAIL PROTECTED] writes: I get the distinct impression that some people using non-Windows environments would get really pissed if Emacs suddenly started to treat .ext and .EXT (for most values of ext) as the same thing. I don't think they'd care in general, and might even approve. Like most people, even though I never use windows, I occasionally receive files from windows users, and there's lots of crufty old windows software that still uses DOS-like names. I think it's the special cases that you to be careful about, e.g., .c - c-mode, .C - c++-mode. -Miles -- My books focus on timeless truths. -- Donald Knuth ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
I guess it is a matter of taste, but I would prefer if Emacs uses the technique above instead of looking at the file name. An example of why this is useful: From my digital camera, each time I record a movie with it I get both an avi file and a thm file (I think that was the extension but it does not matter really), and it turns out that this extra thm file is a small thumbnail of the movie, in jpeg format. That seems like a valid reason. Would someone please install that change? It would be useful to recognize PNG and GIF as well this way. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Is there any kind of file where the case of the extension matters? In general it isn't correct for many of those regexps to match with the wrong case. This change can't be made. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
image.el doesn't associate image-mode with .JPG files
Lots of digital cameras create '.JPG' files (note: capital letters). Opening these files with Emacs opens them in fundamental mode, not image mode, since Emacs only associates image-mode with .jpg and .jpeg files. Adding this line to the default value of image-type-file-name-regexps in lisp/image.el would help: (\\.JPE?G\\' . jpeg) In GNU Emacs 22.0.91.28 (i686-pc-linux-gnu, GTK+ Version 2.8.20) of 2006-12-11 on chrislap X server distributor `The X.Org Foundation', version 11.0.70101000 configured using `configure '--with-gtk' '--prefix' '/usr/local/emacs22' '--with-xpm' '--with-jpeg' '--with-png' '--with-gif'' ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/12/06, Chris Moore [EMAIL PROTECTED] wrote: Opening these files with Emacs opens them in fundamental mode, not image mode, since Emacs only associates image-mode with .jpg and .jpeg files. `image-type-from-file-name' uses `string-match', which depends on the setting of `case-fold-search'. Adding this line to the default value of image-type-file-name-regexps in lisp/image.el would help: (\\.JPE?G\\' . jpeg) Perhaps the following patch would be more correct. After all, I don't think it will be common to have files with extensions .PNG, .TIFF, .BMP, etc. which are not images. /L/e/k/t/u Index: lisp/image.el === RCS file: /cvsroot/emacs/emacs/lisp/image.el,v retrieving revision 1.63 diff -u -2 -r1.63 image.el --- lisp/image.el 21 Apr 2006 20:56:06 - 1.63 +++ lisp/image.el 12 Dec 2006 10:59:47 - @@ -271,4 +271,5 @@ be determined. (let ((types image-type-file-name-regexps) + (case-fold-search t) type) (while types ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Juanma Barranquero [EMAIL PROTECTED] writes: Adding this line to the default value of image-type-file-name-regexps in lisp/image.el would help: (\\.JPE?G\\' . jpeg) Perhaps the following patch would be more correct. After all, I don't think it will be common to have files with extensions .PNG, .TIFF, .BMP, etc. which are not images. ... --- lisp/image.el 21 Apr 2006 20:56:06 - 1.63 +++ lisp/image.el 12 Dec 2006 10:59:47 - @@ -271,4 +271,5 @@ (let ((types image-type-file-name-regexps) + (case-fold-search t) Thought that's probably a reasoanble change, but it doesn't suffice in this case -- image-type-from-file-name is not called except when specifically dealing with an image, and Emacs never gets that far unless auto-mode-alist tells it to... -Miles -- `The suburb is an obsolete and contradictory form of human settlement' ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
On 12/12/06, Miles Bader [EMAIL PROTECTED] wrote: Thought that's probably a reasoanble change, but it doesn't suffice in this case -- image-type-from-file-name is not called except when specifically dealing with an image, and Emacs never gets that far unless auto-mode-alist tells it to... Ah. I wasn't aware, because on Windows machines, emacs TEST.JPEG opens it in image mode. If .JPG/.JPEG is frequent, perhaps we should add it to `auto-mode-alist', then. Or do this: (push '(^\xFF\xD8\xFF\xE0\x00\x10JFIF . image-mode) magic-mode-alist) /L/e/k/t/u ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Juanma Barranquero [EMAIL PROTECTED] writes: If .JPG/.JPEG is frequent, perhaps we should add it to `auto-mode-alist', then. Or do this: I don't know exactly how frequent it is, but every Canon digital camera I've seen uses the .JPG extension when saving in jpeg format. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
Perhaps the following patch would be more correct. After all, I don't think it will be common to have files with extensions .PNG, .TIFF, .BMP, etc. which are not images. It is more flexible to add the specific uppercase extensions, even if we add all of them. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
Re: image.el doesn't associate image-mode with .JPG files
If .JPG/.JPEG is frequent, perhaps we should add it to `auto-mode-alist', then. Or do this: (push '(^\xFF\xD8\xFF\xE0\x00\x10JFIF . image-mode) magic-mode-alist) I am not sure which is better, but I agree we should do one or the other. ___ emacs-pretest-bug mailing list emacs-pretest-bug@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug