diff options
| author | Karl Heuer | 1997-11-18 22:31:16 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-11-18 22:31:16 +0000 |
| commit | 9cf081fa5cbfae43320c1e2fdfa9f4c6b13dfe59 (patch) | |
| tree | f9181586cb3db5d7ed71db3c31bda38053221ad4 | |
| parent | 4877ba13d7971e10bf8b35e6c675f06bd9c46d2a (diff) | |
| download | emacs-9cf081fa5cbfae43320c1e2fdfa9f4c6b13dfe59.tar.gz emacs-9cf081fa5cbfae43320c1e2fdfa9f4c6b13dfe59.zip | |
(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.
| -rw-r--r-- | lisp/isearch.el | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index d253278fe2f..9d75bc35143 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -944,55 +944,49 @@ If no previous match was done, just beep." | |||
| 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 () |