diff options
| author | Richard M. Stallman | 2002-05-14 19:45:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-05-14 19:45:16 +0000 |
| commit | 93a43334636555ece84e990241daf420fba429d5 (patch) | |
| tree | a10f170bd7c183a3ae8da20df1559b6648bf6ccd | |
| parent | be59410cd4ba7bc7d4309a1af6ec277e7057013c (diff) | |
| download | emacs-93a43334636555ece84e990241daf420fba429d5.tar.gz emacs-93a43334636555ece84e990241daf420fba429d5.zip | |
(dabbrev-case-distinction): New option.
(dabbrev--try-find): Handle dabbrev-case-distinction.
(dabbrev--search): Clean up the code.
(dabbrev-upcase-means-case-search): Doc fix.
(dabbrev-case-replace): Fix custom tags and docs.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/dabbrev.el | 57 |
2 files changed, 46 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 94e145e7b91..87ae381fe96 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2002-05-14 Richard M. Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * dabbrev.el (dabbrev-case-distinction): New option. | ||
| 4 | (dabbrev--try-find): Handle dabbrev-case-distinction. | ||
| 5 | (dabbrev--search): Clean up the code. | ||
| 6 | (dabbrev-upcase-means-case-search): Doc fix. | ||
| 7 | (dabbrev-case-replace): Fix custom tags and docs. | ||
| 8 | |||
| 1 | 2002-05-14 Jochen K,A|(Bpper <jochen@jochen-kuepper.de> | 9 | 2002-05-14 Jochen K,A|(Bpper <jochen@jochen-kuepper.de> |
| 2 | 10 | ||
| 3 | * calc/calc-units.el (math-standard-units): Update from CODATA. | 11 | * calc/calc-units.el (math-standard-units): Update from CODATA. |
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index 55b080ee0b1..f2beb011247 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el | |||
| @@ -147,23 +147,41 @@ Any other non-nil version means case is not significant." | |||
| 147 | 147 | ||
| 148 | (defcustom dabbrev-upcase-means-case-search nil | 148 | (defcustom dabbrev-upcase-means-case-search nil |
| 149 | "*The significance of an uppercase character in an abbreviation. | 149 | "*The significance of an uppercase character in an abbreviation. |
| 150 | nil means case fold search, non-nil means case sensitive search. | 150 | nil means case fold search when searching for possible expansions; |
| 151 | non-nil means case sensitive search. | ||
| 151 | 152 | ||
| 152 | This variable has an effect only when the value of | 153 | This variable has an effect only when the value of |
| 153 | `dabbrev-case-fold-search' says to ignore case." | 154 | `dabbrev-case-fold-search' says to ignore case." |
| 154 | :type 'boolean | 155 | :type 'boolean |
| 155 | :group 'dabbrev) | 156 | :group 'dabbrev) |
| 156 | 157 | ||
| 158 | (defcustom dabbrev-case-distinction 'case-replace | ||
| 159 | "*Whether dabbrev treats expansions as the same if they differ in case. | ||
| 160 | |||
| 161 | A value of nil means treat them as different. | ||
| 162 | A value of `case-replace' means distinguish them if `case-replace' is nil. | ||
| 163 | Any other non-nil value means to treat them as the same. | ||
| 164 | |||
| 165 | This variable has an effect only when the value of | ||
| 166 | `dabbrev-case-fold-search' specifies to ignore case." | ||
| 167 | :type '(choice (const :tag "off" nil) | ||
| 168 | (const :tag "based on `case-replace'" case-replace) | ||
| 169 | (other :tag "on" t)) | ||
| 170 | :group 'dabbrev | ||
| 171 | :version "21.4") | ||
| 172 | |||
| 157 | (defcustom dabbrev-case-replace 'case-replace | 173 | (defcustom dabbrev-case-replace 'case-replace |
| 158 | "*Controls whether dabbrev preserves case when expanding the abbreviation. | 174 | "*Whether dabbrev applies the abbreviations's case pattern to the expansion. |
| 159 | A value of nil means preserve case. | 175 | |
| 160 | A value of `case-replace' means preserve case if `case-replace' is nil. | 176 | A value of nil means preserve the expansion's case pattern. |
| 161 | Any other non-nil version means do not preserve case. | 177 | A value of `case-replace' means preserve it if `case-replace' is nil. |
| 178 | Any other non-nil value means modify the expansion | ||
| 179 | by applying the abbreviation's case pattern to it. | ||
| 162 | 180 | ||
| 163 | This variable has an effect only when the value of | 181 | This variable has an effect only when the value of |
| 164 | `dabbrev-case-fold-search' specifies to ignore case." | 182 | `dabbrev-case-fold-search' specifies to ignore case." |
| 165 | :type '(choice (const :tag "off" nil) | 183 | :type '(choice (const :tag "off" nil) |
| 166 | (const :tag "like M-x query-replace" case-replace) | 184 | (const :tag "based on `case-replace'" case-replace) |
| 167 | (other :tag "on" t)) | 185 | (other :tag "on" t)) |
| 168 | :group 'dabbrev) | 186 | :group 'dabbrev) |
| 169 | 187 | ||
| @@ -689,7 +707,11 @@ of the expansion in `dabbrev--last-expansion-location'." | |||
| 689 | (while (and (> count 0) | 707 | (while (and (> count 0) |
| 690 | (setq expansion (dabbrev--search abbrev | 708 | (setq expansion (dabbrev--search abbrev |
| 691 | reverse | 709 | reverse |
| 692 | ignore-case))) | 710 | (and ignore-case |
| 711 | (if (eq dabbrev-case-distinction 'case-replace) | ||
| 712 | case-replace | ||
| 713 | dabbrev-case-distinction)) | ||
| 714 | ))) | ||
| 693 | (setq count (1- count)))) | 715 | (setq count (1- count)))) |
| 694 | (and expansion | 716 | (and expansion |
| 695 | (setq dabbrev--last-expansion-location (point))) | 717 | (setq dabbrev--last-expansion-location (point))) |
| @@ -950,7 +972,7 @@ Leaves point at the location of the start of the expansion." | |||
| 950 | "\\(" dabbrev--abbrev-char-regexp "\\)")) | 972 | "\\(" dabbrev--abbrev-char-regexp "\\)")) |
| 951 | (pattern2 (concat (regexp-quote abbrev) | 973 | (pattern2 (concat (regexp-quote abbrev) |
| 952 | "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) | 974 | "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) |
| 953 | (found-string nil)) | 975 | found-string result) |
| 954 | ;; Limited search. | 976 | ;; Limited search. |
| 955 | (save-restriction | 977 | (save-restriction |
| 956 | (and dabbrev-limit | 978 | (and dabbrev-limit |
| @@ -974,7 +996,8 @@ Leaves point at the location of the start of the expansion." | |||
| 974 | ;; We have a truly valid match. Find the end. | 996 | ;; We have a truly valid match. Find the end. |
| 975 | (re-search-forward pattern2) | 997 | (re-search-forward pattern2) |
| 976 | (setq found-string (buffer-substring-no-properties | 998 | (setq found-string (buffer-substring-no-properties |
| 977 | (match-beginning 1) (match-end 1))) | 999 | (match-beginning 0) (match-end 0))) |
| 1000 | (setq result found-string) | ||
| 978 | (and ignore-case (setq found-string (downcase found-string))) | 1001 | (and ignore-case (setq found-string (downcase found-string))) |
| 979 | ;; Ignore this match if it's already in the table. | 1002 | ;; Ignore this match if it's already in the table. |
| 980 | (if (dabbrev-filter-elements | 1003 | (if (dabbrev-filter-elements |
| @@ -986,16 +1009,12 @@ Leaves point at the location of the start of the expansion." | |||
| 986 | (goto-char (match-beginning 0)) | 1009 | (goto-char (match-beginning 0)) |
| 987 | (goto-char (match-end 0)))) | 1010 | (goto-char (match-end 0)))) |
| 988 | ;; If we found something, use it. | 1011 | ;; If we found something, use it. |
| 989 | (if found-string | 1012 | (when found-string |
| 990 | ;; Put it into `dabbrev--last-table' | 1013 | ;; Put it into `dabbrev--last-table' |
| 991 | ;; and return it (either downcased, or as is). | 1014 | ;; and return it (either downcased, or as is). |
| 992 | (let ((result (buffer-substring-no-properties | 1015 | (setq dabbrev--last-table |
| 993 | (match-beginning 0) (match-end 0)))) | 1016 | (cons found-string dabbrev--last-table)) |
| 994 | (setq dabbrev--last-table | 1017 | result))))) |
| 995 | (cons found-string dabbrev--last-table)) | ||
| 996 | (if (and ignore-case (eval dabbrev-case-replace)) | ||
| 997 | result | ||
| 998 | result))))))) | ||
| 999 | 1018 | ||
| 1000 | (dolist (mess '("^No dynamic expansion for .* found$" | 1019 | (dolist (mess '("^No dynamic expansion for .* found$" |
| 1001 | "^No further dynamic expansion for .* found$" | 1020 | "^No further dynamic expansion for .* found$" |