diff options
| author | Karl Heuer | 1995-07-17 22:48:39 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-07-17 22:48:39 +0000 |
| commit | 63d991d6349ae456ab39a2301c4aae4e6a80168e (patch) | |
| tree | 3b47abc34f34e5371eeb4cb91bdef0c749372dba | |
| parent | c1fe251aceb9ca50b130ce1525e66e225aba337e (diff) | |
| download | emacs-63d991d6349ae456ab39a2301c4aae4e6a80168e.tar.gz emacs-63d991d6349ae456ab39a2301c4aae4e6a80168e.zip | |
(dabbrev--search): Don't let spurious match in middle
of word obscure real match at start of same word.
| -rw-r--r-- | lisp/dabbrev.el | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index d57ba974363..438ad165559 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el | |||
| @@ -789,38 +789,38 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | |||
| 789 | (if reverse | 789 | (if reverse |
| 790 | (re-search-backward pattern1 nil t) | 790 | (re-search-backward pattern1 nil t) |
| 791 | (re-search-forward pattern1 nil t))) | 791 | (re-search-forward pattern1 nil t))) |
| 792 | (cond | 792 | (goto-char (match-beginning 0)) |
| 793 | ((progn | 793 | ;; In case we matched in the middle of a word, |
| 794 | (goto-char (match-beginning 0)) | 794 | ;; back up to start of word and verify we still match. |
| 795 | (dabbrev--goto-start-of-abbrev) | 795 | (dabbrev--goto-start-of-abbrev) |
| 796 | (/= (point) (match-beginning 0))) | 796 | |
| 797 | ;; Prefix of found abbreviation not OK | 797 | (if (not (looking-at pattern1)) |
| 798 | nil) | 798 | nil |
| 799 | (t | 799 | ;; We have a truly valid match. Find the end. |
| 800 | (goto-char (match-beginning 0)) | ||
| 801 | (re-search-forward pattern2) | 800 | (re-search-forward pattern2) |
| 802 | (setq found-string | 801 | (setq found-string |
| 803 | (buffer-substring (match-beginning 1) (match-end 1))) | 802 | (buffer-substring (match-beginning 1) (match-end 1))) |
| 804 | (and ignore-case (setq found-string (downcase found-string))) | 803 | (and ignore-case (setq found-string (downcase found-string))) |
| 805 | ;; Throw away if found in table | 804 | ;; Ignore this match if it's already in the table. |
| 806 | (if (dabbrev-filter-elements | 805 | (if (dabbrev-filter-elements |
| 807 | table-string dabbrev--last-table | 806 | table-string dabbrev--last-table |
| 808 | (string= found-string table-string)) | 807 | (string= found-string table-string)) |
| 809 | (setq found-string nil)))) | 808 | (setq found-string nil))) |
| 809 | ;; Prepare to continue searching. | ||
| 810 | (if reverse | 810 | (if reverse |
| 811 | (goto-char (match-beginning 0)) | 811 | (goto-char (match-beginning 0)) |
| 812 | (goto-char (match-end 0)))) | 812 | (goto-char (match-end 0)))) |
| 813 | (cond | 813 | ;; If we found something, use it. |
| 814 | (found-string | 814 | (if found-string |
| 815 | ;;-------------------------------- | 815 | ;; Put it into `dabbrev--last-table' |
| 816 | ;; Put in `dabbrev--last-table' and decide if we should return | 816 | ;; and return it (either downcased, or as is). |
| 817 | ;; result or (downcase result) | 817 | (let ((result |
| 818 | ;;-------------------------------- | 818 | (buffer-substring (match-beginning 0) (match-end 0)))) |
| 819 | (setq dabbrev--last-table (cons found-string dabbrev--last-table)) | 819 | (setq dabbrev--last-table |
| 820 | (let ((result (buffer-substring (match-beginning 0) (match-end 0)))) | 820 | (cons found-string dabbrev--last-table)) |
| 821 | (if (and ignore-case (eval dabbrev-case-replace)) | 821 | (if (and ignore-case (eval dabbrev-case-replace)) |
| 822 | (downcase result) | 822 | (downcase result) |
| 823 | result)))))))) | 823 | result))))))) |
| 824 | 824 | ||
| 825 | (provide 'dabbrev) | 825 | (provide 'dabbrev) |
| 826 | 826 | ||