[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I search for symbols such as \253 in Emacs
From: |
Peter |
Subject: |
Re: How do I search for symbols such as \253 in Emacs |
Date: |
Tue, 6 Nov 2012 12:24:15 -0800 (PST) |
User-agent: |
G2/1.0 |
I wrote this many years ago when I first picked up Emacs. As I come across new
characters I just add to the list with the expected replacement string. I tried
to keep track of what the character looked like in the comment beside it. The
replacement strings are for text files which I am converting to LaTeX files
(which is typically where I run across this problem), so you might want to
change some of the replacements to better suit your application.
Hope this helps,
Peter
(defun fix-latin-1-chars ()
(interactive)
(let ((change-list '((?\x005397c "``") ; “
(?\xc "") ; Page Feed character
(?\x005397d "''") ; ”
(?\x2019 "'") ; ’
(?\x201c "''") ; ”
(?\x201d "''") ; ”
(?\x2014 "--") ; —
(?\x2026 " \\ldots ") ; —
(?\x0053974 "--") ; —
(?\x0053979 "'") ; ’
(?\x81 "'")
(?\x2018 "'")
(?\x2019 "'")
(?\x201A ".")
(?\x2022 ".")
(?\x8b4 "'") ; ´
(?\x53979 "'")
(?\x00539a6 " ") ; …
(?\x0053978 "`") ; ‘
(?\x0053973 "--") ; –
(?\x2013 "--") ; –
(?\x8b7 "*") ; ·
(?\x004e647 "*") ;
(?\x004e6a0 "*") ;
(?\x8bd ".5") ; ½
(?\x8a1 " ") ; ¡
(?\x8a7 " ") ; §
(?\x8a8 " ") ; ¨
(?\x0053973 "-") ; –
(?\x0053c39 "*") ; ∙
(?\x26 "and") ; &
(?\x004e657 "*") ;
(?\x004e5f1 "*") ;
(?\x004e648 "*") ;
(?\x004f070 "*") ;
(?\x004e5ca "*") ;
(?\x004e5f6 "*") ;
(?\x004e678 "*") ;
(?\xf0a8 "*") ;
(?\xf0b7 "*") ;
(?\xf0fc "*") ;
(?\x0053972 "*") ; ‒
(?\x8d8 "*") ; Ø
(?\x004e5aa "*") ;
(?\x8b6 " ") ; ¶
(?\x4f95f "") ;
(?\x539a0 "") ; †
(?\x5397e "")
(?\xfeff "")
(?\x00539a2 "*"))) ; •
(search-for)
(start-point (point))
(buffer-limit (point-max)))
(dolist (item change-list)
(setq search-for (make-string 1 (car item)))
(goto-char start-point)
(while (re-search-forward search-for buffer-limit t)
(delete-char -1)
(insert (car (cdr item)))))))