Mercurial > emacs
comparison lisp/dabbrev.el @ 89909:68c22ea6027c
Sync to HEAD
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 16 Apr 2004 12:51:06 +0000 |
parents | 375f2633d815 |
children | 4c90ffeb71c5 |
comparison
equal
deleted
inserted
replaced
89908:ee1402f7b568 | 89909:68c22ea6027c |
---|---|
1 ;;; dabbrev.el --- dynamic abbreviation package | 1 ;;; dabbrev.el --- dynamic abbreviation package |
2 | 2 |
3 ;; Copyright (C) 1985, 86, 92, 94, 96, 1997, 2000, 01, 2003 | 3 ;; Copyright (C) 1985, 86, 92, 94, 96, 1997, 2000, 01, 03, 2004 |
4 ;; Free Software Foundation, Inc. | 4 ;; Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Don Morrison | 6 ;; Author: Don Morrison |
7 ;; Maintainer: Lars Lindberg <Lars.Lindberg@sypro.cap.se> | 7 ;; Maintainer: Lars Lindberg <Lars.Lindberg@sypro.cap.se> |
8 ;; Created: 16 Mars 1992 | 8 ;; Created: 16 Mars 1992 |
527 (length dabbrev--last-expansion)))) | 527 (length dabbrev--last-expansion)))) |
528 (goto-char dabbrev--last-expansion-location) | 528 (goto-char dabbrev--last-expansion-location) |
529 ;; Take the following word, with intermediate separators, | 529 ;; Take the following word, with intermediate separators, |
530 ;; as our expansion this time. | 530 ;; as our expansion this time. |
531 (re-search-forward | 531 (re-search-forward |
532 (concat "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) | 532 (concat "\\(?:" dabbrev--abbrev-char-regexp "\\)+")) |
533 (setq expansion (buffer-substring-no-properties | 533 (setq expansion (buffer-substring-no-properties |
534 dabbrev--last-expansion-location (point))) | 534 dabbrev--last-expansion-location (point))) |
535 | 535 |
536 ;; Record the end of this expansion, in case we repeat this. | 536 ;; Record the end of this expansion, in case we repeat this. |
537 (setq dabbrev--last-expansion-location (point))) | 537 (setq dabbrev--last-expansion-location (point))) |
791 (setq dabbrev--friend-buffer-list | 791 (setq dabbrev--friend-buffer-list |
792 (dabbrev--make-friend-buffer-list)))) | 792 (dabbrev--make-friend-buffer-list)))) |
793 ;; Walk through the buffers till we find a match. | 793 ;; Walk through the buffers till we find a match. |
794 (let (expansion) | 794 (let (expansion) |
795 (while (and (not expansion) dabbrev--friend-buffer-list) | 795 (while (and (not expansion) dabbrev--friend-buffer-list) |
796 (setq dabbrev--last-buffer | 796 (setq dabbrev--last-buffer (pop dabbrev--friend-buffer-list)) |
797 (car dabbrev--friend-buffer-list)) | |
798 (setq dabbrev--friend-buffer-list | |
799 (cdr dabbrev--friend-buffer-list)) | |
800 (set-buffer dabbrev--last-buffer) | 797 (set-buffer dabbrev--last-buffer) |
801 (dabbrev--scanning-message) | 798 (dabbrev--scanning-message) |
802 (setq dabbrev--last-expansion-location (point-min)) | 799 (setq dabbrev--last-expansion-location (point-min)) |
803 (setq expansion (dabbrev--try-find abbrev nil 1 ignore-case))) | 800 (setq expansion (dabbrev--try-find abbrev nil 1 ignore-case))) |
804 expansion))))) | 801 expansion))))) |
849 (delq (dabbrev--minibuffer-origin) list)))) | 846 (delq (dabbrev--minibuffer-origin) list)))) |
850 list)) | 847 list)) |
851 | 848 |
852 (defun dabbrev--safe-replace-match (string &optional fixedcase literal) | 849 (defun dabbrev--safe-replace-match (string &optional fixedcase literal) |
853 (if (eq major-mode 'picture-mode) | 850 (if (eq major-mode 'picture-mode) |
854 (picture-replace-match string fixedcase literal) | 851 (with-no-warnings |
852 (picture-replace-match string fixedcase literal)) | |
855 (replace-match string fixedcase literal))) | 853 (replace-match string fixedcase literal))) |
856 | 854 |
857 ;;;---------------------------------------------------------------- | 855 ;;;---------------------------------------------------------------- |
858 (defun dabbrev--substitute-expansion (old abbrev expansion record-case-pattern) | 856 (defun dabbrev--substitute-expansion (old abbrev expansion record-case-pattern) |
859 "Replace OLD with EXPANSION in the buffer. | 857 "Replace OLD with EXPANSION in the buffer. |
997 | 995 |
998 (if (not (looking-at pattern1)) | 996 (if (not (looking-at pattern1)) |
999 nil | 997 nil |
1000 ;; We have a truly valid match. Find the end. | 998 ;; We have a truly valid match. Find the end. |
1001 (re-search-forward pattern2) | 999 (re-search-forward pattern2) |
1002 (setq found-string (buffer-substring-no-properties | 1000 (setq found-string (match-string-no-properties 0)) |
1003 (match-beginning 0) (match-end 0))) | |
1004 (setq result found-string) | 1001 (setq result found-string) |
1005 (and ignore-case (setq found-string (downcase found-string))) | 1002 (and ignore-case (setq found-string (downcase found-string))) |
1006 ;; Ignore this match if it's already in the table. | 1003 ;; Ignore this match if it's already in the table. |
1007 (if (dabbrev-filter-elements | 1004 (if (dabbrev-filter-elements |
1008 table-string dabbrev--last-table | 1005 table-string dabbrev--last-table |
1009 (string= found-string table-string)) | 1006 (string= found-string table-string)) |
1010 (setq found-string nil))) | 1007 (setq found-string nil))) |
1011 ;; Prepare to continue searching. | 1008 ;; Prepare to continue searching. |
1012 (if reverse | 1009 (goto-char (if reverse (match-beginning 0) (match-end 0)))) |
1013 (goto-char (match-beginning 0)) | |
1014 (goto-char (match-end 0)))) | |
1015 ;; If we found something, use it. | 1010 ;; If we found something, use it. |
1016 (when found-string | 1011 (when found-string |
1017 ;; Put it into `dabbrev--last-table' | 1012 ;; Put it into `dabbrev--last-table' |
1018 ;; and return it (either downcased, or as is). | 1013 ;; and return it (either downcased, or as is). |
1019 (setq dabbrev--last-table | 1014 (setq dabbrev--last-table |
1025 "^No possible abbreviation preceding point$")) | 1020 "^No possible abbreviation preceding point$")) |
1026 (add-to-list 'debug-ignored-errors mess)) | 1021 (add-to-list 'debug-ignored-errors mess)) |
1027 | 1022 |
1028 (provide 'dabbrev) | 1023 (provide 'dabbrev) |
1029 | 1024 |
1025 ;;; arch-tag: 29e58596-f080-4306-a409-70296cf9d46f | |
1030 ;;; dabbrev.el ends here | 1026 ;;; dabbrev.el ends here |