From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#27391: 25.2.50; utf-8 coding cookie is not applied on some specific markdown file Date: Fri, 16 Jun 2017 21:34:26 +0000 Message-ID: References: <841sqkdzh5.fsf@gmail.com> <84zid7y668.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a113cc70c50656905521a8d33" X-Trace: blaine.gmane.org 1497648915 29666 195.159.176.226 (16 Jun 2017 21:35:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 16 Jun 2017 21:35:15 +0000 (UTC) To: Vincent =?UTF-8?Q?Bela=C3=AFche?= , Eli Zaretskii , 27391@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jun 16 23:35:09 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLytY-0007F1-CW for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Jun 2017 23:35:08 +0200 Original-Received: from localhost ([::1]:60793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLytb-0003R8-OA for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Jun 2017 17:35:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLytW-0003Pw-1t for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2017 17:35:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLytS-0001NQ-22 for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2017 17:35:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLytR-0001Mf-UP for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2017 17:35:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dLytR-0006HX-Lm for bug-gnu-emacs@gnu.org; Fri, 16 Jun 2017 17:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Jun 2017 21:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27391 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27391-submit@debbugs.gnu.org id=B27391.149764888424117 (code B ref 27391); Fri, 16 Jun 2017 21:35:01 +0000 Original-Received: (at 27391) by debbugs.gnu.org; 16 Jun 2017 21:34:44 +0000 Original-Received: from localhost ([127.0.0.1]:51761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLytA-0006Gu-4k for submit@debbugs.gnu.org; Fri, 16 Jun 2017 17:34:44 -0400 Original-Received: from mail-oi0-f44.google.com ([209.85.218.44]:36447) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLyt8-0006Ge-QZ for 27391@debbugs.gnu.org; Fri, 16 Jun 2017 17:34:43 -0400 Original-Received: by mail-oi0-f44.google.com with SMTP id k145so30774019oih.3 for <27391@debbugs.gnu.org>; Fri, 16 Jun 2017 14:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=iHh7L4mO9m1ExY9TmVVfe11t1erJ+RFvlfwxePjE3B4=; b=pYBxpDgN+hgAPBGmVmbdCzyOHGmW5i6LqGRIo5Wacg7NAOsZG9UsTCPAJssSfOneBS rpRvWGNjrrT5Zhsd+XqN8BtnQ4qNVdNDOZsBtZS3kkDs63licqCGEKAhd6HocFv7oZWh Mslq7TRNY5ZGktOx2izxhcWeKgFq/x68TY0S52hNxZRfWFDZQiBg1pkzlk4NGWXxWmrs FSct/tPlEQvzlyZInrn+bnNJwjaxRjj6ZkGfXILT/V0q+OENwGYoohunlTvat97y7lgj /yeJOKcmgOQcrcashm8fiiDucR/O0Tl6ReQW2LdsdnA3TDYP+iEibTz+j3R5r1llmzQZ we7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=iHh7L4mO9m1ExY9TmVVfe11t1erJ+RFvlfwxePjE3B4=; b=NkWpF5h9hpV8DV2PMzU0SosdT0gJELk9tL1EwFf6EguXf4BpJHkiigDwTSfFUGtfSo R3kpR+L2gmnaDKyIx6Q9q3d4hLbb0zhRCju6qOLJsBU4ciaVgDFvZD39M4gNHHjlclWp pla96iyjZFtEsBv9aUmE2E9pPv2gVxobXYhQ8uRWI5QfvAsYxnsYev546/bdg1Knc//f gI0Ea3VNzEVsu3Mxh4NF6U7oOHtmv+empmsprTWrw+0nzcPZINqLrdDr1FQyDLCAqgxD OqJG9qtqn7gguMfGkOvBJRt66GsIUTLUJhCPId7hq91HFIn7M+lxjn2eSANrB9mz94ty ZRzg== X-Gm-Message-State: AKS2vOxgQ8EdVINYvwZhVqi9lbetuf3APLfWnEzkIMQ526RF7+4jEb+I MwAVUggbo/d9JO7tih9ElAceZR3qEA== X-Received: by 10.202.235.12 with SMTP id j12mr6370606oih.2.1497648877035; Fri, 16 Jun 2017 14:34:37 -0700 (PDT) In-Reply-To: <84zid7y668.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:133670 Archived-At: --001a113cc70c50656905521a8d33 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Vincent Bela=C3=AFche schrieb am Fr., 16. Juni= 2017 um 23:28 Uhr: > > > Le 16/06/2017 =C3=A0 21:37, Vincent Bela=C3=AFche a =C3=A9crit : > > > > > > Le 16/06/2017 =C3=A0 21:15, Vincent Bela=C3=AFche a =C3=A9crit : > >> > > [...] > > >> > >> > > After some more investigation, I think that the bug is in function > > insert-file-contents of fileio.c which is the one that decide and sets > > the coding system well before the other local variables are looked into= . > > After some more investigation, in the end the find-auto-coding of > mule.el is what is called to detect the coding. This function calls some > re-coding regexp. > > Here is a test function defining the same regexp. > > > (defun doit () > (interactive) > (let* ((prefix (regexp-quote "[comment]: # (")) > (suffix (regexp-quote ")")) > (re-coding > (concat > "[\r\n]" prefix > ;; N.B. without the \n below, the regexp can > ;; eat newlines. > "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*" > suffix "[\r\n]"))) > (message (if (looking-at re-coding) "ok" "nak")))) > > I tried it with point at end of line > > [comment]: # ( Local Variables: ) > > and it answered "ok". Now I defined this with re-search-forward instead > of looking-at: > > (defun doit () > (interactive) > (let* ((prefix (regexp-quote "[comment]: # (")) > (suffix (regexp-quote ")")) > (re-coding > (concat > "[\r\n]" prefix > ;; N.B. without the \n below, the regexp can > ;; eat newlines. > "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*" > suffix "[\r\n]"))) > (message (if (re-search-forward re-coding nil t) "ok" "nak")))) > > I placed the point before the coding: line, and I also got answer "ok" > > So I don't think that the regexp as such is to blame. Something else > seems to happen. It is too late now, I need to go to bed... > > Vincent. > > I think it's actually the regexp that searches for "Local Variables". The following minimal example fails for me: (with-temp-buffer (insert " [comment]: # ( Local Variables: ) [comment]: # ( coding: utf-8 ) [comment]: # ( End: ) ") (goto-char (point-min)) (re-search-forward "[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]")) --001a113cc70c50656905521a8d33 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Vincen= t Bela=C3=AFche <vincent.b= elaiche@gmail.com> schrieb am Fr., 16. Juni 2017 um 23:28=C2=A0Uhr:<= br>


Le 16/06/2017 =C3=A0 21:37, Vincent Bela=C3=AFche a =C3=A9crit :
>
>
> Le 16/06/2017 =C3=A0 21:15, Vincent Bela=C3=AFche a =C3=A9crit :
>>

[...]

>>
>>
> After some more investigation, I think that the bug is in function
> insert-file-contents of fileio.c which is the one that decide and sets=
> the coding system well before the other local variables are looked int= o.

After some more investigation, in the end the find-auto-coding of
mule.el is what is called to detect the coding. This function calls some re-coding regexp.

Here is a test function defining the same regexp.


(defun doit ()
=C2=A0 (interactive)
=C2=A0 (let* ((prefix (regexp-quote "[comment]: # ("))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(suffix (regexp-quote ")"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(re-coding
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"[\r\n]" prefix
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; N.B. without the \n below, the = regexp can
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; eat newlines.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"[ \t]*coding[ \t]*:[ \t]*\\(= [^ \t\r\n]+\\)[ \t]*"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0suffix "[\r\n]")))
=C2=A0 =C2=A0 (message (if (looking-at re-coding) "ok" "nak&= quot;))))

I tried it with point at end of line

[comment]: # ( Local Variables: )

and it answered "ok". Now I defined this with re-search-forward i= nstead
of looking-at:

(defun doit ()
=C2=A0 (interactive)
=C2=A0 (let* ((prefix (regexp-quote "[comment]: # ("))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(suffix (regexp-quote ")"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(re-coding
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (concat
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"[\r\n]" prefix
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; N.B. without the \n below, the = regexp can
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; eat newlines.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"[ \t]*coding[ \t]*:[ \t]*\\(= [^ \t\r\n]+\\)[ \t]*"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0suffix "[\r\n]")))
=C2=A0 =C2=A0 (message (if (re-search-forward re-coding nil t) "ok&quo= t; "nak"))))

I placed the point before the coding: line, and I also got answer "ok&= quot;

So I don't think that the regexp as such is to blame. Something else seems to happen. It is too late now, I need to go to bed...

=C2=A0 Vincent.


I think it's actually the regexp that = searches for "Local Variables". The following minimal example fai= ls for me:

(with-temp-buffer
=C2=A0= (insert "

[comment]: # ( Local Variables: )<= /div>
[comment]: # ( coding: utf-8 )
[comment]: # ( End: )

")
(goto-char (point-min))
(re-search-forward
=C2=A0"[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^= \r\n]*\\)[\r\n]"))

--001a113cc70c50656905521a8d33--