Lars Ingebrigtsen writes: >> IMO GNU Emacs should open a PostScript file in >> adobe-standard-encoding, except it sees in the file that the font(s) >> used is (are) re-encoded in ISOLatin1Encoding (which is *not* the same >> as ISO 8819-1), CE Encoding, or whatever. > > I took a first stab at this, but this is obviously not correct. I'm not > sure how to detect whether it's a ISOLatin1Encoding file? And... I'm > this will probably make the file opened like this be saved in utf-8, > which isn't what we want... I tested this a bit more now, and it doesn't work. First of all, saving the file with adobe-standard-encoding means that all the newlines are stripped from the file. So I tried the patch below, but 1) it didn't display non-ascii chars correctly, and 2) when saving, I got: These default coding systems were tried to encode the following problematic characters in the buffer ‘a.ps’: Coding System Pos Codepoint Char adobe-standard-encoding-unix 1 #xA 4 #xA ... utf-8-unix 328 #x3FFFF3 I.e., it's complaining about the newlines, as well as the non-ASCII char. So it seems like the adobe coding system doesn't actually work, and I wonder whether anybody's ever tried using it before? Possibly not? I've never actually tried working with the coding system stuff before on this level, so I'm probably missing something really simple. The work-in-progress patch is below, as well as a .ps test file. Anybody see immediately what's wrong here? diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el index 9a68fce2e8..1fe4b5c55a 100644 --- a/lisp/international/mule-conf.el +++ b/lisp/international/mule-conf.el @@ -1637,6 +1637,7 @@ 'utf-7-imap ("\\.el\\'" . prefer-utf-8) ("\\.utf\\(-8\\)?\\'" . utf-8) ("\\.xml\\'" . xml-find-file-coding-system) + ("\\.ps\\'" . ps-find-file-coding-system) ;; We use raw-text for reading loaddefs.el so that if it ;; happens to have DOS or Mac EOLs, they are converted to ;; newlines. This is required to make the special treatment diff --git a/lisp/international/mule.el b/lisp/international/mule.el index 5022a17db5..b2945bbbf3 100644 --- a/lisp/international/mule.el +++ b/lisp/international/mule.el @@ -2526,6 +2526,17 @@ sgml-html-meta-auto-coding-function (message "Warning: unknown coding system \"%s\"" match) nil))))) +(defun ps-find-file-coding-system (args) + (if (not (eq (car args) 'insert-file-contents)) + 'undecided + (let ((coding-system + (coding-system-base + (detect-coding-region (point-min) (point-max) t)))) + ;; If it's an ASCII file, then interpret ` specially. + (if (memq coding-system '(undecided iso-latin-1)) + 'adobe-standard-encoding-unix + coding-system)))) + (defun xml-find-file-coding-system (args) "Determine the coding system of an XML file without a declaration. Strictly speaking, the file should be utf-8, but mistakes are -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no