annotate lisp/textmodes/tildify.el @ 65059:8bd0fdf7b9d1

(normal-mode): If font lock is on, turn it off and on.
author Richard M. Stallman <rms@gnu.org>
date Sat, 20 Aug 2005 21:49:28 +0000
parents 5b1a238fcbb4
children 703495630901 2d92f5c9d6ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; tildify.el --- adding hard spaces into texts
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64751
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004,
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
4 ;; 2005 Free Software Foundation, Inc.
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
38690
ebcceabda1b5 Milan Zamazal has new address.
Pavel Janík <Pavel@Janik.cz>
parents: 37895
diff changeset
6 ;; Author: Milan Zamazal <pdm@zamazal.org>
43636
30dfcb85b1ca (tildify-string-alist): Entry for xml-mode added.
Pavel Janík <Pavel@Janik.cz>
parents: 38690
diff changeset
7 ;; Version: 4.5
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
8 ;; Keywords: text, TeX, SGML, wp
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
25 ;; Boston, MA 02110-1301, USA.
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; This package can be typically used for adding forgotten tildes in TeX
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; sources or adding `&nbsp;' sequences in SGML (e.g. HTML) texts.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
32 ;; For example, the Czech ortography requires avoiding one letter
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
33 ;; prepositions at line endings. So they should be connected with the
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
34 ;; following words by a tilde. Some users forget to do this all the
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
35 ;; time. The purpose of this program is to check the text and suggest
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
36 ;; adding of missing tildes on some places. It works in a similar
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
37 ;; manner to `query-replace-regexp'.
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
39 ;; The functionality of this program is actually performing query
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
40 ;; replace on certain regions, but for historical reasons explained
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
41 ;; above it is called `tildify'.
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;;
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; The default variable settings are suited for Czech, so do not try to
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; understand them if you are not familiar with Czech grammar and spelling.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;;
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; The algorithm was inspired by Petr Ol¹įk's program `vlna'. Abbilities of
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; `tildify.el' are a little limited; if you have improvement suggestions, let
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;; me know.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;;; Code:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;;; *** User configuration variables ***
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 (defgroup tildify nil
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 "Adding missing hard spaces or other text fragments into texts."
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
58 :version "21.1"
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 :group 'wp)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 (defcustom tildify-pattern-alist
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 '((t "\\([,:;(][ \t]*[a]\\|\\<[AIKOSUVZikosuvz]\\)\\([ \t]+\\|[ \t]*\n[ \t]*\\)\\(\\w\\|[([{\\]\\|<[a-zA-Z]\\)" 2))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 "Alist specifying where to insert hard spaces.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 Each alist item is of the form (MAJOR-MODE REGEXP NUMBER) or
37894
504c274ec49b (tildify-ignored-environments-alist):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33949
diff changeset
66 \(MAJOR-MODE . SYMBOL).
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 MAJOR-MODE defines major mode, for which the item applies. It can be either:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 - a symbol equal to the major mode of the buffer to be fixed
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 - t for default item, this applies to all major modes not defined in another
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 alist item
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 REGEXP is a regular expression matching the part of a text, where a hard space
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 is missing. The regexp is always case sensitive, regardless of the current
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 `case-fold-search' setting.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 NUMBER defines the number of the REGEXP subexpression which should be replaced
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 by the hard space character.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 The form (MAJOR-MODE . SYMBOL) defines alias item for MAJOR-MODE. For this
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
81 mode, the item for the mode SYMBOL is looked up in the alist instead."
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 :group 'tildify
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 :type '(repeat (choice (list symbol regexp integer) (cons symbol symbol))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (defcustom tildify-string-alist
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 '((latex-mode . "~")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 (tex-mode . latex-mode)
33949
7012133c553b *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 31529
diff changeset
88 (plain-tex-mode . latex-mode)
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (sgml-mode . "&nbsp;")
43636
30dfcb85b1ca (tildify-string-alist): Entry for xml-mode added.
Pavel Janík <Pavel@Janik.cz>
parents: 38690
diff changeset
90 (xml-mode . sgml-mode)
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (html-mode . sgml-mode)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (t . " "))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 "Alist specifying what is a hard space in the current major mode.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95 Each alist item is of the form (MAJOR-MODE . STRING) or
37894
504c274ec49b (tildify-ignored-environments-alist):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33949
diff changeset
96 \(MAJOR-MODE . SYMBOL).
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 MAJOR-MODE defines major mode, for which the item applies. It can be either:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 - a symbol equal to the major mode of the buffer to be fixed
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 - t for default item, this applies to all major modes not defined in another
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 alist item
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 STRING defines the hard space, which is inserted at places defined by
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 `tildify-pattern-alist'. For example it can be \"~\" for TeX or \"&nbsp;\"
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 for SGML.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 The form (MAJOR-MODE . SYMBOL) defines alias item for MAJOR-MODE. For this
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
108 mode, the item for the mode SYMBOL is looked up in the alist instead."
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 :group 'tildify
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 :type '(repeat (cons symbol (choice string symbol))))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43636
diff changeset
111
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (defcustom tildify-ignored-environments-alist
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 '((latex-mode
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 ("\\\\\\\\" . "") ; do not remove this
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 ("\\\\begin{verbatim}" . "\\\\end{verbatim}")
37895
41ca5705b623 (tildify-ignored-environments-alist): Recognize \verb* right.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37894
diff changeset
116 ("\\\\verb\\*?\\(.\\)" . (1))
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 ("\\$\\$" . "\\$\\$")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 ("\\$" . "\\$")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 ("\\\\(" . "\\\\)")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 ("\\\\[[]" . "\\\\[]]")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 ("\\\\begin{math}" . "\\\\end{math}")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 ("\\\\begin{displaymath}" . "\\\\end{displaymath}")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 ("\\\\begin{equation}" . "\\\\end{equation}")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 ("\\\\begin{eqnarray\\*?}" . "\\\\end{eqnarray\\*?}")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 ("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 ("%" . "$"))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (plain-tex-mode . latex-mode)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (html-mode
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 ("<pre[^>]*>" . "</pre>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 ("<dfn>" . "</dfn>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 ("<code>" . "</code>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 ("<samp>" . "</samp>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 ("<kbd>" . "</kbd>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 ("<var>" . "</var>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 ("<PRE[^>]*>" . "</PRE>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 ("<DFN>" . "</DFN>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 ("<CODE>" . "</CODE>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 ("<SAMP>" . "</SAMP>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 ("<KBD>" . "</KBD>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 ("<VAR>" . "</VAR>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 ("<! *--" . "-- *>")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 ("<" . ">"))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (sgml-mode . html-mode)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (t nil))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 "Alist specifying ignored structured text environments.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 Parts of text defined in this alist are skipped without performing hard space
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 insertion on them. These setting allow skipping text parts like verbatim or
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 math environments in TeX or preformatted text in SGML.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 Each list element is of the form
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (MAJOR-MODE (BEG-REGEX . END-REGEX) (BEG-REGEX . END-REGEX) ... )
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 MAJOR-MODE defines major mode, for which the item applies. It can be either:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 - a symbol equal to the major mode of the buffer to be fixed
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 - t for default item, this applies to all major modes not defined in another
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 alist item
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 BEG-REGEX is a regexp matching beginning of a text part to be skipped.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 END-REGEX defines end of the corresponding text part and can be either:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 - a regexp matching the end of the skipped text part
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 - a list of regexps and numbers, which will compose the ending regexp by
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 concatenating themselves, while replacing the numbers with corresponding
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 subexpressions of BEG-REGEX (this is used to solve cases like
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
164 \\\\verb<character> in TeX)."
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 :group 'tildify
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 :type '(repeat (cons symbol (choice symbol (repeat sexp)))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 ;;; *** Internal variables ***
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (defvar tildify-count nil
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 "Counter for replacements.")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 ;;; *** Interactive functions ***
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ;;;###autoload
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 (defun tildify-region (beg end)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 "Add hard spaces in the region between BEG and END.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 See variables `tildify-pattern-alist', `tildify-string-alist', and
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 `tildify-ignored-environments-alist' for information about configuration
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 parameters.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 This function performs no refilling of the changed text."
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (interactive "*r")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (setq tildify-count 0)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (let (a
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 z
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 (marker-end (copy-marker end))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 end-env
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 finish
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (ask t)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 (case-fold-search nil)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (regexp (tildify-build-regexp)) ; beginnings of environments
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 aux)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 (if regexp
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 ;; Yes, ignored environments exist for the current major mode,
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 ;; tildify just texts outside them
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (save-excursion
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 (save-restriction
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (widen)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (goto-char (point-min))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (while (not finish)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (setq a (point))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 (setq end-env (tildify-find-env regexp))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (setq z (copy-marker (if end-env (1- (point)) (point-max))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (if (>= (marker-position z) beg)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 (progn
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (or (>= a beg) (setq a beg))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (or (<= (marker-position z) (marker-position marker-end))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 (setq z marker-end))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 (setq aux (tildify-tildify a (marker-position z) ask))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 (if (eq aux 'force)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 (setq ask nil)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 (if (eq aux nil)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (setq finish t)))))
31529
7f307e299d03 Minor doc/commentary fixes.
Dave Love <fx@gnu.org>
parents: 26187
diff changeset
216 (if (>= (marker-position z) (marker-position marker-end))
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 (setq finish t))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 (or (>= (point) (marker-position z))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 (goto-char (marker-position z)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 (if (not finish)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221 (if (re-search-forward end-env nil t)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 (if (> (point) (marker-position marker-end))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 (setq finish t))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 (message
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 (format "End of environment not found: %s" end-env))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 (setq finish t))))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 ;; No ignored environments, tildify directly
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (tildify-tildify beg end ask)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (message (format "%d spaces replaced." tildify-count)))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43636
diff changeset
230
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 ;;;###autoload
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (defun tildify-buffer ()
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 "Add hard spaces in the current buffer.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 See variables `tildify-pattern-alist', `tildify-string-alist', and
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 `tildify-ignored-environments-alist' for information about configuration
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 parameters.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 This function performs no refilling of the changed text."
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (interactive "*")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (tildify-region (point-min) (point-max)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 ;;; *** Auxiliary functions ***
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (defun tildify-build-regexp ()
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 "Build start of environment regexp."
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (let ((alist (tildify-mode-alist tildify-ignored-environments-alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 regexp)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (when alist
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (setq regexp (caar alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (setq alist (cdr alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (while alist
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 (setq regexp (concat regexp "\\|" (caar alist)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (setq alist (cdr alist)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 regexp)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (defun tildify-mode-alist (mode-alist &optional mode)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 "Return alist item for the MODE-ALIST in the current major MODE."
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (if (null mode)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (setq mode major-mode))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (let ((alist (cdr (or (assoc mode mode-alist)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (assoc t mode-alist)))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (if (and alist
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (symbolp alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (tildify-mode-alist mode-alist alist)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 alist)))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 43636
diff changeset
266
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (defun tildify-find-env (regexp)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 "Find environment using REGEXP.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 Return regexp for the end of the environment or nil if no environment was
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 found."
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 ;; Find environment
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (if (re-search-forward regexp nil t)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 ;; Build end-env regexp
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (let ((match (match-string 0))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (alist (tildify-mode-alist tildify-ignored-environments-alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 expression)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (save-match-data
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (while (not (eq (string-match (caar alist) match) 0))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (setq alist (cdr alist))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 (if (stringp (setq expression (cdar alist)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 expression
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (let ((result "")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 aux)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (while expression
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (setq result (concat result
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (if (stringp (setq aux (car expression)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 expression
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (regexp-quote (match-string aux)))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (setq expression (cdr expression)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 result)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 ;; Return nil if not found
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 nil))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (defun tildify-tildify (beg end ask)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 "Add tilde characters in the region between BEG and END.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 This function does not do any further checking except of for comments and
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 macros.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 If ASK is nil, perform replace without asking user for confirmation.
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 Returns one of symbols: t (all right), nil (quit), force (replace without
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 further questions)."
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (save-excursion
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (goto-char beg)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (let* ((alist (tildify-mode-alist tildify-pattern-alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (regexp (car alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (match-number (cadr alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (tilde (tildify-mode-alist tildify-string-alist))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (end-marker (copy-marker end))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 answer
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 bad-answer
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 replace
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 quit
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (message-log-max nil))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (while (and (not quit)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (re-search-forward regexp (marker-position end-marker) t))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (when (or (not ask)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (progn
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (goto-char (match-beginning match-number))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (setq bad-answer t)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (while bad-answer
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (setq bad-answer nil)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (message "Replace? (yn!q) ")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (setq answer (read-event)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (cond
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 ((or (eq answer ?y) (eq answer ? ) (eq answer 'space))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (setq replace t))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 ((eq answer ?n)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (setq replace nil))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 ((eq answer ?!)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (setq replace t
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 ask nil))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 ((eq answer ?q)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (setq replace nil
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 quit t))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (t
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (message "Press y, n, !, or q.")
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (setq bad-answer t)))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 replace))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 (replace-match tilde t t nil match-number)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (setq tildify-count (1+ tildify-count))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 ;; Return value
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (cond
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (quit nil)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 ((not ask) 'force)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (t t)))))
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 ;;; *** Announce ***
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (provide 'tildify)
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 ;; Local variables:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 ;; coding: iso-latin-2
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 ;; End:
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49599
diff changeset
358 ;;; arch-tag: fc9b05a6-7355-4639-8170-dcf57853ba22
26187
eca255a79645 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 ;;; tildify.el ends here