emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ^M in the info files


From: Juanma Barranquero
Subject: Re: ^M in the info files
Date: Thu, 7 Aug 2008 15:01:07 +0200

On Thu, Aug 7, 2008 at 05:47, Kenichi Handa <address@hidden> wrote:

> I don't see any bad effect to it.  But, as I'm not familiar
> with the code of info, I don't know which place is the best
> to bind that variable.

I've tried implementing your suggestion; see the attached patch.

It works for uncompressed info files, and for compressed ones when
auto-compression-mode is off.
However, when auto-compression-mode is on, the conversion depends on
the settings of `file-coding-system-alist' for the given compression
method.

   Juanma



Index: src/coding.c
===================================================================
RCS file: /sources/emacs/emacs/src/coding.c,v
retrieving revision 1.390
diff -u -2 -r1.390 coding.c
--- src/coding.c        9 Jul 2008 13:05:56 -0000       1.390
+++ src/coding.c        7 Aug 2008 10:42:46 -0000
@@ -381,4 +381,7 @@
 int inhibit_iso_escape_detection;

+/* Flag to inhibit detection of binary files through null bytes.  */
+int inhibit_null_byte_detection;
+
 /* Flag to make buffer-file-coding-system inherit from process-coding.  */
 int inherit_process_coding_system;
@@ -5895,5 +5898,5 @@
          if (i < coding_category_raw_text)
            setup_coding_system (CODING_ID_NAME (this->id), coding);
-         else if (null_byte_found)
+         else if (null_byte_found && ! inhibit_null_byte_detection)
            setup_coding_system (Qno_conversion, coding);
          else if ((detect_info.rejected & CATEGORY_MASK_ANY)
@@ -10233,4 +10236,23 @@
   inhibit_iso_escape_detection = 0;

+  DEFVAR_BOOL ("inhibit-null-byte-detection",
+              &inhibit_null_byte_detection,
+              doc: /*
+If non-nil, Emacs ignores null bytes on code detection.
+
+By default, on reading a file, Emacs tries to detect how the text is
+encoded.  This code detection is sensitive to null bytes.  If the
+text contains null bytes, the file is determined as containing
+binary data.
+
+However, there may be a case that you want to read non-binary data
+that contains null bytes.  In such a case, you can set this variable
+to non-nil.
+
+The default value is nil, and it is strongly recommended not to change
+it.  This variable is intended to be bound to t in the few instances
+where that is useful, for example to read certain info files.  */);
+  inhibit_null_byte_detection = 0;
+
   DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input,
               doc: /* Char table for translating self-inserting characters.
Index: lisp/info.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/info.el,v
retrieving revision 1.540
diff -u -2 -r1.540 info.el
--- lisp/info.el        30 Jul 2008 17:16:46 -0000      1.540
+++ lisp/info.el        7 Aug 2008 11:20:36 -0000
@@ -456,5 +456,6 @@
            (apply 'call-process-region (point-min) (point-max)
                   (car decoder) t t nil (cdr decoder))))
-      (insert-file-contents fullname visit))))
+      (let ((inhibit-null-byte-detection t))
+       (insert-file-contents fullname visit)))))
 
 (defun Info-default-dirs ()

reply via email to

[Prev in Thread] Current Thread [Next in Thread]