]> code.delx.au - gnu-emacs/blobdiff - lisp/dabbrev.el
Do not prompt twice to save a buffer
[gnu-emacs] / lisp / dabbrev.el
index 87a03fd24da46626c0a2741f6022ddba0529e69c..d9f36b152905cf971da126a1d7c6d5969eb17cc1 100644 (file)
@@ -1,7 +1,7 @@
 ;;; dabbrev.el --- dynamic abbreviation package  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1992, 1994, 1996-1997, 2000-2012
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1992, 1994, 1996-1997, 2000-2016 Free
+;; Software Foundation, Inc.
 
 ;; Author: Don Morrison
 ;;     Lars Lindberg
 
 Example: Set this to \"\\\\$\" for programming languages
 in which variable names may appear with or without a leading `$'.
-\(For example, in Makefiles.\)
+\(For example, in Makefiles.)
 
 Set this to nil if no characters should be skipped."
   :type '(choice regexp
@@ -285,6 +285,7 @@ A mode setting this variable should make it buffer local."
 If this variable is non-nil, dabbrev will only look in these buffers.
 It will not even look in the current buffer if it is not a member of
 this list."
+  :type '(choice (const nil) (repeat :tag "List of buffers" string))
   :group 'dabbrev)
 
 ;;----------------------------------------------------------------
@@ -457,7 +458,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
               (markerp dabbrev--last-abbrev-location)
               (marker-position dabbrev--last-abbrev-location)
               (or (eq last-command this-command)
-                  (and (window-minibuffer-p (selected-window))
+                  (and (window-minibuffer-p)
                        (= dabbrev--last-abbrev-location
                           (point)))))
          ;; Find a different expansion for the same abbrev as last time.
@@ -527,13 +528,13 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
            (search-backward old)
            (insert abbrev)
            (delete-region (point) (+ (point) (length old)))))
-      (error "No%s dynamic expansion for `%s' found"
-            (if old " further" "") abbrev))
+      (user-error "No%s dynamic expansion for `%s' found"
+                  (if old " further" "") abbrev))
      (t
       (if (not (or (eq dabbrev--last-buffer dabbrev--last-buffer-found)
                   (minibuffer-window-active-p (selected-window))))
          (progn
-           (message "Expansion found in '%s'"
+           (message "Expansion found in `%s'"
                     (buffer-name dabbrev--last-buffer))
            (setq dabbrev--last-buffer-found dabbrev--last-buffer))
        (message nil))
@@ -545,8 +546,8 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
                (copy-marker dabbrev--last-expansion-location)))
       ;; Success: stick it in and return.
       (setq buffer-undo-list (cons orig-point buffer-undo-list))
-      (dabbrev--substitute-expansion old abbrev expansion
-                                    record-case-pattern)
+      (setq expansion (dabbrev--substitute-expansion old abbrev expansion
+                                                     record-case-pattern))
 
       ;; Save state for re-expand.
       (setq dabbrev--last-expansion expansion)
@@ -793,7 +794,7 @@ of the start of the occurrence."
     ;; In a minibuffer, search the buffer it was activated from,
     ;; first after the minibuffer itself.  Unless we aren't supposed
     ;; to search the current buffer either.
-    (if (and (window-minibuffer-p (selected-window))
+    (if (and (window-minibuffer-p)
             (not dabbrev-search-these-buffers-only))
        (setq list
              (cons (dabbrev--minibuffer-origin)
@@ -901,7 +902,9 @@ to record whether we upcased the expansion, downcased it, or did neither."
     ;; and (2) the replacement itself is all lower case.
     (dabbrev--safe-replace-match expansion
                                 (not use-case-replace)
-                                t)))
+                                t))
+  ;; Return the expansion actually used.
+  expansion)
 
 
 ;;;----------------------------------------------------------------