From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: How to get rid of Microsoft dumb quotes, e.g. \222 for apostrophe? Date: Fri, 16 Feb 2007 20:47:11 -0500 Message-ID: References: <1171628373.417583.61410@k78g2000cwa.googlegroups.com> <87zm7e8e7j.fsf@wivenhoe.staff8.ul.ie> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1171680040 5992 80.91.229.12 (17 Feb 2007 02:40:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 17 Feb 2007 02:40:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 17 03:40:33 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 1HIFV2-0005aq-O4 for geh-help-gnu-emacs@m.gmane.org; Sat, 17 Feb 2007 03:40:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HIFV2-0006vd-AJ for geh-help-gnu-emacs@m.gmane.org; Fri, 16 Feb 2007 21:40:32 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.umontreal.ca!news.umontreal.ca.POSTED!not-for-mail Original-NNTP-Posting-Date: Fri, 16 Feb 2007 19:47:11 -0600 Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux) Cancel-Lock: sha1:3Zr3JoLunfodmHjQkyO/pLa8aqk= Original-Lines: 31 Original-NNTP-Posting-Host: 132.204.27.213 Original-X-Trace: sv3-I8JtwSKFqJb3M3GrxXr3SGyzJq/t0RfN8NYd1mPsVLVQez8DweUzPakP58CR6dgRbmAlwXMuq5R1SQW!3DZLRqWv5rqRMRTSXSH6JMkT6keZyDeNrTUZVbTPaRGnWqI4vOKFcs8iaE8f02UCLHc1z5hYHd1x!9n9dSait3G9ldPDNWw== Original-X-Complaints-To: abuse@umontreal.ca X-DMCA-Complaints-To: abuse@umontreal.ca X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Original-Xref: shelby.stanford.edu gnu.emacs.help:145663 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:41268 Archived-At: > (while (re-search-forward "[€-Ÿ]" nil t) > (let ((mschar (buffer-substring-no-properties > (match-beginning 0) (match-end 0)))) > (cond > ((string= mschar "‘") (replace-match "`" )) > ((string= mschar "’") (replace-match "'" )) > ((string= mschar "“") (replace-match "``")) > ((string= mschar "”") (replace-match "''")) > ((string= mschar "–") (replace-match "--"))))) Better work on chars rather than strings of one-char. Also better not use those special chars that are sometimes displayed as \200 and use the \ 2 0 0 escape sequence instead: (require 'cl) (defun my-fun-foo () (interactive) (goto-char (point-min)) (while (re-search-forward "[\200-\237]" nil t) (case (char-before) (?\221 (replace-match "`" )) (?\222 (replace-match "'" )) (?\233 (replace-match "``")) (?\224 (replace-match "''")) (?\226 (replace-match "--"))))) -- Stefan PS: Guaranteed 100% untested.