comparison lisp/dabbrev.el @ 3731:ca1e006fff42

(dabbrev-expand): Do all changes with replace-match. In picture-mode, use picture-replace-match instead.
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Jun 1993 18:55:10 +0000
parents fd3e1f2d7ae5
children 069c54e77fd1
comparison
equal deleted inserted replaced
3730:473c03886fc2 3731:ca1e006fff42
160 (if (not expansion) 160 (if (not expansion)
161 (let ((first (string= abbrev old))) 161 (let ((first (string= abbrev old)))
162 (setq last-dabbrevs-abbrev-location nil) 162 (setq last-dabbrevs-abbrev-location nil)
163 (if (not first) 163 (if (not first)
164 (progn (undo-boundary) 164 (progn (undo-boundary)
165 (delete-backward-char (length old)) 165 (search-backward old)
166 (insert abbrev))) 166 (if (eq major-mode 'picture-mode)
167 (picture-replace-match abbrev t 'literal)
168 (replace-match abbrev t 'literal))))
167 (error (if first 169 (error (if first
168 "No dynamic expansion for \"%s\" found." 170 "No dynamic expansion for \"%s\" found."
169 "No further dynamic expansions for \"%s\" found.") 171 "No further dynamic expansions for \"%s\" found.")
170 abbrev)) 172 abbrev))
171 ;; Success: stick it in and return. 173 ;; Success: stick it in and return.
175 ;; provided (1) that kind of thing is enabled in this buffer 177 ;; provided (1) that kind of thing is enabled in this buffer
176 ;; and (2) the replacement itself is all lower case. 178 ;; and (2) the replacement itself is all lower case.
177 ;; First put back the original abbreviation with its original 179 ;; First put back the original abbreviation with its original
178 ;; case pattern. 180 ;; case pattern.
179 (save-excursion 181 (save-excursion
180 (replace-match abbrev t 'literal)) 182 (if (eq major-mode 'picture-mode)
183 (picture-replace-match abbrev t 'literal)
184 (replace-match abbrev t 'literal)))
181 (search-forward abbrev) 185 (search-forward abbrev)
182 (let ((do-case (and do-case 186 (let ((do-case (and do-case
183 (string= (substring expansion 1) 187 (string= (substring expansion 1)
184 (downcase (substring expansion 1)))))) 188 (downcase (substring expansion 1))))))
185 ;; First put back the original abbreviation with its original 189 ;; First put back the original abbreviation with its original
187 (save-excursion 191 (save-excursion
188 (replace-match abbrev t 'literal)) 192 (replace-match abbrev t 'literal))
189 ;;; This used to be necessary, but no longer, 193 ;;; This used to be necessary, but no longer,
190 ;;; because now point is preserved correctly above. 194 ;;; because now point is preserved correctly above.
191 ;;; (search-forward abbrev) 195 ;;; (search-forward abbrev)
192 (replace-match (if do-case (downcase expansion) expansion) 196 (if (eq major-mode 'picture-mode)
193 (not do-case) 197 (picture-replace-match (if do-case (downcase expansion) expansion)
194 'literal)) 198 (not do-case)
199 'literal)
200 (replace-match (if do-case (downcase expansion) expansion)
201 (not do-case)
202 'literal)))
195 ;; Save state for re-expand. 203 ;; Save state for re-expand.
196 (setq last-dabbrevs-abbreviation abbrev) 204 (setq last-dabbrevs-abbreviation abbrev)
197 (setq last-dabbrevs-expansion expansion) 205 (setq last-dabbrevs-expansion expansion)
198 (setq last-dabbrevs-expansion-location loc)))) 206 (setq last-dabbrevs-expansion-location loc))))
199 207