]> code.delx.au - gnu-emacs/blobdiff - lisp/dabbrev.el
(hexl-mode): Stash `eldoc-documentation-function' in
[gnu-emacs] / lisp / dabbrev.el
index cac4cc27f3e4b742da5b643624e1f93e07869b96..c51f1322a0a9886e9cc3b3bac9be95b0bcefe936 100644 (file)
@@ -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
@@ -332,6 +332,9 @@ this list."
 ;; The regexp for recognizing a character in an abbreviation.
 (defvar dabbrev--abbrev-char-regexp nil)
 
+;; The progress reporter for buffer-scanning progress.
+(defvar dabbrev--progress-reporter nil)
+
 ;;----------------------------------------------------------------
 ;; Macros
 ;;----------------------------------------------------------------
@@ -711,10 +714,6 @@ If IGNORE-CASE is non-nil, accept matches which differ in case."
        (setq all-expansions (cons expansion all-expansions))))
     all-expansions))
 
-(defun dabbrev--scanning-message ()
-  (unless (window-minibuffer-p (selected-window))
-    (message "Scanning `%s'" (buffer-name (current-buffer)))))
-
 (defun dabbrev--ignore-buffer-p (buffer)
   "Return non-nil if BUFFER should be ignored by dabbrev."
   (let ((bn (buffer-name buffer)))
@@ -740,8 +739,7 @@ of the start of the occurrence."
     ;; If we were scanning something other than the current buffer,
     ;; continue scanning there.
     (when dabbrev--last-buffer
-      (set-buffer dabbrev--last-buffer)
-      (dabbrev--scanning-message))
+      (set-buffer dabbrev--last-buffer))
     (or
      ;; ------------------------------------------
      ;; Look backward in current buffer.
@@ -773,15 +771,20 @@ of the start of the occurrence."
         ;; If we have just now begun to search other buffers,
         ;; determine which other buffers we should check.
         ;; Put that list in dabbrev--friend-buffer-list.
-        (or dabbrev--friend-buffer-list
-            (setq dabbrev--friend-buffer-list
-                  (dabbrev--make-friend-buffer-list))))
+        (unless dabbrev--friend-buffer-list
+           (setq dabbrev--friend-buffer-list
+                 (dabbrev--make-friend-buffer-list))
+           (setq dabbrev--progress-reporter
+                 (make-progress-reporter
+                  "Scanning for dabbrevs..."
+                  (- (length dabbrev--friend-buffer-list)) 0 0 1 1.5))))
        ;; Walk through the buffers till we find a match.
        (let (expansion)
         (while (and (not expansion) dabbrev--friend-buffer-list)
           (setq dabbrev--last-buffer (pop dabbrev--friend-buffer-list))
           (set-buffer dabbrev--last-buffer)
-          (dabbrev--scanning-message)
+           (progress-reporter-update dabbrev--progress-reporter
+                                     (- (length dabbrev--friend-buffer-list)))
           (setq dabbrev--last-expansion-location (point-min))
           (setq expansion (dabbrev--try-find abbrev nil 1 ignore-case)))
         expansion)))))
@@ -913,10 +916,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)))))
@@ -1006,12 +1011,12 @@ Leaves point at the location of the start of the expansion."
                (cons found-string dabbrev--last-table))
          result)))))
 
-(dolist (mess '("^No dynamic expansion for .* found$"
+(dolist (mess '("^No dynamic expansion for .* found"
                "^No further dynamic expansion for .* found$"
                "^No possible abbreviation preceding point$"))
   (add-to-list 'debug-ignored-errors mess))
 
 (provide 'dabbrev)
 
-;;; arch-tag: 29e58596-f080-4306-a409-70296cf9d46f
+;; arch-tag: 29e58596-f080-4306-a409-70296cf9d46f
 ;;; dabbrev.el ends here