From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Wedler, Christoph" Newsgroups: gmane.emacs.devel Subject: RE: [Bug] Issues with format.el: coding system, byte/char confusi on Date: Tue, 8 Apr 2003 20:01:22 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <67B8CED503F3D511BB9F0008C75DAD6605485571@dewdfx17> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: main.gmane.org 1049825288 15570 80.91.224.249 (8 Apr 2003 18:08:08 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 8 Apr 2003 18:08:08 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Apr 08 20:08:06 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 192xV4-0003y8-00 for ; Tue, 08 Apr 2003 20:07:14 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 192xZA-00008o-00 for ; Tue, 08 Apr 2003 20:11:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 192xSy-00040q-03 for emacs-devel@quimby.gnus.org; Tue, 08 Apr 2003 14:05:04 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 192xSI-0003vJ-00 for emacs-devel@gnu.org; Tue, 08 Apr 2003 14:04:22 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 192xRj-0003bn-00 for emacs-devel@gnu.org; Tue, 08 Apr 2003 14:03:54 -0400 Original-Received: from smtpde02.sap-ag.de ([155.56.68.170]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 192xPU-0001cV-00; Tue, 08 Apr 2003 14:01:28 -0400 Original-Received: from sap-ag.de (smtpde02) by smtpde02.sap-ag.de (out) with ESMTP id UAA05437; Tue, 8 Apr 2003 20:01:41 +0200 (MESZ) Original-To: "'rms@gnu.org'" X-Mailer: Internet Mail Service (5.5.2656.59) X-SAP: out X-SAP: out X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13033 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13033 > 1. Shouldn't `format-annotate-function' also save the buffer-local > variable `buffer-file-coding-system' (as it does with > `selective-display' and `enable-multibyte-characters' since v1.38)? > That seems plausible, but one ought to test it. Currently, I do it in the format-encode function of my package X-Symbol since July 2002 (it wouldn't work without), but I think this should be done in general. > 2. To compute the coding system of the current buffer, Emacs adds > function `after-insert-file-set-buffer-file-coding-system' to > `after-insert-file-functions'. Is this correct? > Yes. > - decode functions using format.el, > - decode functions in `after-insert-file-functions' before > `after-insert-file-set-buffer-file-coding-system', > - Emacs determines the coding system with > `after-insert-file-set-buffer-file-coding-system', > - decode functions in `after-insert-file-functions' after > `after-insert-file-set-buffer-file-coding-system' > That would be true, if there is anything in > after-insert-file-functions other than > after-insert-file-set-buffer-file-coding-system. Normally I believe > there isn't anything else. What does this mean? Is `after-insert-file-functions' obsolete without being declared as such? > I would assume that the coding system must be determined before any > of the decode functions have been executed... > Not necessarily. That would depend on what those other functions are. > Normally there aren't any others. I suppose if you add other functions > to this hook that you should put them in the proper order. As I said, the coding system is determined not only after some functions in this hook, but also after the format-decode functions. I also don't think that the order is correct (if after-insert-file-set-buffer-file-coding-system doesn't do much, it might not matter): since the `buffer-file-coding-system' is used to save the RESULT of the format encode functions, it must be determined BEFORE the format-decode functions have been executed. > Is there any real example where this question arises, or is it > purely hypothetical. I'm not sure since I don't know what `after-insert-file-set-buffer-file-coding-system' does exactly (is it more than eol-type handling?). > 3. The docstring of `after-insert-file-functions' includes "It should > return the new byte count", whereas `format-decode' returns the > new char count. > It looks like they are really both measured in characters. > I will fix some doc strings. In this case, you might also want to check (`position-bytes', but this might be OK): (defun after-insert-file-set-buffer-file-coding-system (inserted) ... (let ((pos-byte (position-bytes (+ (point) inserted)))) (set-buffer-multibyte nil) (setq inserted (- pos-byte (position-bytes (point)))))) (set-buffer-modified-p modified-p)))) inserted) - Christoph