unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Peter Dyballa <Peter_Dyballa@Freenet.DE>
Cc: 7786@debbugs.gnu.org
Subject: bug#7786: 23.2; Encoding of PostScript files
Date: Wed, 13 Oct 2021 14:49:26 +0200	[thread overview]
Message-ID: <875yu16qeh.fsf@gnus.org> (raw)
In-Reply-To: <877djcek3s.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 02 Jun 2021 10:39:19 +0200")

[-- Attachment #1: Type: text/plain, Size: 3260 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> 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

[-- Attachment #2: a.ps --]
[-- Type: application/postscript, Size: 331 bytes --]

  parent reply	other threads:[~2021-10-13 12:49 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05  0:18 bug#7786: 23.2; Encoding of PostScript files Peter Dyballa
2021-01-20 18:02 ` Lars Ingebrigtsen
2021-06-02  8:39 ` Lars Ingebrigtsen
2021-06-02 16:37   ` Peter Dyballa
2021-10-13 12:49   ` Lars Ingebrigtsen [this message]
2021-10-13 13:12     ` Lars Ingebrigtsen
2021-10-13 13:51 ` Lars Ingebrigtsen
2021-10-13 15:41   ` Eli Zaretskii
2021-10-13 16:05     ` Lars Ingebrigtsen
2021-10-13 16:18       ` Eli Zaretskii
2021-10-13 16:20         ` Lars Ingebrigtsen
2021-10-13 16:23           ` Peter Dyballa
2021-10-13 16:28             ` Lars Ingebrigtsen
2021-10-13 16:43               ` Peter Dyballa
2021-10-13 16:45             ` Eli Zaretskii
2021-10-13 17:35               ` Peter Dyballa
2021-10-13 16:43           ` Eli Zaretskii
2021-10-13 18:55             ` Lars Ingebrigtsen
2021-10-13 19:05               ` Eli Zaretskii
2021-10-13 19:07               ` Peter Dyballa
2021-10-13 21:02   ` Peter Dyballa
2021-10-14  6:42     ` Eli Zaretskii
2021-10-15 12:47       ` Lars Ingebrigtsen
2021-10-15 15:59         ` Peter Dyballa
2021-10-18  7:09           ` Lars Ingebrigtsen
2021-10-18 12:25             ` Eli Zaretskii
2021-10-18 13:17               ` Lars Ingebrigtsen
2021-10-18 15:51               ` Peter Dyballa
2021-10-18 16:00                 ` Eli Zaretskii
2021-10-19  5:49                   ` Peter Dyballa
2021-10-19 11:59                     ` Eli Zaretskii
2021-10-19 13:47                       ` Lars Ingebrigtsen
2021-10-20  5:39                         ` Peter Dyballa
2021-10-20  5:45                           ` Lars Ingebrigtsen
2021-10-20  6:18                             ` Lars Ingebrigtsen
2021-10-20 16:34                             ` Peter Dyballa
2021-10-13 21:55   ` Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yu16qeh.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=7786@debbugs.gnu.org \
    --cc=Peter_Dyballa@Freenet.DE \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).