diff options
| author | Richard M. Stallman | 1996-08-07 18:27:20 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-08-07 18:27:20 +0000 |
| commit | dea5efcbe3af1c2f19e7983c3276cd9ad25bc5b4 (patch) | |
| tree | 5d99ba8b6ea68ee7a92b4db13ecde61e211cb898 | |
| parent | 3d52d58a996f89a38134003d638d094989e40298 (diff) | |
| download | emacs-dea5efcbe3af1c2f19e7983c3276cd9ad25bc5b4.tar.gz emacs-dea5efcbe3af1c2f19e7983c3276cd9ad25bc5b4.zip | |
(dabbrev--last-case-pattern): New variable.
(dabbrev-expand): Set it for ordinary expansions;
use it when copying successive words.
| -rw-r--r-- | lisp/dabbrev.el | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index 3396ef34564..ed6ef3e92a4 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el | |||
| @@ -252,6 +252,10 @@ this list.") | |||
| 252 | ;; The buffer we last did a completion in. | 252 | ;; The buffer we last did a completion in. |
| 253 | (defvar dabbrev--last-completion-buffer nil) | 253 | (defvar dabbrev--last-completion-buffer nil) |
| 254 | 254 | ||
| 255 | ;; Non-nil means we should upcase | ||
| 256 | ;; when copying successive words. | ||
| 257 | (defvar dabbrev--last-case-pattern nil) | ||
| 258 | |||
| 255 | ;; Same as dabbrev-check-other-buffers, but is set for every expand. | 259 | ;; Same as dabbrev-check-other-buffers, but is set for every expand. |
| 256 | (defvar dabbrev--check-other-buffers dabbrev-check-other-buffers) | 260 | (defvar dabbrev--check-other-buffers dabbrev-check-other-buffers) |
| 257 | 261 | ||
| @@ -313,8 +317,8 @@ if there is a suitable one already." | |||
| 313 | (and arg (= (prefix-numeric-value arg) 16))) | 317 | (and arg (= (prefix-numeric-value arg) 16))) |
| 314 | (abbrev (dabbrev--abbrev-at-point)) | 318 | (abbrev (dabbrev--abbrev-at-point)) |
| 315 | (ignore-case-p (and (eval dabbrev-case-fold-search) | 319 | (ignore-case-p (and (eval dabbrev-case-fold-search) |
| 316 | (or (not dabbrev-upcase-means-case-search) | 320 | (or (not dabbrev-upcase-means-case-search) |
| 317 | (string= abbrev (downcase abbrev))))) | 321 | (string= abbrev (downcase abbrev))))) |
| 318 | (my-obarray dabbrev--last-obarray) | 322 | (my-obarray dabbrev--last-obarray) |
| 319 | init) | 323 | init) |
| 320 | (save-excursion | 324 | (save-excursion |
| @@ -414,7 +418,8 @@ direction of search to backward if set non-nil. | |||
| 414 | 418 | ||
| 415 | See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | 419 | See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." |
| 416 | (interactive "*P") | 420 | (interactive "*P") |
| 417 | (let (abbrev expansion old direction (orig-point (point))) | 421 | (let (abbrev record-case-pattern |
| 422 | expansion old direction (orig-point (point))) | ||
| 418 | ;; abbrev -- the abbrev to expand | 423 | ;; abbrev -- the abbrev to expand |
| 419 | ;; expansion -- the expansion found (eventually) or nil until then | 424 | ;; expansion -- the expansion found (eventually) or nil until then |
| 420 | ;; old -- the text currently in the buffer | 425 | ;; old -- the text currently in the buffer |
| @@ -438,14 +443,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | |||
| 438 | (markerp dabbrev--last-abbrev-location) | 443 | (markerp dabbrev--last-abbrev-location) |
| 439 | (marker-position dabbrev--last-abbrev-location) | 444 | (marker-position dabbrev--last-abbrev-location) |
| 440 | (= (point) (1+ dabbrev--last-abbrev-location))) | 445 | (= (point) (1+ dabbrev--last-abbrev-location))) |
| 441 | (let* ((prev-expansion | 446 | (progn |
| 442 | (buffer-substring-no-properties | ||
| 443 | (- dabbrev--last-abbrev-location (length dabbrev--last-expansion)) | ||
| 444 | dabbrev--last-abbrev-location)) | ||
| 445 | ;; If the previous expansion was upcased. | ||
| 446 | ;; upcase this one too. | ||
| 447 | (upcase-it | ||
| 448 | (equal prev-expansion (upcase prev-expansion)))) | ||
| 449 | ;; The "abbrev" to expand is just the space. | 447 | ;; The "abbrev" to expand is just the space. |
| 450 | (setq abbrev " ") | 448 | (setq abbrev " ") |
| 451 | (save-excursion | 449 | (save-excursion |
| @@ -466,7 +464,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | |||
| 466 | (setq expansion | 464 | (setq expansion |
| 467 | (buffer-substring dabbrev--last-expansion-location | 465 | (buffer-substring dabbrev--last-expansion-location |
| 468 | (point))) | 466 | (point))) |
| 469 | (if upcase-it | 467 | (if dabbrev--last-case-pattern |
| 470 | (setq expansion (upcase expansion))) | 468 | (setq expansion (upcase expansion))) |
| 471 | 469 | ||
| 472 | ;; Record the end of this expansion, in case we repeat this. | 470 | ;; Record the end of this expansion, in case we repeat this. |
| @@ -481,6 +479,7 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | |||
| 481 | (if dabbrev-backward-only 1 0) | 479 | (if dabbrev-backward-only 1 0) |
| 482 | (prefix-numeric-value arg))) | 480 | (prefix-numeric-value arg))) |
| 483 | (setq abbrev (dabbrev--abbrev-at-point)) | 481 | (setq abbrev (dabbrev--abbrev-at-point)) |
| 482 | (setq record-case-pattern t) | ||
| 484 | (setq old nil))) | 483 | (setq old nil))) |
| 485 | 484 | ||
| 486 | ;;-------------------------------- | 485 | ;;-------------------------------- |
| @@ -520,6 +519,15 @@ See also `dabbrev-abbrev-char-regexp' and \\[dabbrev-completion]." | |||
| 520 | ;; Success: stick it in and return. | 519 | ;; Success: stick it in and return. |
| 521 | (setq buffer-undo-list (cons orig-point buffer-undo-list)) | 520 | (setq buffer-undo-list (cons orig-point buffer-undo-list)) |
| 522 | (dabbrev--substitute-expansion old abbrev expansion) | 521 | (dabbrev--substitute-expansion old abbrev expansion) |
| 522 | |||
| 523 | ;; If we are not copying successive words now, | ||
| 524 | ;; set dabbrev--last-case-pattern. | ||
| 525 | (and record-case-pattern | ||
| 526 | (setq dabbrev--last-case-pattern | ||
| 527 | (and (eval dabbrev-case-fold-search) | ||
| 528 | (not dabbrev-upcase-means-case-search) | ||
| 529 | (equal abbrev (upcase abbrev))))) | ||
| 530 | |||
| 523 | ;; Save state for re-expand. | 531 | ;; Save state for re-expand. |
| 524 | (setq dabbrev--last-expansion expansion) | 532 | (setq dabbrev--last-expansion expansion) |
| 525 | (setq dabbrev--last-abbreviation abbrev) | 533 | (setq dabbrev--last-abbreviation abbrev) |