Mercurial > emacs
annotate lisp/emulation/cua-gmrk.el @ 111502:df6573cbdd34
* lisp/emacs-lisp/pcase.el (pcase-let*, pcase-let): Add debug and
indentation specs.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 11 Nov 2010 20:35:06 -0500 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
rev | line source |
---|---|
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1 ;;; cua-gmrk.el --- CUA unified global mark support |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
5 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
6 ;; Author: Kim F. Storm <storm@cua.dk> |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
7 ;; Keywords: keyboard emulations convenience cua mark |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
108467
diff
changeset
|
8 ;; Package: cua-base |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
9 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
11 |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
16 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
21 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
24 |
45078 | 25 ;;; Commentary: |
26 | |
27 ;;; Code: | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
28 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
29 (eval-when-compile |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
30 (require 'cua-base) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
31 (require 'cua-rect) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
32 ) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
33 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45503
diff
changeset
|
34 ;;; Global Marker |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
35 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
36 ;; Non-nil when global marker is active. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
37 (defvar cua--global-mark-active nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
38 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
39 ;; Global mark position marker. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
40 (defvar cua--global-mark-marker nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
41 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
42 ;; Overlay for global mark position. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
43 (defvar cua--global-mark-overlay nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
44 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
45 ;; Initialize global mark things once... |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
46 (defvar cua--global-mark-initialized nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
47 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
48 ;; Saved configured blink-cursor-interval |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
49 (defvar cua--orig-blink-cursor-interval nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
50 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
51 (defun cua--deactivate-global-mark (&optional msg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
52 (when cua--global-mark-overlay |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
53 (delete-overlay cua--global-mark-overlay) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
54 (setq cua--global-mark-overlay nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
55 (if (markerp cua--global-mark-marker) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
56 (move-marker cua--global-mark-marker nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
57 (if cua--orig-blink-cursor-interval |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
58 (setq blink-cursor-interval cua--orig-blink-cursor-interval |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
59 cua--orig-blink-cursor-interval nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
60 (setq cua--global-mark-active nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
61 (if msg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
62 (message "Global Mark Cleared"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
63 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
64 (defun cua--activate-global-mark (&optional msg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
65 (if (not (markerp cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
66 (setq cua--global-mark-marker (make-marker))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
67 (when (eobp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
68 (insert " ") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
69 (backward-char 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
70 (move-marker cua--global-mark-marker (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
71 (if (overlayp cua--global-mark-overlay) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
72 (move-overlay cua--global-mark-overlay (point) (1+ (point))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45503
diff
changeset
|
73 (setq cua--global-mark-overlay |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
74 (make-overlay (point) (1+ (point)))) |
63073
f1bf3660220e
* emulation/cua-base.el (cua-rectangle, cua-rectangle-noselect)
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
75 (overlay-put cua--global-mark-overlay 'face 'cua-global-mark)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
76 (if (and cua-global-mark-blink-cursor-interval |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
77 (not cua--orig-blink-cursor-interval)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45503
diff
changeset
|
78 (setq cua--orig-blink-cursor-interval blink-cursor-interval |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
79 blink-cursor-interval cua-global-mark-blink-cursor-interval)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
80 (setq cua--global-mark-active t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
81 (if msg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
82 (message "Global Mark Set"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
83 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
84 (defun cua--global-mark-active () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
85 (if cua--global-mark-active |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
86 (or (and (markerp cua--global-mark-marker) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
87 (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
88 (and (cua--deactivate-global-mark nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
89 nil)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
90 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
91 (defun cua-toggle-global-mark (stay) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
92 "Set or cancel the global marker. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
93 When the global marker is set, CUA cut and copy commands will automatically |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
94 insert the deleted or copied text before the global marker, even when the |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
95 global marker is in another buffer. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
96 If the global marker isn't set, set the global marker at point in the current |
63870
66f83ad1a264
(cua-toggle-global-mark, cua-cut-region-to-global-mark,
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
97 buffer. Otherwise jump to the global marker position and cancel it. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
98 With prefix argument, don't jump to global mark when cancelling it." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
99 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
100 (unless cua--global-mark-initialized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
101 (cua--init-global-mark)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
102 (if (not (cua--global-mark-active)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
103 (if (not buffer-read-only) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
104 (cua--activate-global-mark t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
105 (ding) |
63870
66f83ad1a264
(cua-toggle-global-mark, cua-cut-region-to-global-mark,
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
106 (message "Cannot set global mark in read-only buffer")) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
107 (when (not stay) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
108 (pop-to-buffer (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
109 (goto-char cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
110 (cua--deactivate-global-mark t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
111 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
112 (defun cua--insert-at-global-mark (str &optional msg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
113 ;; Insert string at global marker and move marker |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
114 (with-current-buffer (marker-buffer cua--global-mark-marker) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
115 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
116 (insert-for-yank str) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
117 (cua--activate-global-mark)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
118 (if msg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
119 (message "%s %d to global mark in %s:%d" msg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
120 (length str) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
121 (buffer-name (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
122 (marker-position cua--global-mark-marker)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
123 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
124 (defun cua--delete-at-global-mark (arg &optional msg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
125 ;; Delete chars at global marker |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
126 (with-current-buffer (marker-buffer cua--global-mark-marker) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
127 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
128 (delete-char arg)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
129 (if msg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
130 (message "%s %d chars at global mark in %s:%d" msg arg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
131 (buffer-name (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
132 (marker-position cua--global-mark-marker)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
133 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
134 (defun cua-copy-region-to-global-mark (start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
135 "Copy region to global mark buffer/position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
136 (interactive "r") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
137 (if (cua--global-mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
138 (let ((src-buf (current-buffer))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
139 (save-excursion |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
140 (if (equal (marker-buffer cua--global-mark-marker) src-buf) |
108467
114b70461f96
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
Juanma Barranquero <lekktu@gmail.com>
parents:
108276
diff
changeset
|
141 (let ((text (cua--filter-buffer-noprops start end))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
142 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
143 (insert text)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
144 (set-buffer (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
145 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
146 (insert-buffer-substring-as-yank src-buf start end)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
147 (cua--activate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
148 (message "Copied %d to global mark in %s:%d" |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
149 (abs (- end start)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
150 (buffer-name (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
151 (marker-position cua--global-mark-marker)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
152 (cua--deactivate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
153 (message "No Global Mark"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
154 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
155 (defun cua-cut-region-to-global-mark (start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
156 "Move region to global buffer/position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
157 (interactive "r") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
158 (if (cua--global-mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
159 (let ((src-buf (current-buffer))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
160 (save-excursion |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
161 (if (equal (marker-buffer cua--global-mark-marker) src-buf) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
162 (if (and (< start (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
163 (< (marker-position cua--global-mark-marker) end)) |
63870
66f83ad1a264
(cua-toggle-global-mark, cua-cut-region-to-global-mark,
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
164 (message "Can't move region into itself") |
108467
114b70461f96
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
Juanma Barranquero <lekktu@gmail.com>
parents:
108276
diff
changeset
|
165 (let ((text (cua--filter-buffer-noprops start end)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
166 (p1 (copy-marker start)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
167 (p2 (copy-marker end))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
168 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
169 (insert text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
170 (cua--activate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
171 (delete-region (marker-position p1) (marker-position p2)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
172 (move-marker p1 nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
173 (move-marker p2 nil))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
174 (set-buffer (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
175 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
176 (insert-buffer-substring src-buf start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
177 (message "Moved %d to global mark in %s:%d" |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
178 (abs (- end start)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
179 (buffer-name (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
180 (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
181 (cua--activate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
182 (set-buffer src-buf) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
183 (delete-region start end)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
184 (cua--deactivate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
185 (message "No Global Mark"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
186 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
187 (defun cua--copy-rectangle-to-global-mark (as-text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
188 ;; Copy rectangle to global mark buffer/position. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
189 (if (cua--global-mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
190 (let ((src-buf (current-buffer)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
191 (text (cua--extract-rectangle))) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
192 (with-current-buffer (marker-buffer cua--global-mark-marker) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
193 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
194 (if as-text |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
195 (while text |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
196 (insert-for-yank (car text)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
197 (if (setq text (cdr text)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
198 (insert "\n"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
199 (cua--insert-rectangle text 'auto)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
200 (cua--activate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
201 (message "Copied rectangle to global mark in %s:%d" |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
202 (buffer-name (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
203 (marker-position cua--global-mark-marker)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
204 (cua--deactivate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
205 (message "No Global Mark"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
206 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
207 (defun cua--cut-rectangle-to-global-mark (as-text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
208 ;; Move rectangle to global buffer/position. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
209 (if (cua--global-mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
210 (let ((src-buf (current-buffer))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
211 (save-excursion |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
212 (if (equal (marker-buffer cua--global-mark-marker) src-buf) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
213 (let ((olist (overlays-at (marker-position cua--global-mark-marker))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
214 in-rect) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
215 (while olist |
63073
f1bf3660220e
* emulation/cua-base.el (cua-rectangle, cua-rectangle-noselect)
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
216 (if (eq (overlay-get (car olist) 'face) 'cua-rectangle) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
217 (setq in-rect t olist nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
218 (setq olist (cdr olist)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
219 (if in-rect |
63870
66f83ad1a264
(cua-toggle-global-mark, cua-cut-region-to-global-mark,
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
220 (message "Can't move rectangle into itself") |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
221 (let ((text (cua--extract-rectangle))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
222 (cua--delete-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
223 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
224 (if as-text |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
225 (while text |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
226 (insert-for-yank (car text)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
227 (if (setq text (cdr text)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
228 (insert "\n"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
229 (cua--insert-rectangle text 'auto)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
230 (cua--activate-global-mark)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
231 (let ((text (cua--extract-rectangle))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
232 (cua--delete-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
233 (set-buffer (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
234 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
235 (cua--insert-rectangle text 'auto)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
236 (message "Moved rectangle to global mark in %s:%d" |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
237 (buffer-name (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
238 (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
239 (cua--activate-global-mark)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
240 (cua--deactivate-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
241 (message "No Global Mark"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
242 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
243 (defun cua-copy-to-global-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
244 "Copy active region/rectangle to global mark buffer/position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
245 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
246 (setq cua--last-killed-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
247 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
248 (cua--copy-rectangle-to-global-mark nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
249 (let ((start (mark)) (end (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
250 (or (<= start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
251 (setq start (prog1 end (setq end start)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
252 (cua-copy-region-to-global-mark start end)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
253 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
254 (defun cua-copy-next-to-global-mark (n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
255 "Copy the following N characters in buffer to global mark buffer/position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
256 (interactive "p") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
257 (setq cua--last-killed-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
258 (or (eobp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
259 (let ((p (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
260 (goto-char (+ p n)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
261 (cua-copy-region-to-global-mark p (point))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
262 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
263 (defun cua-cut-to-global-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
264 "Move active region/rectangle to global mark buffer/position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
265 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
266 (if buffer-read-only |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
267 (cua-copy-to-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
268 (setq cua--last-killed-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
269 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
270 (cua--cut-rectangle-to-global-mark nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
271 (let ((start (mark)) (end (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
272 (or (<= start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
273 (setq start (prog1 end (setq end start)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
274 (cua-cut-region-to-global-mark start end))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
275 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
276 (defun cua-cut-next-to-global-mark (n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
277 "Move the following N characters in buffer to global mark buffer/position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
278 (interactive "p") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
279 (setq cua--last-killed-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
280 (or (eobp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
281 (let ((p (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
282 (goto-char (+ p n)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
283 (cua-cut-region-to-global-mark p (point))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
284 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
285 (defun cua-delete-char-at-global-mark (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
286 "Delete character following the global mark position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
287 (interactive "p") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
288 (cua--delete-at-global-mark arg "Deleted")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
289 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
290 (defun cua-delete-backward-char-at-global-mark (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
291 "Delete character before the global mark position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
292 (interactive "p") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
293 (cua--delete-at-global-mark (- arg) "Deleted backward")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
294 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
295 (defun cua-insert-char-at-global-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
296 "Insert the character you type at the global mark position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
297 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
298 (cua--insert-at-global-mark (char-to-string (aref (this-single-command-keys) 0)) "Inserted")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
299 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
300 (defun cua-insert-newline-at-global-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
301 "Insert a newline at the global mark position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
302 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
303 (cua--insert-at-global-mark "\n")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
304 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
305 (defun cua-indent-to-global-mark-column () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
306 "Indent current line or rectangle to global mark column." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
307 (interactive "*") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
308 (if (cua--global-mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
309 (let (col) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
310 (with-current-buffer (marker-buffer cua--global-mark-marker) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
311 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
312 (setq col (current-column))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
313 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
314 (cua--indent-rectangle nil col t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
315 (indent-to col)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
316 (if (eq (current-buffer) (marker-buffer cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
317 (save-excursion |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
318 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
319 (move-to-column col) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
320 (move-marker cua--global-mark-marker (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
321 (move-overlay cua--global-mark-overlay (point) (1+ (point)))))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45503
diff
changeset
|
322 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
323 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
324 (defun cua-cancel-global-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
325 "Cancel the global mark." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
326 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
327 (if mark-active |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
328 (cua-cancel) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
329 (if (cua--global-mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
330 (cua--deactivate-global-mark t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
331 (cua--fallback)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
332 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
333 ;;; Post-command hook for global mark. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
334 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
335 (defun cua--global-mark-post-command () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
336 (when (and (cua--global-mark-active) ;; Updates cua--global-mark-active variable |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
337 cua-global-mark-keep-visible) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
338 ;; keep global mark position visible |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
339 (sit-for 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
340 (if (or (not (eq (current-buffer) (marker-buffer cua--global-mark-marker))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
341 (not (pos-visible-in-window-p (marker-position cua--global-mark-marker)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
342 (let ((w (selected-window)) (p (point)) h) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
45503
diff
changeset
|
343 ;; The following code is an attempt to keep the global mark visible in |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
344 ;; other window -- but it doesn't work. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
345 (switch-to-buffer-other-window (marker-buffer cua--global-mark-marker) t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
346 (goto-char (marker-position cua--global-mark-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
347 (if (not (pos-visible-in-window-p (marker-position cua--global-mark-marker))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
348 (recenter (if (> (setq h (- (window-height) 4)) 1) h '(4)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
349 (select-window w) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
350 (goto-char p))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
351 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
352 ;;; Initialization |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
353 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
354 (defun cua--init-global-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
355 (define-key cua--global-mark-keymap [remap copy-region-as-kill] 'cua-copy-to-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
356 (define-key cua--global-mark-keymap [remap kill-ring-save] 'cua-copy-to-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
357 (define-key cua--global-mark-keymap [remap kill-region] 'cua-cut-to-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
358 (define-key cua--global-mark-keymap [remap yank] 'cua-copy-next-to-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
359 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
360 (define-key cua--global-mark-keymap [remap keyboard-escape-quit] 'cua-cancel-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
361 (define-key cua--global-mark-keymap [remap keyboard-quit] 'cua-cancel-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
362 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
363 (define-key cua--global-mark-keymap [(control ?d)] 'cua-cut-next-to-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
364 (define-key cua--global-mark-keymap [remap delete-backward-char] 'cua-delete-backward-char-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
365 (define-key cua--global-mark-keymap [remap backward-delete-char] 'cua-delete-backward-char-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
366 (define-key cua--global-mark-keymap [remap backward-delete-char-untabify] 'cua-delete-backward-char-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
367 (define-key cua--global-mark-keymap [remap self-insert-command] 'cua-insert-char-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
368 (define-key cua--global-mark-keymap [remap self-insert-iso] 'cua-insert-char-at-global-mark) |
45503
b5885da440b5
(cua--init-global-mark): Install default
Kim F. Storm <storm@cua.dk>
parents:
45078
diff
changeset
|
369 |
b5885da440b5
(cua--init-global-mark): Install default
Kim F. Storm <storm@cua.dk>
parents:
45078
diff
changeset
|
370 ;; Catch self-inserting characters which are "stolen" by other modes |
b5885da440b5
(cua--init-global-mark): Install default
Kim F. Storm <storm@cua.dk>
parents:
45078
diff
changeset
|
371 (define-key cua--global-mark-keymap [t] |
b5885da440b5
(cua--init-global-mark): Install default
Kim F. Storm <storm@cua.dk>
parents:
45078
diff
changeset
|
372 '(menu-item "sic" cua-insert-char-at-global-mark :filter cua--self-insert-char-p)) |
b5885da440b5
(cua--init-global-mark): Install default
Kim F. Storm <storm@cua.dk>
parents:
45078
diff
changeset
|
373 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
374 (define-key cua--global-mark-keymap [remap newline] 'cua-insert-newline-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
375 (define-key cua--global-mark-keymap [remap newline-and-indent] 'cua-insert-newline-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
376 (define-key cua--global-mark-keymap "\r" 'cua-insert-newline-at-global-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
377 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
378 (define-key cua--global-mark-keymap "\t" 'cua-indent-to-global-mark-column) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
379 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
380 (setq cua--global-mark-initialized t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
381 |
87019
e460f7bcfb6d
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
78218
diff
changeset
|
382 (provide 'cua-gmrk) |
e460f7bcfb6d
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
78218
diff
changeset
|
383 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
384 ;; arch-tag: 553d8076-a91d-48ae-825d-6cb962a5f67f |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
385 ;;; cua-gmrk.el ends here |