aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-12-15 11:51:04 +0000
committerGerd Moellmann2000-12-15 11:51:04 +0000
commit3ffa545ba6368080ae668be84c59afe8aa7f3fa7 (patch)
treebd5890decd175229e41f0e5e5e1fbee82dbd35c6
parent125f929e4533f5c89b859588047c97555abbf177 (diff)
downloademacs-3ffa545ba6368080ae668be84c59afe8aa7f3fa7.tar.gz
emacs-3ffa545ba6368080ae668be84c59afe8aa7f3fa7.zip
(dabbrev--last-case-pattern): Value is now
`upcase' or `downcase' or nil. (dabbrev-expand): Don't do anything with dabbrev--last-case-pattern. Pass new record-case-pattern arg to dabbrev--substitute-expansion. (dabbrev--substitute-expansion): New arg record-case-pattern. If it is non-nil, set dabbrev--last-case-pattern. If ABBREV is " ", use dabbrev--last-case-pattern to change EXPANSION. (dabbrev--find-expansion): Remove extra nreverse.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/dabbrev.el81
2 files changed, 56 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b1d35e2e96e..9d972b1b38f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12000-12-15 Richard M. Stallman <rms@caffeine.ai.mit.edu>
2
3 * dabbrev.el (dabbrev--last-case-pattern): Value is now
4 `upcase' or `downcase' or nil.
5 (dabbrev-expand): Don't do anything with dabbrev--last-case-pattern.
6 Pass new record-case-pattern arg to dabbrev--substitute-expansion.
7 (dabbrev--substitute-expansion): New arg record-case-pattern.
8 If it is non-nil, set dabbrev--last-case-pattern.
9 If ABBREV is " ", use dabbrev--last-case-pattern to change EXPANSION.
10
11 * dabbrev.el (dabbrev--find-expansion): Remove extra nreverse.
12
12000-12-15 Miles Bader <miles@gnu.org> 132000-12-15 Miles Bader <miles@gnu.org>
2 14
3 * paths.el (Info-default-directory-list): Don't delete 15 * paths.el (Info-default-directory-list): Don't delete
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 542f657fceb..42e370a7b87 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -297,8 +297,8 @@ this list.")
297;; The buffer we last did a completion in. 297;; The buffer we last did a completion in.
298(defvar dabbrev--last-completion-buffer nil) 298(defvar dabbrev--last-completion-buffer nil)
299 299
300;; Non-nil means we should upcase 300;; If non-nil, a function to use when copying successive words.
301;; when copying successive words. 301;; It should be `upcase' or `downcase'.
302(defvar dabbrev--last-case-pattern nil) 302(defvar dabbrev--last-case-pattern nil)
303 303
304;; Same as dabbrev-check-other-buffers, but is set for every expand. 304;; Same as dabbrev-check-other-buffers, but is set for every expand.
@@ -433,7 +433,7 @@ if there is a suitable one already."
433 (message "Repeat `%s' to see all completions" 433 (message "Repeat `%s' to see all completions"
434 (key-description (this-command-keys))) 434 (key-description (this-command-keys)))
435 (message "The only possible completion")) 435 (message "The only possible completion"))
436 (dabbrev--substitute-expansion nil abbrev init)) 436 (dabbrev--substitute-expansion nil abbrev init nil))
437 (t 437 (t
438 ;; * String is a common substring completion already. Make list. 438 ;; * String is a common substring completion already. Make list.
439 (message "Making completion list...") 439 (message "Making completion list...")
@@ -510,8 +510,6 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
510 (concat "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) 510 (concat "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)"))
511 (setq expansion (buffer-substring-no-properties 511 (setq expansion (buffer-substring-no-properties
512 dabbrev--last-expansion-location (point))) 512 dabbrev--last-expansion-location (point)))
513 (if dabbrev--last-case-pattern
514 (setq expansion (upcase expansion)))
515 513
516 ;; Record the end of this expansion, in case we repeat this. 514 ;; Record the end of this expansion, in case we repeat this.
517 (setq dabbrev--last-expansion-location (point))) 515 (setq dabbrev--last-expansion-location (point)))
@@ -567,17 +565,8 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
567 (copy-marker dabbrev--last-expansion-location))) 565 (copy-marker dabbrev--last-expansion-location)))
568 ;; Success: stick it in and return. 566 ;; Success: stick it in and return.
569 (setq buffer-undo-list (cons orig-point buffer-undo-list)) 567 (setq buffer-undo-list (cons orig-point buffer-undo-list))
570 (dabbrev--substitute-expansion old abbrev expansion) 568 (dabbrev--substitute-expansion old abbrev expansion
571 569 record-case-pattern)
572 ;; If we are not copying successive words now,
573 ;; set dabbrev--last-case-pattern.
574 (and record-case-pattern
575 (setq dabbrev--last-case-pattern
576 (and (if (eq dabbrev-case-fold-search 'case-fold-search)
577 case-fold-search
578 dabbrev-case-fold-search)
579 (not dabbrev-upcase-means-case-search)
580 (equal abbrev (upcase abbrev)))))
581 570
582 ;; Save state for re-expand. 571 ;; Save state for re-expand.
583 (setq dabbrev--last-expansion expansion) 572 (setq dabbrev--last-expansion expansion)
@@ -769,19 +758,18 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
769 (funcall dabbrev-select-buffers-function)) 758 (funcall dabbrev-select-buffers-function))
770 (if dabbrev-check-all-buffers 759 (if dabbrev-check-all-buffers
771 (setq non-friend-buffer-list 760 (setq non-friend-buffer-list
772 (nreverse 761 (dabbrev-filter-elements
773 (dabbrev-filter-elements 762 buffer (buffer-list)
774 buffer (buffer-list) 763 (let ((bn (buffer-name buffer)))
775 (let ((bn (buffer-name buffer))) 764 (and (not (member bn dabbrev-ignored-buffer-names))
776 (and (not (member bn dabbrev-ignored-buffer-names)) 765 (not (memq buffer dabbrev--friend-buffer-list))
777 (not (memq buffer dabbrev--friend-buffer-list)) 766 (not
778 (not 767 (let ((tail dabbrev-ignored-regexps)
779 (let ((tail dabbrev-ignored-regexps) 768 (match nil))
780 (match nil)) 769 (while (and tail (not match))
781 (while (and tail (not match)) 770 (setq match (string-match (car tail) bn)
782 (setq match (string-match (car tail) bn) 771 tail (cdr tail)))
783 tail (cdr tail))) 772 match)))))
784 match))))))
785 dabbrev--friend-buffer-list 773 dabbrev--friend-buffer-list
786 (append dabbrev--friend-buffer-list 774 (append dabbrev--friend-buffer-list
787 non-friend-buffer-list))))) 775 non-friend-buffer-list)))))
@@ -814,11 +802,15 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
814 (replace-match string fixedcase literal))) 802 (replace-match string fixedcase literal)))
815 803
816;;;---------------------------------------------------------------- 804;;;----------------------------------------------------------------
817;;; Substitute the current string in buffer with the expansion 805(defun dabbrev--substitute-expansion (old abbrev expansion record-case-pattern)
818;;; OLD is nil or the last expansion substring. 806 "Replace OLD with EXPANSION in the buffer.
819;;; ABBREV is the abbreviation we are working with. 807OLD is text currently in the buffer, perhaps the abbreviation
820;;; EXPANSION is the expansion substring. 808or perhaps another expansion that was tried previously.
821(defun dabbrev--substitute-expansion (old abbrev expansion) 809ABBREV is the abbreviation we are expanding.
810It is \" \" if we are copying subsequent words.
811EXPANSION is the expansion substring to be used this time.
812RECORD-CASE-PATTERN, if non-nil, means set `dabbrev--last-case-pattern'
813to record whether we upcased the expansion, downcased it, or did neither."
822 ;;(undo-boundary) 814 ;;(undo-boundary)
823 (let ((use-case-replace (and (if (eq dabbrev-case-fold-search 'case-fold-search) 815 (let ((use-case-replace (and (if (eq dabbrev-case-fold-search 'case-fold-search)
824 case-fold-search 816 case-fold-search
@@ -828,9 +820,14 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
828 (if (eq dabbrev-case-replace 'case-replace) 820 (if (eq dabbrev-case-replace 'case-replace)
829 case-replace 821 case-replace
830 dabbrev-case-replace)))) 822 dabbrev-case-replace))))
831 (and nil use-case-replace 823
832 (setq old (concat abbrev (or old ""))) 824 ;; If we upcased or downcased the original expansion,
833 (setq expansion (concat abbrev expansion))) 825 ;; do likewise for the subsequent words when we copy them.
826 (and (equal abbrev " ")
827 dabbrev--last-case-pattern
828 (setq expansion
829 (funcall dabbrev--last-case-pattern expansion)))
830
834 ;; If the expansion has mixed case 831 ;; If the expansion has mixed case
835 ;; and it is not simply a capitalized word, 832 ;; and it is not simply a capitalized word,
836 ;; or if the abbrev has mixed case, 833 ;; or if the abbrev has mixed case,
@@ -850,6 +847,16 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]."
850 (setq use-case-replace nil)) 847 (setq use-case-replace nil))
851 (if use-case-replace 848 (if use-case-replace
852 (setq expansion (downcase expansion))) 849 (setq expansion (downcase expansion)))
850
851 ;; In case we insert subsequent words,
852 ;; record if we upcased or downcased the first word,
853 ;; in order to do likewise for subsequent words.
854 (and record-case-pattern
855 (setq dabbrev--last-case-pattern
856 (and use-case-replace
857 (cond ((equal abbrev (upcase abbrev)) 'upcase)
858 ((equal abbrev (downcase abbrev)) 'downcase)))))
859
853 (if old 860 (if old
854 (save-excursion 861 (save-excursion
855 (search-backward old)) 862 (search-backward old))