(dabbrev-upcase-means-case-search): Doc fix.
[bpt/emacs.git] / lisp / dabbrev.el
index 624a59b..e8bb085 100644 (file)
@@ -1,7 +1,7 @@
 ;;; dabbrev.el --- dynamic abbreviation package
 
 ;; Copyright (C) 1985, 1986, 1992, 1994, 1996, 1997, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;;   2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Don Morrison
 ;; Maintainer: Lars Lindberg <Lars.Lindberg@sypro.cap.se>
@@ -128,7 +128,7 @@ Set this to nil if no characters should be skipped."
                 (const :tag "off" nil))
   :group 'dabbrev)
 
-(defcustom dabbrev--eliminate-newlines t
+(defcustom dabbrev-eliminate-newlines t
   "*Non-nil means dabbrev should not insert newlines.
 Instead it converts them to spaces."
   :type 'boolean
@@ -147,7 +147,7 @@ Any other non-nil version means case is not significant."
 
 (defcustom dabbrev-upcase-means-case-search nil
   "*The significance of an uppercase character in an abbreviation.
-nil means case fold search when searching for possible expansions;
+A nil value means case fold search when searching for possible expansions;
 non-nil means case sensitive search.
 
 This variable has an effect only when the value of
@@ -913,10 +913,12 @@ to record whether we upcased the expansion, downcased it, or did neither."
                          ((equal abbrev (downcase abbrev)) 'downcase)))))
 
     ;; Convert whitespace to single spaces.
-    (if dabbrev--eliminate-newlines
-       ;; Start searching at end of ABBREV so that any whitespace
-       ;; carried over from the existing text is not changed.
-       (let ((pos (length abbrev)))
+    (if dabbrev-eliminate-newlines
+       (let ((pos
+              (if (equal abbrev " ") 0 (length abbrev))))
+         ;; If ABBREV is real, search after the end of it.
+         ;; If ABBREV is space and we are copying successive words,
+         ;; search starting at the front.
          (while (string-match "[\n \t]+" expansion pos)
            (setq pos (1+ (match-beginning 0)))
            (setq expansion (replace-match " " nil nil expansion)))))