Mercurial > emacs
comparison lisp/isearch.el @ 4876:8ddcaee25a73
(isearch-yank): Handle `kill' as chunk type.
(isearch-yank-kill): New command, on M-y and mouse-2.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 24 Oct 1993 04:05:22 +0000 |
parents | 0be7300b18d9 |
children | c4c063887b13 |
comparison
equal
deleted
inserted
replaced
4875:78a52ca82a71 | 4876:8ddcaee25a73 |
---|---|
2 | 2 |
3 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> | 5 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu> |
6 | 6 |
7 ;; |$Date: 1993/10/09 20:00:23 $|$Revision: 1.50 $ | 7 ;; |$Date: 1993/10/09 20:03:33 $|$Revision: 1.51 $ |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
10 | 10 |
11 ;; GNU Emacs is distributed in the hope that it will be useful, | 11 ;; GNU Emacs is distributed in the hope that it will be useful, |
12 ;; but WITHOUT ANY WARRANTY. No author or distributor | 12 ;; but WITHOUT ANY WARRANTY. No author or distributor |
231 (define-key map "\t" 'isearch-printing-char) | 231 (define-key map "\t" 'isearch-printing-char) |
232 (define-key map " " 'isearch-whitespace-chars) | 232 (define-key map " " 'isearch-whitespace-chars) |
233 | 233 |
234 (define-key map "\C-w" 'isearch-yank-word) | 234 (define-key map "\C-w" 'isearch-yank-word) |
235 (define-key map "\C-y" 'isearch-yank-line) | 235 (define-key map "\C-y" 'isearch-yank-line) |
236 (define-key map [mouse-2] 'isearch-yank-kill) | |
237 ;; This overrides the default binding for t. | |
238 (define-key map [down-mouse-2] 'nil) | |
236 | 239 |
237 ;; Bind the ASCII-equivalent "function keys" explicitly | 240 ;; Bind the ASCII-equivalent "function keys" explicitly |
238 ;; if we bind their equivalents, | 241 ;; if we bind their equivalents, |
239 ;; since otherwise the default binding would override. | 242 ;; since otherwise the default binding would override. |
240 ;; We bind [escape] below. | 243 ;; We bind [escape] below. |
264 (define-key map [escape] meta-map)) | 267 (define-key map [escape] meta-map)) |
265 (define-key map (vector meta-prefix-char t) 'isearch-other-meta-char) | 268 (define-key map (vector meta-prefix-char t) 'isearch-other-meta-char) |
266 | 269 |
267 (define-key map "\M-n" 'isearch-ring-advance) | 270 (define-key map "\M-n" 'isearch-ring-advance) |
268 (define-key map "\M-p" 'isearch-ring-retreat) | 271 (define-key map "\M-p" 'isearch-ring-retreat) |
272 (define-key map "\M-y" 'isearch-yank-kill) | |
269 | 273 |
270 (define-key map "\M-\t" 'isearch-complete) | 274 (define-key map "\M-\t" 'isearch-complete) |
271 | 275 |
272 ;; For emacs 19, switching frames should terminate isearch-mode | 276 ;; For emacs 19, switching frames should terminate isearch-mode |
273 (if isearch-gnu-emacs-events | 277 (if isearch-gnu-emacs-events |
852 (isearch-update)) | 856 (isearch-update)) |
853 | 857 |
854 | 858 |
855 (defun isearch-yank (chunk) | 859 (defun isearch-yank (chunk) |
856 ;; Helper for isearch-yank-word and isearch-yank-line | 860 ;; Helper for isearch-yank-word and isearch-yank-line |
857 (let ((string (save-excursion | 861 ;; CHUNK should be word, line or kill. |
858 (and (not isearch-forward) isearch-other-end | 862 (let ((string (cond |
859 (goto-char isearch-other-end)) | 863 ((eq chunk 'kill) |
860 (buffer-substring | 864 (current-kill 0)) |
861 (point) | 865 (t |
862 (save-excursion | 866 (save-excursion |
863 (cond | 867 (and (not isearch-forward) isearch-other-end |
864 ((eq chunk 'word) | 868 (goto-char isearch-other-end)) |
865 (forward-word 1)) | 869 (buffer-substring |
866 ((eq chunk 'line) | 870 (point) |
867 (end-of-line))) | 871 (save-excursion |
868 (point)))))) | 872 (cond |
873 ((eq chunk 'word) | |
874 (forward-word 1)) | |
875 ((eq chunk 'line) | |
876 (end-of-line))) | |
877 (point)))))))) | |
869 ;; Downcase the string if not supposed to case-fold yanked strings. | 878 ;; Downcase the string if not supposed to case-fold yanked strings. |
870 (if (and isearch-case-fold-search | 879 (if (and isearch-case-fold-search |
871 (eq 'not-yanks search-upper-case)) | 880 (eq 'not-yanks search-upper-case)) |
872 (setq string (downcase string))) | 881 (setq string (downcase string))) |
873 (if isearch-regexp (setq string (regexp-quote string))) | 882 (if isearch-regexp (setq string (regexp-quote string))) |
878 string "")) | 887 string "")) |
879 ;; Don't move cursor in reverse search. | 888 ;; Don't move cursor in reverse search. |
880 isearch-yank-flag t)) | 889 isearch-yank-flag t)) |
881 (isearch-search-and-update)) | 890 (isearch-search-and-update)) |
882 | 891 |
892 (defun isearch-yank-kill () | |
893 "Pull string from kill ring into search string." | |
894 (interactive) | |
895 (isearch-yank 'kill)) | |
883 | 896 |
884 (defun isearch-yank-word () | 897 (defun isearch-yank-word () |
885 "Pull next word from buffer into search string." | 898 "Pull next word from buffer into search string." |
886 (interactive) | 899 (interactive) |
887 (isearch-yank 'word)) | 900 (isearch-yank 'word)) |