diff options
| author | Luc Teirlinck | 2005-11-27 23:54:40 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2005-11-27 23:54:40 +0000 |
| commit | fe0e0a47a5c5fc401ecb58099971168781dace2a (patch) | |
| tree | 09f62e2f9dd5775e6c21810d5795cc8174e5f3bd | |
| parent | 0ee83bc6fa6cfbcb5199e68d3e32deb4c304d470 (diff) | |
| download | emacs-fe0e0a47a5c5fc401ecb58099971168781dace2a.tar.gz emacs-fe0e0a47a5c5fc401ecb58099971168781dace2a.zip | |
(dabbrev-completion): Simplify code, by getting rid of `if' whose
condition always returned nil. Doc fix.
| -rw-r--r-- | lisp/dabbrev.el | 94 |
1 files changed, 38 insertions, 56 deletions
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index b330f2b10d7..ea99030d943 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el | |||
| @@ -373,11 +373,7 @@ function pointed out by `dabbrev-friend-buffer-function' to find the | |||
| 373 | completions. | 373 | completions. |
| 374 | 374 | ||
| 375 | If the prefix argument is 16 (which comes from C-u C-u), | 375 | If the prefix argument is 16 (which comes from C-u C-u), |
| 376 | then it searches *all* buffers. | 376 | then it searches *all* buffers." |
| 377 | |||
| 378 | With no prefix argument, it reuses an old completion list | ||
| 379 | if there is a suitable one already." | ||
| 380 | |||
| 381 | (interactive "*P") | 377 | (interactive "*P") |
| 382 | (dabbrev--reset-global-variables) | 378 | (dabbrev--reset-global-variables) |
| 383 | (let* ((dabbrev-check-other-buffers (and arg t)) | 379 | (let* ((dabbrev-check-other-buffers (and arg t)) |
| @@ -392,57 +388,43 @@ if there is a suitable one already." | |||
| 392 | (my-obarray dabbrev--last-obarray) | 388 | (my-obarray dabbrev--last-obarray) |
| 393 | init) | 389 | init) |
| 394 | (save-excursion | 390 | (save-excursion |
| 395 | (if (and (null arg) | 391 | ;;-------------------------------- |
| 396 | my-obarray | 392 | ;; New abbreviation to expand. |
| 397 | (or (eq dabbrev--last-completion-buffer (current-buffer)) | 393 | ;;-------------------------------- |
| 398 | (and (window-minibuffer-p (selected-window)) | 394 | (setq dabbrev--last-abbreviation abbrev) |
| 399 | (eq dabbrev--last-completion-buffer | 395 | ;; Find all expansion |
| 400 | (dabbrev--minibuffer-origin)))) | 396 | (let ((completion-list |
| 401 | dabbrev--last-abbreviation | 397 | (dabbrev--find-all-expansions abbrev ignore-case-p)) |
| 402 | (>= (length abbrev) (length dabbrev--last-abbreviation)) | 398 | (completion-ignore-case ignore-case-p)) |
| 403 | (string= dabbrev--last-abbreviation | 399 | ;; Make an obarray with all expansions |
| 404 | (substring abbrev 0 | 400 | (setq my-obarray (make-vector (length completion-list) 0)) |
| 405 | (length dabbrev--last-abbreviation))) | 401 | (or (> (length my-obarray) 0) |
| 406 | (setq init (try-completion abbrev my-obarray))) | 402 | (error "No dynamic expansion for \"%s\" found%s" |
| 407 | ;; We can reuse the existing completion list. | 403 | abbrev |
| 408 | nil | 404 | (if dabbrev--check-other-buffers "" " in this-buffer"))) |
| 409 | ;;-------------------------------- | 405 | (cond |
| 410 | ;; New abbreviation to expand. | 406 | ((or (not ignore-case-p) |
| 411 | ;;-------------------------------- | 407 | (not dabbrev-case-replace)) |
| 412 | (setq dabbrev--last-abbreviation abbrev) | 408 | (mapc (function (lambda (string) |
| 413 | ;; Find all expansion | 409 | (intern string my-obarray))) |
| 414 | (let ((completion-list | 410 | completion-list)) |
| 415 | (dabbrev--find-all-expansions abbrev ignore-case-p)) | 411 | ((string= abbrev (upcase abbrev)) |
| 416 | (completion-ignore-case ignore-case-p)) | 412 | (mapc (function (lambda (string) |
| 417 | ;; Make an obarray with all expansions | 413 | (intern (upcase string) my-obarray))) |
| 418 | (setq my-obarray (make-vector (length completion-list) 0)) | 414 | completion-list)) |
| 419 | (or (> (length my-obarray) 0) | 415 | ((string= (substring abbrev 0 1) |
| 420 | (error "No dynamic expansion for \"%s\" found%s" | 416 | (upcase (substring abbrev 0 1))) |
| 421 | abbrev | 417 | (mapc (function (lambda (string) |
| 422 | (if dabbrev--check-other-buffers "" " in this-buffer"))) | 418 | (intern (capitalize string) my-obarray))) |
| 423 | (cond | 419 | completion-list)) |
| 424 | ((or (not ignore-case-p) | 420 | (t |
| 425 | (not dabbrev-case-replace)) | 421 | (mapc (function (lambda (string) |
| 426 | (mapc (function (lambda (string) | 422 | (intern (downcase string) my-obarray))) |
| 427 | (intern string my-obarray))) | 423 | completion-list))) |
| 428 | completion-list)) | 424 | (setq dabbrev--last-obarray my-obarray) |
| 429 | ((string= abbrev (upcase abbrev)) | 425 | (setq dabbrev--last-completion-buffer (current-buffer)) |
| 430 | (mapc (function (lambda (string) | 426 | ;; Find the longest common string. |
| 431 | (intern (upcase string) my-obarray))) | 427 | (setq init (try-completion abbrev my-obarray)))) |
| 432 | completion-list)) | ||
| 433 | ((string= (substring abbrev 0 1) | ||
| 434 | (upcase (substring abbrev 0 1))) | ||
| 435 | (mapc (function (lambda (string) | ||
| 436 | (intern (capitalize string) my-obarray))) | ||
| 437 | completion-list)) | ||
| 438 | (t | ||
| 439 | (mapc (function (lambda (string) | ||
| 440 | (intern (downcase string) my-obarray))) | ||
| 441 | completion-list))) | ||
| 442 | (setq dabbrev--last-obarray my-obarray) | ||
| 443 | (setq dabbrev--last-completion-buffer (current-buffer)) | ||
| 444 | ;; Find the longest common string. | ||
| 445 | (setq init (try-completion abbrev my-obarray))))) | ||
| 446 | ;;-------------------------------- | 428 | ;;-------------------------------- |
| 447 | ;; Let the user choose between the expansions | 429 | ;; Let the user choose between the expansions |
| 448 | ;;-------------------------------- | 430 | ;;-------------------------------- |