Mercurial > emacs
comparison lisp/simple.el @ 48583:150e7a54d970
(yank-window-start): New variable.
(yank): Record yank-window-start
(yank-pop): Use yank-window-start.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 29 Nov 2002 15:09:37 +0000 |
parents | e670dd0e8087 |
children | 37b9b1f18615 |
comparison
equal
deleted
inserted
replaced
48582:cb623072f5da | 48583:150e7a54d970 |
---|---|
1928 "*Text properties to discard when yanking." | 1928 "*Text properties to discard when yanking." |
1929 :type '(choice (const :tag "All" t) (repeat symbol)) | 1929 :type '(choice (const :tag "All" t) (repeat symbol)) |
1930 :group 'editing | 1930 :group 'editing |
1931 :version "21.4") | 1931 :version "21.4") |
1932 | 1932 |
1933 (defvar yank-window-start nil) | |
1934 | |
1933 (defun yank-pop (arg) | 1935 (defun yank-pop (arg) |
1934 "Replace just-yanked stretch of killed text with a different stretch. | 1936 "Replace just-yanked stretch of killed text with a different stretch. |
1935 This command is allowed only immediately after a `yank' or a `yank-pop'. | 1937 This command is allowed only immediately after a `yank' or a `yank-pop'. |
1936 At such a time, the region contains a stretch of reinserted | 1938 At such a time, the region contains a stretch of reinserted |
1937 previously-killed text. `yank-pop' deletes that text and inserts in its | 1939 previously-killed text. `yank-pop' deletes that text and inserts in its |
1950 (let ((inhibit-read-only t) | 1952 (let ((inhibit-read-only t) |
1951 (before (< (point) (mark t)))) | 1953 (before (< (point) (mark t)))) |
1952 (delete-region (point) (mark t)) | 1954 (delete-region (point) (mark t)) |
1953 (set-marker (mark-marker) (point) (current-buffer)) | 1955 (set-marker (mark-marker) (point) (current-buffer)) |
1954 (insert-for-yank (current-kill arg)) | 1956 (insert-for-yank (current-kill arg)) |
1957 ;; Set the window start back where it was in the yank command, | |
1958 ;; if possible. | |
1959 (set-window-start (selected-window) yank-window-start t) | |
1955 (if before | 1960 (if before |
1956 ;; This is like exchange-point-and-mark, but doesn't activate the mark. | 1961 ;; This is like exchange-point-and-mark, but doesn't activate the mark. |
1957 ;; It is cleaner to avoid activation, even though the command | 1962 ;; It is cleaner to avoid activation, even though the command |
1958 ;; loop would deactivate the mark because we inserted text. | 1963 ;; loop would deactivate the mark because we inserted text. |
1959 (goto-char (prog1 (mark t) | 1964 (goto-char (prog1 (mark t) |
1967 With just \\[universal-argument] as argument, same but put point at beginning (and mark at end). | 1972 With just \\[universal-argument] as argument, same but put point at beginning (and mark at end). |
1968 With argument N, reinsert the Nth most recently killed stretch of killed | 1973 With argument N, reinsert the Nth most recently killed stretch of killed |
1969 text. | 1974 text. |
1970 See also the command \\[yank-pop]." | 1975 See also the command \\[yank-pop]." |
1971 (interactive "*P") | 1976 (interactive "*P") |
1977 (setq yank-window-start (window-start)) | |
1972 ;; If we don't get all the way thru, make last-command indicate that | 1978 ;; If we don't get all the way thru, make last-command indicate that |
1973 ;; for the following command. | 1979 ;; for the following command. |
1974 (setq this-command t) | 1980 (setq this-command t) |
1975 (push-mark (point)) | 1981 (push-mark (point)) |
1976 (insert-for-yank (current-kill (cond | 1982 (insert-for-yank (current-kill (cond |