From: Richard M. Stallman Date: Mon, 6 Jan 2003 01:19:59 +0000 (+0000) Subject: (dabbrev--substitute-expansion): X-Git-Tag: ttn-vms-21-2-B4~11817 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=19c17c4ec58a7326e6394c00e526e614519e71aa;p=emacs.git (dabbrev--substitute-expansion): Convert all whitespace to single spaces, except when it's carried over from the existing text. --- 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