]> code.delx.au - gnu-emacs/blobdiff - lisp/dabbrev.el
Update the description of version handling.
[gnu-emacs] / lisp / dabbrev.el
index f2beb01124735f5e4b9c52285fc4670f76056037..fd8b596d5301ed58cc9ddbdbe66e86b1d86e6359 100644 (file)
@@ -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
@@ -972,6 +976,9 @@ Leaves point at the location of the start of the expansion."
                            "\\(" dabbrev--abbrev-char-regexp "\\)"))
          (pattern2 (concat (regexp-quote abbrev)
                           "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)"))
+         ;; This makes it possible to find matches in minibuffer prompts
+         ;; even when they are "inviolable".
+         (inhibit-point-motion-hooks t)
          found-string result)
       ;; Limited search.
       (save-restriction