(rmail-retry-failure): Bind inhibit-read-only.
[bpt/emacs.git] / lisp / dabbrev.el
index a28c902..a6f4541 100644 (file)
@@ -130,6 +130,8 @@ This variable has an effect only when the value of
 ;; I recommend that you set this to nil.
 (defvar dabbrev-case-replace 'case-replace
   "*Non-nil means dabbrev should preserve case when expanding the abbreviation.
+More precisely, it preserves the case pattern of the abbreviation as you
+typed it--as opposed to the case pattern of the expansion that is copied.
 The value of this variable is an expression; it is evaluated
 and the resulting value determines the decision.
 For example, setting this to `case-replace' means evaluate that
@@ -490,8 +492,10 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
       (if old
          (save-excursion
            (setq buffer-undo-list (cons orig-point buffer-undo-list))
-           (search-backward (substring old (length abbrev)))
-           (delete-region (match-beginning 0) (match-end 0))))
+           ;; Put back the original abbrev with its original case pattern.
+           (search-backward old)
+           (insert abbrev)
+           (delete-region (point) (+ (point) (length old)))))
       (error "No%s dynamic expansion for `%s' found"
             (if old " further" "") abbrev))
      (t
@@ -709,6 +713,15 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
                        dabbrev--friend-buffer-list
                        (append dabbrev--friend-buffer-list
                                non-friend-buffer-list)))))
+       ;; Move buffers that are visible on the screen
+       ;; to the front of the list.
+       (if dabbrev--friend-buffer-list
+           (let ((w (next-window (selected-window))))
+             (while (not (eq w (selected-window)))
+               (setq dabbrev--friend-buffer-list
+                     (cons (window-buffer w)
+                           (delq (window-buffer w) dabbrev--friend-buffer-list)))
+               (setq w (next-window w)))))
        ;; Walk through the buffers
        (while (and (not expansion) dabbrev--friend-buffer-list)
          (setq dabbrev--last-buffer