X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f5f727f8ffa2e674601875b2f2fe7ce3f0030c93..f52154007f41abe6857acab91e31ab4a7d18210d:/lisp/dabbrev.el diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index d6ce4ee8c7..34c9a41d70 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el @@ -1,6 +1,7 @@ ;;; dabbrev.el --- dynamic abbreviation package -;; Copyright (C) 1985, 86, 92, 94, 96, 1997 Free Software Foundation, Inc. +;; Copyright (C) 1985, 86, 92, 94, 96, 1997, 2000 +;; Free Software Foundation, Inc. ;; Author: Don Morrison ;; Maintainer: Lars Lindberg @@ -134,8 +135,8 @@ A value of `case-fold-search' means case is significant if `case-fold-search' is nil. Any other non-nil version means case is not significant." :type '(choice (const :tag "off" nil) - (const :tag "on" t) - (const :tag "like search" case-fold-search)) + (const :tag "like search" case-fold-search) + (other :tag "on" t)) :group 'dabbrev) (defcustom dabbrev-upcase-means-case-search nil @@ -156,8 +157,8 @@ Any other non-nil version means do not preserve case. This variable has an effect only when the value of `dabbrev-case-fold-search' specifies to ignore case." :type '(choice (const :tag "off" nil) - (const :tag "on" t) - (const :tag "like M-x query-replace" case-replace)) + (const :tag "like M-x query-replace" case-replace) + (other :tag "on" t)) :group 'dabbrev) (defcustom dabbrev-abbrev-char-regexp nil @@ -193,16 +194,25 @@ Dabbrev always searches the current buffer first. Then, if designated by `dabbrev-select-buffers-function'. Then, if `dabbrev-check-all-buffers' is non-nil, dabbrev searches -all the other buffers, except those named in `dabbrev-ignored-buffer-names'." +all the other buffers, except those named in `dabbrev-ignored-buffer-names', +or matched by `dabbrev-ignored-regexps'." :type 'boolean :group 'dabbrev) -(defcustom dabbrev-ignored-buffer-names '("*Messages") - "*List of buffer names that dabbrev should not check." +(defcustom dabbrev-ignored-buffer-names '("*Messages*" "*Buffer List*") + "*List of buffer names that dabbrev should not check. +See also `dabbrev-ignored-regexps'." :type '(repeat (string :tag "Buffer name")) :group 'dabbrev :version "20.3") +(defcustom dabbrev-ignored-regexps nil + "*List of regexps matching names of buffers that dabbrev should not check. +See also `dabbrev-ignored-buffer-names'." + :type '(repeat regexp) + :group 'dabbrev + :version "21.1") + (defcustom dabbrev-check-other-buffers t "*Should \\[dabbrev-expand] look in other buffers?\ @@ -216,7 +226,7 @@ buffers too. The default value is t." :type '(choice (const :tag "off" nil) (const :tag "on" t) - (const :tag "ask" other)) + (other :tag "ask" other)) :group 'dabbrev) ;; I guess setting this to a function that selects all C- or C++- @@ -310,14 +320,14 @@ this list.") ;; variable ELEMENT, and include it in the result ;; if CONDITION evaluates non-nil. (defmacro dabbrev-filter-elements (element list condition) - (` (let (dabbrev-result dabbrev-tail (, element)) - (setq dabbrev-tail (, list)) - (while dabbrev-tail - (setq (, element) (car dabbrev-tail)) - (if (, condition) - (setq dabbrev-result (cons (, element) dabbrev-result))) - (setq dabbrev-tail (cdr dabbrev-tail))) - (nreverse dabbrev-result)))) + `(let (dabbrev-result dabbrev-tail ,element) + (setq dabbrev-tail ,list) + (while dabbrev-tail + (setq ,element (car dabbrev-tail)) + (if ,condition + (setq dabbrev-result (cons ,element dabbrev-result))) + (setq dabbrev-tail (cdr dabbrev-tail))) + (nreverse dabbrev-result))) ;;---------------------------------------------------------------- ;; Exported functions @@ -569,7 +579,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." (equal abbrev (upcase abbrev))))) ;; Save state for re-expand. - (setq dabbrev--last-expansion expansion) + (setq dabbrev--last-expansion expansion) (setq dabbrev--last-abbreviation abbrev) (setq dabbrev--last-abbrev-location (point-marker)))))) @@ -630,7 +640,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." (dabbrev--goto-start-of-abbrev) (buffer-substring-no-properties dabbrev--last-abbrev-location (point)))) - + ;;; Initializes all global variables (defun dabbrev--reset-global-variables () ;; dabbrev--last-obarray and dabbrev--last-completion-buffer @@ -761,21 +771,30 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." (nreverse (dabbrev-filter-elements buffer (buffer-list) - (and (not (member (buffer-name buffer) - dabbrev-ignored-buffer-names)) - (not (memq buffer dabbrev--friend-buffer-list))))) + (let ((bn (buffer-name buffer))) + (and (not (member bn dabbrev-ignored-buffer-names)) + (not (memq buffer dabbrev--friend-buffer-list)) + (not + (let ((tail dabbrev-ignored-regexps) + (match nil)) + (while (and tail (not match)) + (setq match (string-match (car tail) bn) + tail (cdr tail))) + match)))))) 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))))) + ;; to the front of the list. Remove the current buffer. + (when 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)))) + (setq dabbrev--friend-buffer-list + (delq (current-buffer) dabbrev--friend-buffer-list))) ;; Walk through the buffers (while (and (not expansion) dabbrev--friend-buffer-list) (setq dabbrev--last-buffer