aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2010-05-10 16:37:59 +0200
committerJuanma Barranquero2010-05-10 16:37:59 +0200
commitc5eb971bec053d053e41fa5463fe3b925b314633 (patch)
tree218a437de67c79ae91ddfece3682e0268535c3de
parent1fdf5102be10625fece506324e57af3b735f67f0 (diff)
downloademacs-c5eb971bec053d053e41fa5463fe3b925b314633.tar.gz
emacs-c5eb971bec053d053e41fa5463fe3b925b314633.zip
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
* emulation/cua-base.el (cua--filter-buffer-noprops): New function. (cua-repeat-replace-region): * emulation/cua-rect.el (cua--extract-rectangle, cua-incr-rectangle): * emulation/cua-gmrk.el (cua-copy-region-to-global-mark) (cua-cut-region-to-global-mark): Use it.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/emulation/cua-base.el9
-rw-r--r--lisp/emulation/cua-gmrk.el6
-rw-r--r--lisp/emulation/cua-rect.el8
4 files changed, 20 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 871b51470f8..5176590dc8e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12010-05-10 Juanma Barranquero <lekktu@gmail.com>
2
3 Fix use of `filter-buffer-substring' (rework previous change).
4 * emulation/cua-base.el (cua--filter-buffer-noprops): New function.
5 (cua-repeat-replace-region):
6 * emulation/cua-rect.el (cua--extract-rectangle, cua-incr-rectangle):
7 * emulation/cua-gmrk.el (cua-copy-region-to-global-mark)
8 (cua-cut-region-to-global-mark): Use it.
9
12010-05-09 Michael R. Mauger <mmaug@yahoo.com> 102010-05-09 Michael R. Mauger <mmaug@yahoo.com>
2 11
3 * progmodes/sql.el: Version 2.1 12 * progmodes/sql.el: Version 2.1
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index d8b36adf730..3e434b36213 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -780,6 +780,10 @@ Repeating prefix key when region is active works as a single prefix key."
780 (setq mark-active nil) 780 (setq mark-active nil)
781 (run-hooks 'deactivate-mark-hook))) 781 (run-hooks 'deactivate-mark-hook)))
782 782
783(defun cua--filter-buffer-noprops (start end)
784 (let ((str (filter-buffer-substring start end)))
785 (set-text-properties 0 (length str) nil str)
786 str))
783 787
784;; The current register prefix 788;; The current register prefix
785(defvar cua--register nil) 789(defvar cua--register nil)
@@ -1039,10 +1043,7 @@ of text."
1039 (setq s (car u)) 1043 (setq s (car u))
1040 (setq s (car u) e (cdr u))))))) 1044 (setq s (car u) e (cdr u)))))))
1041 (cond ((and s e (<= s e) (= s (mark t))) 1045 (cond ((and s e (<= s e) (= s (mark t)))
1042 (setq cua--repeat-replace-text 1046 (setq cua--repeat-replace-text (cua--filter-buffer-noprops s e)))
1043 (filter-buffer-substring s e))
1044 (set-text-properties 0 (length cua--repeat-replace-text)
1045 nil cua--repeat-replace-text))
1046 ((and (null s) (eq u elt)) ;; nothing inserted 1047 ((and (null s) (eq u elt)) ;; nothing inserted
1047 (setq cua--repeat-replace-text 1048 (setq cua--repeat-replace-text
1048 "")) 1049 ""))
diff --git a/lisp/emulation/cua-gmrk.el b/lisp/emulation/cua-gmrk.el
index 6c69800d73c..b67d09c04cf 100644
--- a/lisp/emulation/cua-gmrk.el
+++ b/lisp/emulation/cua-gmrk.el
@@ -137,9 +137,8 @@ With prefix argument, don't jump to global mark when cancelling it."
137 (let ((src-buf (current-buffer))) 137 (let ((src-buf (current-buffer)))
138 (save-excursion 138 (save-excursion
139 (if (equal (marker-buffer cua--global-mark-marker) src-buf) 139 (if (equal (marker-buffer cua--global-mark-marker) src-buf)
140 (let ((text (filter-buffer-substring start end))) 140 (let ((text (cua--filter-buffer-noprops start end)))
141 (goto-char (marker-position cua--global-mark-marker)) 141 (goto-char (marker-position cua--global-mark-marker))
142 (set-text-properties 0 (length text) text)
143 (insert text)) 142 (insert text))
144 (set-buffer (marker-buffer cua--global-mark-marker)) 143 (set-buffer (marker-buffer cua--global-mark-marker))
145 (goto-char (marker-position cua--global-mark-marker)) 144 (goto-char (marker-position cua--global-mark-marker))
@@ -162,11 +161,10 @@ With prefix argument, don't jump to global mark when cancelling it."
162 (if (and (< start (marker-position cua--global-mark-marker)) 161 (if (and (< start (marker-position cua--global-mark-marker))
163 (< (marker-position cua--global-mark-marker) end)) 162 (< (marker-position cua--global-mark-marker) end))
164 (message "Can't move region into itself") 163 (message "Can't move region into itself")
165 (let ((text (filter-buffer-substring start end)) 164 (let ((text (cua--filter-buffer-noprops start end))
166 (p1 (copy-marker start)) 165 (p1 (copy-marker start))
167 (p2 (copy-marker end))) 166 (p2 (copy-marker end)))
168 (goto-char (marker-position cua--global-mark-marker)) 167 (goto-char (marker-position cua--global-mark-marker))
169 (set-text-properties 0 (length text) text)
170 (insert text) 168 (insert text)
171 (cua--activate-global-mark) 169 (cua--activate-global-mark)
172 (delete-region (marker-position p1) (marker-position p2)) 170 (delete-region (marker-position p1) (marker-position p2))
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 4ac8ce58b3e..2b41f6435ee 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -625,7 +625,7 @@ If command is repeated at same position, delete the rectangle."
625 (if (not (cua--rectangle-virtual-edges)) 625 (if (not (cua--rectangle-virtual-edges))
626 (cua--rectangle-operation nil nil nil nil nil ; do not tabify 626 (cua--rectangle-operation nil nil nil nil nil ; do not tabify
627 '(lambda (s e l r) 627 '(lambda (s e l r)
628 (setq rect (cons (filter-buffer-substring s e nil t) rect)))) 628 (setq rect (cons (cua--filter-buffer-noprops s e) rect))))
629 (cua--rectangle-operation nil 1 nil nil nil ; do not tabify 629 (cua--rectangle-operation nil 1 nil nil nil ; do not tabify
630 '(lambda (s e l r v) 630 '(lambda (s e l r v)
631 (let ((copy t) (bs 0) (as 0) row) 631 (let ((copy t) (bs 0) (as 0) row)
@@ -643,7 +643,7 @@ If command is repeated at same position, delete the rectangle."
643 (setq as (- r (max (current-column) l)) 643 (setq as (- r (max (current-column) l))
644 e (point))) 644 e (point)))
645 (setq row (if (and copy (> e s)) 645 (setq row (if (and copy (> e s))
646 (filter-buffer-substring s e nil t) 646 (cua--filter-buffer-noprops s e)
647 "")) 647 ""))
648 (when (> bs 0) 648 (when (> bs 0)
649 (setq row (concat (make-string bs ?\s) row))) 649 (setq row (concat (make-string bs ?\s) row)))
@@ -1124,12 +1124,12 @@ The length of STRING need not be the same as the rectangle width."
1124 '(lambda (s e l r) 1124 '(lambda (s e l r)
1125 (cond 1125 (cond
1126 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t) 1126 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t)
1127 (let* ((txt (filter-buffer-substring (match-beginning 1) (match-end 1) nil t)) 1127 (let* ((txt (cua--filter-buffer-noprops (match-beginning 1) (match-end 1)))
1128 (n (string-to-number txt 16)) 1128 (n (string-to-number txt 16))
1129 (fmt (format "0x%%0%dx" (length txt)))) 1129 (fmt (format "0x%%0%dx" (length txt))))
1130 (replace-match (format fmt (+ n increment))))) 1130 (replace-match (format fmt (+ n increment)))))
1131 ((re-search-forward "\\( *-?[0-9]+\\)" e t) 1131 ((re-search-forward "\\( *-?[0-9]+\\)" e t)
1132 (let* ((txt (filter-buffer-substring (match-beginning 1) (match-end 1) nil t)) 1132 (let* ((txt (cua--filter-buffer-noprops (match-beginning 1) (match-end 1)))
1133 (prefix (if (= (aref txt 0) ?0) "0" "")) 1133 (prefix (if (= (aref txt 0) ?0) "0" ""))
1134 (n (string-to-number txt 10)) 1134 (n (string-to-number txt 10))
1135 (fmt (format "%%%s%dd" prefix (length txt)))) 1135 (fmt (format "%%%s%dd" prefix (length txt))))