# HG changeset patch # User Richard M. Stallman # Date 1041815999 0 # Node ID c0e98fdf377f9f1de6b368710c1f8e2dcd48397e # Parent d00c13d69d31677f123fd27679ea401d4c785ed8 (dabbrev--substitute-expansion): Convert all whitespace to single spaces, except when it's carried over from the existing text. diff -r d00c13d69d31 -r c0e98fdf377f lisp/dabbrev.el --- a/lisp/dabbrev.el Mon Jan 06 01:17:19 2003 +0000 +++ b/lisp/dabbrev.el Mon Jan 06 01:19:59 2003 +0000 @@ -926,10 +926,14 @@ (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