From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: decode-coding-string gone awry? Date: Mon, 14 Feb 2005 13:12:03 -0500 Message-ID: References: <874qgf1dkv.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1108405061 21273 80.91.229.2 (14 Feb 2005 18:17:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 14 Feb 2005 18:17:41 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 14 19:17:41 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D0kmS-0003GL-T9 for ged-emacs-devel@m.gmane.org; Mon, 14 Feb 2005 19:17:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D0l22-0007jN-RB for ged-emacs-devel@m.gmane.org; Mon, 14 Feb 2005 13:33:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D0kzh-0006Ve-Hc for emacs-devel@gnu.org; Mon, 14 Feb 2005 13:30:50 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D0kzf-0006Tz-8d for emacs-devel@gnu.org; Mon, 14 Feb 2005 13:30:47 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D0kze-0006S5-O6 for emacs-devel@gnu.org; Mon, 14 Feb 2005 13:30:46 -0500 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D0ki4-0005H1-PW; Mon, 14 Feb 2005 13:12:37 -0500 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 4D7F58282C5; Mon, 14 Feb 2005 13:12:36 -0500 (EST) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id ACFA24AC1CE; Mon, 14 Feb 2005 13:12:03 -0500 (EST) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 87A8A4BCF2; Mon, 14 Feb 2005 13:12:03 -0500 (EST) Original-To: David Kastrup In-Reply-To: (David Kastrup's message of "Mon, 14 Feb 2005 18:24:55 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-4.795, requis 5, AWL 0.10, BAYES_00 -4.90) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: main.gmane.org gmane.emacs.devel:33405 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:33405 >> instead of being processed directly from the process filter, then >> you should also ensure that this buffer is unibyte. > Yuk. The problem is that this buffer is not only processed by > preview-latex, but also by AUCTeX, and the versions that get combined > may be different. AUCTeX uses the source code buffer's file encoding > by default, which is fine for basically unibyte based coding systems. If you can't change this part, then your best bet might be to do something like: (defun preview-error-quote (string) "Turn STRING with potential ^^ sequences into a regexp. To preserve sanity, additional ^ prefixes are matched literally, so the character represented by ^^^ preceding extended characters will not get matched, usually." (let (output case-fold-search) (while (string-match "\\^*\\(\\^\\^\\(\\([@-_?]\\)\\|[8-9a-f][0-9a-f]\\)\\)+" string) (setq output (concat output (regexp-quote (substring string 0 (match-beginning 1))) (decode-coding-string (preview-dequote-thingies (substring (match-beginning 1) (match-end 0))) buffer-file-coding-system)) string (substring string (match-end 0)))) (setq output (concat output (regexp-quote string))) output))) BTW, you can use the 3rd arg to string-match to avoid consing strings for `string'. This way you only apply decode-coding-string to the part of the string which is still undecoded but not to the rest. Stefan