summaryrefslogtreecommitdiff
path: root/lisp/dabbrev.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2003-01-06 01:19:59 +0000
committerRichard M. Stallman <rms@gnu.org>2003-01-06 01:19:59 +0000
commit0b42e5ad375b7ecb9656db875de9ec414629bd2b (patch)
treed363f504249234a5354681d6b308cb6c3176494f /lisp/dabbrev.el
parented3337224639bed1dcaf4f3e914d0b9b2d986091 (diff)
downloademacs-0b42e5ad375b7ecb9656db875de9ec414629bd2b.tar.gz
(dabbrev--substitute-expansion):
Convert all whitespace to single spaces, except when it's carried over from the existing text.
Diffstat (limited to 'lisp/dabbrev.el')
-rw-r--r--lisp/dabbrev.el10
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 9dba5d61ebe..fd8b596d530 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -926,10 +926,14 @@ to record whether we upcased the expansion, downcased it, or did neither."
(cond ((equal abbrev (upcase abbrev)) 'upcase)
((equal abbrev (downcase abbrev)) 'downcase)))))
- ;; Convert newlines to spaces.
+ ;; Convert whitespace to single spaces.
(if dabbrev--eliminate-newlines
- (while (string-match "\n" expansion)
- (setq expansion (replace-match " " nil nil expansion))))
+ ;; Start searching at end of ABBREV so that any whitespace
+ ;; carried over from the existing text is not changed.
+ (let ((pos (length abbrev)))
+ (while (string-match "[\n \t]+" expansion pos)
+ (setq pos (1+ (match-beginning 0)))
+ (setq expansion (replace-match " " nil nil expansion)))))
(if old
(save-excursion