comparison lisp/simple.el @ 2850:f5f7e7295ec2

(keyboard-quit): Run deactivate-mark-hook. (kill-ring-save): If quit happens while cursor is bounced,
author Richard M. Stallman <rms@gnu.org>
date Mon, 17 May 1993 21:52:21 +0000
parents 086fda6b2041
children 653e14f61220
comparison
equal deleted inserted replaced
2849:29d41032d9fd 2850:f5f7e7295ec2
1057 If `interprogram-cut-function' is non-nil, also save the text for a window 1057 If `interprogram-cut-function' is non-nil, also save the text for a window
1058 system cut and paste." 1058 system cut and paste."
1059 (interactive "r") 1059 (interactive "r")
1060 (copy-region-as-kill beg end) 1060 (copy-region-as-kill beg end)
1061 (if (interactive-p) 1061 (if (interactive-p)
1062 (save-excursion 1062 (let ((other-end (if (= (point) beg) end beg))
1063 (let ((other-end (if (= (point) beg) end beg))) 1063 (opoint (point))
1064 (if (pos-visible-in-window-p other-end (selected-window)) 1064 ;; Inhibit quitting so we can make a quit here
1065 (let ((omark (mark t))) 1065 ;; look like a C-g typed as a command.
1066 (set-marker (mark-marker) (point) (current-buffer)) 1066 (inhibit-quit t))
1067 (goto-char other-end) 1067 (if (pos-visible-in-window-p other-end (selected-window))
1068 (sit-for 1)) 1068 (progn
1069 (let* ((killed-text (current-kill 0)) 1069 ;; Swap point and mark.
1070 (message-len (min (length killed-text) 40))) 1070 (set-marker (mark-marker) (point) (current-buffer))
1071 (if (= (point) beg) 1071 (goto-char other-end)
1072 ;; Don't say "killed"; that is misleading. 1072 (sit-for 1)
1073 (message "Saved text until \"%s\"" 1073 ;; Swap back.
1074 (substring killed-text (- message-len))) 1074 (set-marker (mark-marker) other-end (current-buffer))
1075 (message "Saved text from \"%s\"" 1075 (goto-char opoint)
1076 (substring killed-text 0 message-len))))))))) 1076 ;; If user quit, deactivate the mark
1077 ;; as C-g would as a command.
1078 (and quit-flag transient-mark-mode mark-active
1079 (progn
1080 (message "foo")
1081 (setq mark-active nil)
1082 (run-hooks 'deactivate-mark-hook))))
1083 (let* ((killed-text (current-kill 0))
1084 (message-len (min (length killed-text) 40)))
1085 (if (= (point) beg)
1086 ;; Don't say "killed"; that is misleading.
1087 (message "Saved text until \"%s\""
1088 (substring killed-text (- message-len)))
1089 (message "Saved text from \"%s\""
1090 (substring killed-text 0 message-len))))))))
1077 1091
1078 (defun append-next-kill () 1092 (defun append-next-kill ()
1079 "Cause following command, if it kills, to append to previous kill." 1093 "Cause following command, if it kills, to append to previous kill."
1080 (interactive) 1094 (interactive)
1081 (if (interactive-p) 1095 (if (interactive-p)
2090 (defun keyboard-quit () 2104 (defun keyboard-quit ()
2091 "Signal a quit condition. 2105 "Signal a quit condition.
2092 During execution of Lisp code, this character causes a quit directly. 2106 During execution of Lisp code, this character causes a quit directly.
2093 At top-level, as an editor command, this simply beeps." 2107 At top-level, as an editor command, this simply beeps."
2094 (interactive) 2108 (interactive)
2095 (if transient-mark-mode 2109 (and transient-mark-mode mark-active
2096 (setq mark-active nil)) 2110 (progn
2111 (setq mark-active nil)
2112 (run-hooks 'deactivate-mark-hook)))
2097 (signal 'quit nil)) 2113 (signal 'quit nil))
2098 2114
2099 (define-key global-map "\C-g" 'keyboard-quit) 2115 (define-key global-map "\C-g" 'keyboard-quit)
2100 2116
2101 (defun set-variable (var val) 2117 (defun set-variable (var val)