Mercurial > emacs
comparison lisp/isearch.el @ 50733:f038a895a805
(isearch-complete1): Don't allocate unnecessarily.
(isearch-complete-edit): Adjust to Emacs-21's new minibuffer handling.
(isearch-update-ring): Use push.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 29 Apr 2003 20:38:53 +0000 |
parents | 07a876ca33f0 |
children | f26c6004759f |
comparison
equal
deleted
inserted
replaced
50732:30fe8b465071 | 50733:f038a895a805 |
---|---|
1 ;;; isearch.el --- incremental search minor mode | 1 ;;; isearch.el --- incremental search minor mode |
2 | 2 |
3 ;; Copyright (C) 1992, 93, 94, 95, 96, 97, 1999, 2000, 2001 | 3 ;; Copyright (C) 1992, 93, 94, 95, 96, 97, 1999, 2000, 01, 2003 |
4 ;; Free Software Foundation, Inc. | 4 ;; Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> | 6 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> |
7 ;; Maintainer: FSF | 7 ;; Maintainer: FSF |
8 ;; Keywords: matching | 8 ;; Keywords: matching |
736 REGEXP says which ring to use." | 736 REGEXP says which ring to use." |
737 (if regexp | 737 (if regexp |
738 (if (or (null regexp-search-ring) | 738 (if (or (null regexp-search-ring) |
739 (not (string= string (car regexp-search-ring)))) | 739 (not (string= string (car regexp-search-ring)))) |
740 (progn | 740 (progn |
741 (setq regexp-search-ring | 741 (push string regexp-search-ring) |
742 (cons string regexp-search-ring)) | |
743 (if (> (length regexp-search-ring) regexp-search-ring-max) | 742 (if (> (length regexp-search-ring) regexp-search-ring-max) |
744 (setcdr (nthcdr (1- search-ring-max) regexp-search-ring) | 743 (setcdr (nthcdr (1- search-ring-max) regexp-search-ring) |
745 nil)))) | 744 nil)))) |
746 (if (or (null search-ring) | 745 (if (or (null search-ring) |
747 (not (string= string (car search-ring)))) | 746 (not (string= string (car search-ring)))) |
748 (progn | 747 (progn |
749 (setq search-ring (cons string search-ring)) | 748 (push string search-ring) |
750 (if (> (length search-ring) search-ring-max) | 749 (if (> (length search-ring) search-ring-max) |
751 (setcdr (nthcdr (1- search-ring-max) search-ring) nil)))))) | 750 (setcdr (nthcdr (1- search-ring-max) search-ring) nil)))))) |
752 | 751 |
753 ;; Switching buffers should first terminate isearch-mode. | 752 ;; Switching buffers should first terminate isearch-mode. |
754 ;; ;; For Emacs 19, the frame switch event is handled. | 753 ;; ;; For Emacs 19, the frame switch event is handled. |
1491 | 1490 |
1492 (defun isearch-complete1 () | 1491 (defun isearch-complete1 () |
1493 ;; Helper for isearch-complete and isearch-complete-edit | 1492 ;; Helper for isearch-complete and isearch-complete-edit |
1494 ;; Return t if completion OK, nil if no completion exists. | 1493 ;; Return t if completion OK, nil if no completion exists. |
1495 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) | 1494 (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) |
1496 (alist (mapcar (function (lambda (string) (list string))) ring)) | |
1497 (completion-ignore-case case-fold-search) | 1495 (completion-ignore-case case-fold-search) |
1498 (completion (try-completion isearch-string alist))) | 1496 (completion (try-completion isearch-string ring))) |
1499 (cond | 1497 (cond |
1500 ((eq completion t) | 1498 ((eq completion t) |
1501 ;; isearch-string stays the same | 1499 ;; isearch-string stays the same |
1502 t) | 1500 t) |
1503 ((or completion ; not nil, must be a string | 1501 ((or completion ; not nil, must be a string |
1505 (if (equal completion isearch-string) ;; no extension? | 1503 (if (equal completion isearch-string) ;; no extension? |
1506 (progn | 1504 (progn |
1507 (if completion-auto-help | 1505 (if completion-auto-help |
1508 (with-output-to-temp-buffer "*Isearch completions*" | 1506 (with-output-to-temp-buffer "*Isearch completions*" |
1509 (display-completion-list | 1507 (display-completion-list |
1510 (all-completions isearch-string alist)))) | 1508 (all-completions isearch-string ring)))) |
1511 t) | 1509 t) |
1512 (and completion | 1510 (and completion |
1513 (setq isearch-string completion)))) | 1511 (setq isearch-string completion)))) |
1514 (t | 1512 (t |
1515 (message "No completion") ; waits a second if in minibuffer | 1513 (message "No completion") ; waits a second if in minibuffer |
1527 (isearch-update))) | 1525 (isearch-update))) |
1528 | 1526 |
1529 (defun isearch-complete-edit () | 1527 (defun isearch-complete-edit () |
1530 "Same as `isearch-complete' except in the minibuffer." | 1528 "Same as `isearch-complete' except in the minibuffer." |
1531 (interactive) | 1529 (interactive) |
1532 (setq isearch-string (buffer-string)) | 1530 (setq isearch-string (field-string)) |
1533 (if (isearch-complete1) | 1531 (if (isearch-complete1) |
1534 (progn | 1532 (progn |
1535 (delete-field) | 1533 (delete-field) |
1536 (insert isearch-string)))) | 1534 (insert isearch-string)))) |
1537 | 1535 |