comparison lisp/emulation/cua-rect.el @ 108467:114b70461f96

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.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 10 May 2010 16:37:59 +0200
parents de5ba6f3514c
children d835100c3e8b
comparison
equal deleted inserted replaced
108466:a30c85fa75e8 108467:114b70461f96
623 (defun cua--extract-rectangle () 623 (defun cua--extract-rectangle ()
624 (let (rect) 624 (let (rect)
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)
632 (if (= s e) (setq e (1+ e))) 632 (if (= s e) (setq e (1+ e)))
633 (goto-char s) 633 (goto-char s)
641 (move-to-column r) 641 (move-to-column r)
642 (skip-chars-backward "\s\t" s) 642 (skip-chars-backward "\s\t" s)
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)))
650 (when (> as 0) 650 (when (> as 0)
651 (setq row (concat row (make-string as ?\s)))) 651 (setq row (concat row (make-string as ?\s))))
1122 (interactive "p") 1122 (interactive "p")
1123 (cua--rectangle-operation 'keep nil t 1 nil 1123 (cua--rectangle-operation 'keep nil t 1 nil
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))))
1136 (replace-match (format fmt (+ n increment))))) 1136 (replace-match (format fmt (+ n increment)))))
1137 (t nil))))) 1137 (t nil)))))