From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: replacing characters and whacky trans-buffer conversion Date: Fri, 09 Mar 2007 05:15:02 -0500 Message-ID: <45F133A6.8090308@speakeasy.net> References: <45ED8574.3040201@speakeasy.net> <45EF2512.9060200@speakeasy.net> <45EF28B8.2050905@speakeasy.net> <953CC6C7-14E6-4321-8899-665613380DC2@Web.DE> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1173435448 3359 80.91.229.12 (9 Mar 2007 10:17:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 9 Mar 2007 10:17:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 09 11:17:22 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HPcA5-0001mx-9R for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Mar 2007 11:17:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HPcAM-0003jW-Mo for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Mar 2007 05:17:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HPc8G-00033b-6c for help-gnu-emacs@gnu.org; Fri, 09 Mar 2007 05:15:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HPc8F-000321-5S for help-gnu-emacs@gnu.org; Fri, 09 Mar 2007 05:15:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HPc8E-00031g-P7 for help-gnu-emacs@gnu.org; Fri, 09 Mar 2007 05:15:26 -0500 Original-Received: from mail8.sea5.speakeasy.net ([69.17.117.10]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HPc7u-0000lG-Fo for help-gnu-emacs@gnu.org; Fri, 09 Mar 2007 05:15:06 -0500 Original-Received: (qmail 10289 invoked from network); 9 Mar 2007 10:15:04 -0000 Original-Received: from dsl093-011-017.cle1.dsl.speakeasy.net (HELO [192.168.0.27]) (gebser@[66.93.11.17]) (envelope-sender ) by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 9 Mar 2007 10:15:03 -0000 User-Agent: Thunderbird 2.0pre (X11/20070214) In-Reply-To: X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:41822 Archived-At: On 03/08/2007 08:51 PM somebody named Stefan Monnier wrote: >>>> The first buffer is a *scratch* buffer, the modeline starts "--:". The >>>> second contains the *.el file mentioned in the original post; its >>>> modeline begins "-:". >>> For some reason this second buffer is in unibyte mode. >>> That's the source of your problem. Tell us how you created that buffer. > >> C-x C-f > > Hmm, that doesn't say much. > Tell us the value of C-h v default-enable-multibyte-characters. > Also shows us the first few and last few lines of the file. In both the *.el file and in the *scratch* buffer default-enable-multibyte-characters is t. Here's the entirety of the *.el file: ;Replace goofy MS chars with latin1 equivalents. ;You can, of course, add to the list of chars. ; Multi-byte strings such as the one below should be toward ; the top of the list so that single-byte replacements don't ; cut them up, making subsequent searches for them impossible. ;"—" => "--" ; Also, to enter the escaped numbers, e.g. "\221", do ; C-q 2 2 1 RETURN. ;To discover the code for a new (garbage) char to be replaced, ;put the point over it and do "C-x="; the first code returned in ;the minibuffer tells you the escaped number you want to replace. ;Wrote up more on this at ; (defun replace-garbage-chars () "Replace goofy MS and other garbage characters with latin1 equivalents." (interactive) (save-excursion ;save the current point (replace-string "—" "--" nil (point-min) (point-max)); multi-byte (replace-string "“" "``" nil (point-min) (point-max)) (replace-string "–" "--" nil (point-min) (point-max)) (replace-string "–" "'" nil (point-min) (point-max)) (replace-string "k," "i" nil (point-min) (point-max)) (replace-string "¢" "'" nil (point-min) (point-max)) (replace-string "”" "'" nil (point-min) (point-max)) (replace-string "?" "`" nil (point-min) (point-max)) (replace-string "?" "'" nil (point-min) (point-max)) (replace-string "?" "``" nil (point-min) (point-max)) (replace-string "?" "''" nil (point-min) (point-max)) (replace-string "?" "--" nil (point-min) (point-max)) )) -- "Genius might be described as a supreme capacity for getting its possessors into trouble of all kinds." -- Samuel Butler