Re: File type misclassification

2007-03-25 Thread Daniel Pfeiffer

Salut Stefan,

la 21.03.2007 15:21 Stefan Monnier skribis:

Daniel,

do you remember why you put an entry

  (%![^V] . ps-mode)

in magic-mode-alist?  Did it just seem like a good idea or was there
some particular (set of) circumstances you had bumped into that called
for it?
  
I don't remember, but I checked this:  The way I read magic, a 
conforming document must start with %!PS, but a non confirming one only 
with %!.  The -- maybe not so important -- exception is:


# This would otherwise be recognized as PostScript - [EMAIL PROTECTED]
0string%!VMF SunClock's Vector Map Format data

Btw. on SuSE 10.1 this magic entry is ignored by the file command, 
maybe because it comes too late in the file.



Juanma == Juanma Barranquero [EMAIL PROTECTED] writes:



  

On 3/21/07, Stefan Monnier [EMAIL PROTECTED] wrote:



  

Who put this entry in magic-mode-alist, and why?
  


  

It's there since the beginning, at least according to ViewCVS
(files.el, revision 1.720) and lisp/ChangeLog.11:



  

2004-11-03  Daniel Pfeiffer  [EMAIL PROTECTED]



  

   * files.el (xml-based-modes): Delete var.
   (magic-mode-alist): New more general var.
   (set-auto-mode): Use it.



  

Juanma



  



coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

--
lerne / learn / apprends / lär dig / ucz sięEsperanto:
   http://lernu.net  /  http://ikurso.net

___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-25 Thread Stefan Monnier
 do you remember why you put an entry
 
 (%![^V] . ps-mode)
 
 in magic-mode-alist?  Did it just seem like a good idea or was there
 some particular (set of) circumstances you had bumped into that called
 for it?
 
 I don't remember, but I checked this:  The way I read magic, a conforming
 document must start with %!PS, but a non confirming one only with %!.

Thanks.  I.e. you just thought it would be a good idea.

The question we were discussing is what Emacs should do with it, so what the
standard says is not really important (this is very different from what
`file' should do).  And since Emacs usually uses file-name extensions to
determine the mode of a file, it's important to only use magic-mode-alist in
those rare cases where it's really important in practice.


Stefan


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread David Kastrup
Stefan Monnier [EMAIL PROTECTED] writes:

 Sigh.  Seems like a magic string for the TeXshop TeX editor.  But I
 think just ruling out [VT] is still asking for trouble.
 I think a bug report to the TeXshop is in order.
 Uh, you people are joking, right?

 Nope!

 It is not a bug in TeXshop if Emacs' magic-mode-alist goes out of control
 and calls everything PostScript.

 The %! thingy is not Emacs's invention.  It's how postscript was
 specified.

The only relevant standard I can find starts off with %!PS-Adobe.
In contrast, %! is far too generic to be useful.  It may be a
heuristic for a PostScript interpreter to decide whether it is getting
fed PostScript on stdin.  But it does not sound like a useful
heuristic for a text editor to decide whether a named file contains
PostScript code or anything else.

 And for that reason `file greek-utf8.tex' agrees with Emacs.

 This said, I'd be happy to see the %! entry removed from
 magic-mode-alist, because I think magic-mode-alist should really be
 kept to its absolute strictest minimum.

I don't think that %!PS has comparable potential to do accidental
harm.  Whether it does noticeable good is a different question
altogether.

However, dvips -i produces PostScript files where the extension is
replaced by a serial number.  Those will not be recognized as
PostScript without magic number detection.  %!PS is completely
sufficient for that purpose, however.

I think that little except hand-crafted PostScript would ever start
with %! alone, and hand-crafted PostScript will have a proper file
name.

Even if one uses
dvips -N
(which disabled structured comments) the file starts with
%!PS (but not EPSF; comments have been disabled)

So I think that %!PS _does_ have some usefulness, and it is clearly
not as overboard as %!.

-- 
David Kastrup


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread David Kastrup
Juanma Barranquero [EMAIL PROTECTED] writes:

 On 3/21/07, Stefan Monnier [EMAIL PROTECTED] wrote:

 because I think magic-mode-alist should really be kept to its absolute
 strictest minimum.

 Certainly, it should only be used for file formats which are often
 found without a telling file extension. Alas, it seems like Postscript
 is one of those.

Do you have an example for a Postscript file on your system that is
neither identified by the magic string %!PS nor an appropriate
extension?

-- 
David Kastrup


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread Juanma Barranquero

On 3/21/07, David Kastrup [EMAIL PROTECTED] wrote:


Do you have an example for a Postscript file on your system that is
neither identified by the magic string %!PS nor an appropriate
extension?


No. But I don't understand your question. I was agreeing with you
(yeah, it happens sometimes).

Juanma


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread David Kastrup
Juanma Barranquero [EMAIL PROTECTED] writes:

 On 3/21/07, David Kastrup [EMAIL PROTECTED] wrote:

 Do you have an example for a Postscript file on your system that is
 neither identified by the magic string %!PS nor an appropriate
 extension?

 No. But I don't understand your question. I was agreeing with you
 (yeah, it happens sometimes).

Basically, we have three proposals (partly proposed by previously
existing code):

a) accept %! as magic PostScript override (previous behavior)
b) accept %!PS as magic override (what I proposed and checked in)
c) don't accept any magic postscript override

When arguing against c), it is not clear whether you agree with a)
being a sufficiently bad idea.

I had one example file causing problems with option a), and I already
gave examples for files requiring b) (those produced using dvips -i
don't have an extension, but in all cases start with %!PS).

My point of view is that b) nowadays appears like the most
pragmatically useful option, judging from problematic cases I have
seen.

If people can live with that, I suggest we leave it at that.  While
there are arguments for the other choices, we had them mentioned
(Stefan's argument that magic should be kept to a minimum certainly
_is_ valid) and, I believe, considered.  Repeating them will just
waste time.

If people feel that they have been weighed wrongly, the way to resolve
this is not repeating arguments, but vote on the resolution.

Anybody who feels that the current solution b) as checked in by myself
is not the best solution?

If so, I'd want to either hear new arguments or have a vote.

Everything else seems like a waste of time.

-- 
David Kastrup


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread Stefan Monnier
 In contrast, %! is far too generic to be useful.  It may be a
 heuristic for a PostScript interpreter to decide whether it is getting
 fed PostScript on stdin.  But it does not sound like a useful
 heuristic for a text editor to decide whether a named file contains
 PostScript code or anything else.

Complete agreement.  But it still means that TeXshop should avoid the %!
magic characters because they have a conflicting meaning in some contexts.

I don't claim that TeXshop should change for the sake of Emacs: it should
change because its choice is fundamentally wrong, whether that bites Emacs
users or not is irrelevant.

 This said, I'd be happy to see the %! entry removed from
 magic-mode-alist, because I think magic-mode-alist should really be
 kept to its absolute strictest minimum.

 I don't think that %!PS has comparable potential to do accidental
 harm.  Whether it does noticeable good is a different question
 altogether.

Obviously using a stricter regexp is good in my book since it means that
magic-mode-alist is used less often.

 However, dvips -i produces PostScript files where the extension is
 replaced by a serial number.  Those will not be recognized as
 PostScript without magic number detection.  %!PS is completely
 sufficient for that purpose, however.

Well, I find the likelihood of someone trying to edit with Emacs the output
of dvips -i sufficiently low that it doesn't justify in my eye the use of
a magic-mode-alist entry for it.  That's just an opinion.  Maybe a better
solution is to make dvips output file names of the form foo.NNN.ps rather
than foo.ps.NNN.

 So I think that %!PS _does_ have some usefulness, and it is clearly
 not as overboard as %!.

We agree that it's a step in the right direction.


Stefan


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread Stefan Monnier
Daniel,

do you remember why you put an entry

  (%![^V] . ps-mode)

in magic-mode-alist?  Did it just seem like a good idea or was there
some particular (set of) circumstances you had bumped into that called
for it?


Stefan


 Juanma == Juanma Barranquero [EMAIL PROTECTED] writes:

 On 3/21/07, Stefan Monnier [EMAIL PROTECTED] wrote:

 Who put this entry in magic-mode-alist, and why?

 It's there since the beginning, at least according to ViewCVS
 (files.el, revision 1.720) and lisp/ChangeLog.11:

 2004-11-03  Daniel Pfeiffer  [EMAIL PROTECTED]

* files.el (xml-based-modes): Delete var.
(magic-mode-alist): New more general var.
(set-auto-mode): Use it.

 Juanma


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-21 Thread Miles Bader
David Kastrup [EMAIL PROTECTED] writes:
 a) accept %! as magic PostScript override (previous behavior)
 b) accept %!PS as magic override (what I proposed and checked in)
 c) don't accept any magic postscript override
...
 My point of view is that b) nowadays appears like the most
 pragmatically useful option, judging from problematic cases I have
 seen.

I agree.  (b) is the conservative change.

% is a common enough comment character that I can see %! as being
slightly risky, but %!PS is far less so.

-Miles

-- 
1971 pickup truck; will trade for guns


___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug


Re: File type misclassification

2007-03-20 Thread Richard Stallman
1) Restrict the magic for PostScript files to %!PS

 (%!PS . ps-mode)

Do Postscript files normally start with `%!PS'?  If so, that
change is clearly correct. 

2) Recognize the specific case of TEX

 (%![^VT] . ps-mode)

In TeX, the % is a comment character.  There is no reason
for it to be followed by `!TEX'.

Is there some convention about using %! to start a file
which is being followed here?  It looks like one is in use,
but I have never heard of it.


To take this out of magic-mode-alist, and leave recognition of
Postscript to file names alone, might be a good change, but I am not
sure of usage practices.




___
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug