Mercurial > emacs
comparison lisp/simple.el @ 2805:5efa58250e35
(push-mark): Don't activate the mark.
(set-mark-command): Explicitly do so here.
When popping, don't mind if mark is inactive.
(pop-mark): Deactivate mark. Don't mind if it's inactive.
(yank-pop): Don't mind if mark is inactive.
(keyboard-quit): Deactivate the mark.
(kill-ring-save): When bouncing cursor,
bounce the mark too, so highlighted area does not change.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 15 May 1993 20:55:02 +0000 |
parents | e0a9c4815584 |
children | c684bce3e977 |
comparison
equal
deleted
inserted
replaced
2804:6cbe25563857 | 2805:5efa58250e35 |
---|---|
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 (save-excursion |
1063 (let ((other-end (if (= (point) beg) end beg))) | 1063 (let ((other-end (if (= (point) beg) end beg))) |
1064 (if (pos-visible-in-window-p other-end (selected-window)) | 1064 (if (pos-visible-in-window-p other-end (selected-window)) |
1065 (progn | 1065 (let ((omark (mark t))) |
1066 (set-marker (mark-marker) (point) (current-buffer)) | |
1066 (goto-char other-end) | 1067 (goto-char other-end) |
1067 (sit-for 1)) | 1068 (sit-for 1)) |
1068 (let* ((killed-text (current-kill 0)) | 1069 (let* ((killed-text (current-kill 0)) |
1069 (message-len (min (length killed-text) 40))) | 1070 (message-len (min (length killed-text) 40))) |
1070 (if (= (point) beg) | 1071 (if (= (point) beg) |
1071 ;; Don't say "killed"; that is misleading. | 1072 ;; Don't say "killed"; that is misleading. |
1072 (message "Saved text until \"%s\"" | 1073 (message "Saved text until \"%s\"" |
1098 comes the newest one." | 1099 comes the newest one." |
1099 (interactive "*p") | 1100 (interactive "*p") |
1100 (if (not (eq last-command 'yank)) | 1101 (if (not (eq last-command 'yank)) |
1101 (error "Previous command was not a yank")) | 1102 (error "Previous command was not a yank")) |
1102 (setq this-command 'yank) | 1103 (setq this-command 'yank) |
1103 (let ((before (< (point) (mark)))) | 1104 (let ((before (< (point) (mark t)))) |
1104 (delete-region (point) (mark)) | 1105 (delete-region (point) (mark t)) |
1105 (set-mark (point)) | 1106 (set-mark (point)) |
1106 (insert (current-kill arg)) | 1107 (insert (current-kill arg)) |
1107 (if before (exchange-point-and-mark))) | 1108 (if before (exchange-point-and-mark))) |
1108 nil) | 1109 nil) |
1109 | 1110 |
1240 | 1241 |
1241 Novice Emacs Lisp programmers often try to use the mark for the wrong | 1242 Novice Emacs Lisp programmers often try to use the mark for the wrong |
1242 purposes. See the documentation of `set-mark' for more information." | 1243 purposes. See the documentation of `set-mark' for more information." |
1243 (interactive "P") | 1244 (interactive "P") |
1244 (if (null arg) | 1245 (if (null arg) |
1245 (push-mark) | 1246 (progn |
1247 (push-mark) | |
1248 (set-mark (mark t))) | |
1246 (if (null (mark t)) | 1249 (if (null (mark t)) |
1247 (error "No mark set in this buffer") | 1250 (error "No mark set in this buffer") |
1248 (goto-char (mark)) | 1251 (goto-char (mark t)) |
1249 (pop-mark)))) | 1252 (pop-mark)))) |
1250 | 1253 |
1251 (defun push-mark (&optional location nomsg) | 1254 (defun push-mark (&optional location nomsg) |
1252 "Set mark at LOCATION (point, by default) and push old mark on mark ring. | 1255 "Set mark at LOCATION (point, by default) and push old mark on mark ring. |
1253 Displays \"Mark set\" unless the optional second arg NOMSG is non-nil. | 1256 Displays \"Mark set\" unless the optional second arg NOMSG is non-nil. |
1254 | 1257 |
1255 Novice Emacs Lisp programmers often try to use the mark for the wrong | 1258 Novice Emacs Lisp programmers often try to use the mark for the wrong |
1256 purposes. See the documentation of `set-mark' for more information." | 1259 purposes. See the documentation of `set-mark' for more information. |
1260 | |
1261 In Transient Mark mode, this does not activate the mark." | |
1257 (if (null (mark t)) | 1262 (if (null (mark t)) |
1258 nil | 1263 nil |
1259 (setq mark-ring (cons (copy-marker (mark-marker)) mark-ring)) | 1264 (setq mark-ring (cons (copy-marker (mark-marker)) mark-ring)) |
1260 (if (> (length mark-ring) mark-ring-max) | 1265 (if (> (length mark-ring) mark-ring-max) |
1261 (progn | 1266 (progn |
1262 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil) | 1267 (move-marker (car (nthcdr mark-ring-max mark-ring)) nil) |
1263 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil)))) | 1268 (setcdr (nthcdr (1- mark-ring-max) mark-ring) nil)))) |
1264 (set-mark (or location (point))) | 1269 (set-marker (mark-marker) (or location (point)) (current-buffer)) |
1265 (or nomsg executing-macro (> (minibuffer-depth) 0) | 1270 (or nomsg executing-macro (> (minibuffer-depth) 0) |
1266 (message "Mark set")) | 1271 (message "Mark set")) |
1267 nil) | 1272 nil) |
1268 | 1273 |
1269 (defun pop-mark () | 1274 (defun pop-mark () |
1270 "Pop off mark ring into the buffer's actual mark. | 1275 "Pop off mark ring into the buffer's actual mark. |
1271 Does not set point. Does nothing if mark ring is empty." | 1276 Does not set point. Does nothing if mark ring is empty." |
1272 (if mark-ring | 1277 (if mark-ring |
1273 (progn | 1278 (progn |
1274 (setq mark-ring (nconc mark-ring (list (copy-marker (mark-marker))))) | 1279 (setq mark-ring (nconc mark-ring (list (copy-marker (mark-marker))))) |
1275 (set-mark (+ 0 (car mark-ring))) | 1280 (set-marker (mark-marker) (+ 0 (car mark-ring)) (current-buffer)) |
1281 (if transient-mark-mode | |
1282 (setq mark-active nil)) | |
1276 (move-marker (car mark-ring) nil) | 1283 (move-marker (car mark-ring) nil) |
1277 (if (null (mark)) (ding)) | 1284 (if (null (mark t)) (ding)) |
1278 (setq mark-ring (cdr mark-ring))))) | 1285 (setq mark-ring (cdr mark-ring))))) |
1279 | 1286 |
1280 (define-function 'exchange-dot-and-mark 'exchange-point-and-mark) | 1287 (define-function 'exchange-dot-and-mark 'exchange-point-and-mark) |
1281 (defun exchange-point-and-mark () | 1288 (defun exchange-point-and-mark () |
1282 "Put the mark where point is now, and point where the mark is now. | 1289 "Put the mark where point is now, and point where the mark is now. |
2063 (message "Unmatched parenthesis")))))))) | 2070 (message "Unmatched parenthesis")))))))) |
2064 | 2071 |
2065 ;Turned off because it makes dbx bomb out. | 2072 ;Turned off because it makes dbx bomb out. |
2066 (setq blink-paren-function 'blink-matching-open) | 2073 (setq blink-paren-function 'blink-matching-open) |
2067 | 2074 |
2068 ; this is just something for the luser to see in a keymap -- this is not | 2075 ;; This executes C-g typed while Emacs is waiting for a command. |
2069 ; how quitting works normally! | 2076 ;; Quitting out of a program does not go through here; |
2077 ;; that happens in the QUIT macro at the C code level. | |
2070 (defun keyboard-quit () | 2078 (defun keyboard-quit () |
2071 "Signal a quit condition. | 2079 "Signal a quit condition. |
2072 During execution of Lisp code, this character causes a quit directly. | 2080 During execution of Lisp code, this character causes a quit directly. |
2073 At top-level, as an editor command, this simply beeps." | 2081 At top-level, as an editor command, this simply beeps." |
2074 (interactive) | 2082 (interactive) |
2083 (if transient-mark-mode | |
2084 (setq mark-active nil)) | |
2075 (signal 'quit nil)) | 2085 (signal 'quit nil)) |
2076 | 2086 |
2077 (define-key global-map "\C-g" 'keyboard-quit) | 2087 (define-key global-map "\C-g" 'keyboard-quit) |
2078 | 2088 |
2079 (defun set-variable (var val) | 2089 (defun set-variable (var val) |