comparison lisp/isearch.el @ 20275:0e102e83c51d

(isearch-yank-string): New helper function. (isearch-yank-kill, isearch-yank-word, isearch-yank-line): Use it. (isearch-yank-x-selection): New function. (isearch-yank): Function deleted.
author Karl Heuer <kwzh@gnu.org>
date Tue, 18 Nov 1997 22:31:16 +0000
parents dd567e1fddd5
children cfb872a45411
comparison
equal deleted inserted replaced
20274:faa32765fb8f 20275:0e102e83c51d
942 (ding) 942 (ding)
943 (isearch-pop-state)) 943 (isearch-pop-state))
944 (isearch-update)) 944 (isearch-update))
945 945
946 946
947 (defun isearch-yank (chunk) 947 (defun isearch-yank-string (string)
948 ;; Helper for isearch-yank-word and isearch-yank-line 948 "Pull STRING into search string."
949 ;; CHUNK should be word, line, kill, or x-sel. 949 ;; Downcase the string if not supposed to case-fold yanked strings.
950 (let ((string (cond 950 (if (and isearch-case-fold-search
951 ((eq chunk 'kill) 951 (eq 'not-yanks search-upper-case))
952 (current-kill 0)) 952 (setq string (downcase string)))
953 ((eq chunk 'x-sel) 953 (if isearch-regexp (setq string (regexp-quote string)))
954 (x-get-selection)) 954 (setq isearch-string (concat isearch-string string)
955 (t 955 isearch-message
956 (save-excursion 956 (concat isearch-message
957 (and (not isearch-forward) isearch-other-end 957 (mapconcat 'isearch-text-char-description
958 (goto-char isearch-other-end)) 958 string ""))
959 (buffer-substring 959 ;; Don't move cursor in reverse search.
960 (point) 960 isearch-yank-flag t)
961 (save-excursion
962 (cond
963 ((eq chunk 'word)
964 (forward-word 1))
965 ((eq chunk 'line)
966 (end-of-line)))
967 (point))))))))
968 ;; Downcase the string if not supposed to case-fold yanked strings.
969 (if (and isearch-case-fold-search
970 (eq 'not-yanks search-upper-case))
971 (setq string (downcase string)))
972 (if isearch-regexp (setq string (regexp-quote string)))
973 (setq isearch-string (concat isearch-string string)
974 isearch-message
975 (concat isearch-message
976 (mapconcat 'isearch-text-char-description
977 string ""))
978 ;; Don't move cursor in reverse search.
979 isearch-yank-flag t))
980 (isearch-search-and-update)) 961 (isearch-search-and-update))
981 962
982 (defun isearch-yank-kill () 963 (defun isearch-yank-kill ()
983 "Pull string from kill ring into search string." 964 "Pull string from kill ring into search string."
984 (interactive) 965 (interactive)
985 (isearch-yank 'kill)) 966 (isearch-yank-string (current-kill 0)))
967
968 (defun isearch-yank-x-selection ()
969 "Pull current X selection into search string."
970 (interactive)
971 (isearch-yank-string (x-get-selection)))
986 972
987 (defun isearch-yank-word () 973 (defun isearch-yank-word ()
988 "Pull next word from buffer into search string." 974 "Pull next word from buffer into search string."
989 (interactive) 975 (interactive)
990 (isearch-yank 'word)) 976 (isearch-yank-string
977 (save-excursion
978 (and (not isearch-forward) isearch-other-end
979 (goto-char isearch-other-end))
980 (buffer-substring (point) (progn (forward-word 1) (point))))))
991 981
992 (defun isearch-yank-line () 982 (defun isearch-yank-line ()
993 "Pull rest of line from buffer into search string." 983 "Pull rest of line from buffer into search string."
994 (interactive) 984 (interactive)
995 (isearch-yank 'line)) 985 (isearch-yank-string
986 (save-excursion
987 (and (not isearch-forward) isearch-other-end
988 (goto-char isearch-other-end))
989 (buffer-substring (point) (line-end-position)))))
996 990
997 991
998 (defun isearch-search-and-update () 992 (defun isearch-search-and-update ()
999 ;; Do the search and update the display. 993 ;; Do the search and update the display.
1000 (if (and (not isearch-success) 994 (if (and (not isearch-success)