comparison lisp/emulation/cua-rect.el @ 69901:a1cf3efe0a2c

(cua--extract-rectangle) (cua-incr-rectangle, cua--rectangle-aux-replace): Use filter-buffer-substring.
author Kim F. Storm <storm@cua.dk>
date Sun, 09 Apr 2006 23:04:22 +0000
parents 5f7de9821aeb
children 4a6411420a60 c156f6a9e7b5
comparison
equal deleted inserted replaced
69900:2bf5f807797c 69901:a1cf3efe0a2c
629 (defun cua--extract-rectangle () 629 (defun cua--extract-rectangle ()
630 (let (rect) 630 (let (rect)
631 (if (not (cua--rectangle-virtual-edges)) 631 (if (not (cua--rectangle-virtual-edges))
632 (cua--rectangle-operation nil nil nil nil nil ; do not tabify 632 (cua--rectangle-operation nil nil nil nil nil ; do not tabify
633 '(lambda (s e l r) 633 '(lambda (s e l r)
634 (setq rect (cons (buffer-substring-no-properties s e) rect)))) 634 (setq rect (cons (filter-buffer-substring s e nil t) rect))))
635 (cua--rectangle-operation nil 1 nil nil nil ; do not tabify 635 (cua--rectangle-operation nil 1 nil nil nil ; do not tabify
636 '(lambda (s e l r v) 636 '(lambda (s e l r v)
637 (let ((copy t) (bs 0) (as 0) row) 637 (let ((copy t) (bs 0) (as 0) row)
638 (if (= s e) (setq e (1+ e))) 638 (if (= s e) (setq e (1+ e)))
639 (goto-char s) 639 (goto-char s)
647 (move-to-column r) 647 (move-to-column r)
648 (skip-chars-backward "\s\t" s) 648 (skip-chars-backward "\s\t" s)
649 (setq as (- r (max (current-column) l)) 649 (setq as (- r (max (current-column) l))
650 e (point))) 650 e (point)))
651 (setq row (if (and copy (> e s)) 651 (setq row (if (and copy (> e s))
652 (buffer-substring-no-properties s e) 652 (filter-buffer-substring s e nil t)
653 "")) 653 ""))
654 (when (> bs 0) 654 (when (> bs 0)
655 (setq row (concat (make-string bs ?\s) row))) 655 (setq row (concat (make-string bs ?\s) row)))
656 (when (> as 0) 656 (when (> as 0)
657 (setq row (concat row (make-string as ?\s)))) 657 (setq row (concat row (make-string as ?\s))))
1125 (interactive "p") 1125 (interactive "p")
1126 (cua--rectangle-operation 'keep nil t 1 nil 1126 (cua--rectangle-operation 'keep nil t 1 nil
1127 '(lambda (s e l r) 1127 '(lambda (s e l r)
1128 (cond 1128 (cond
1129 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t) 1129 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t)
1130 (let* ((txt (buffer-substring-no-properties (match-beginning 1) (match-end 1))) 1130 (let* ((txt (filter-buffer-substring (match-beginning 1) (match-end 1) nil t))
1131 (n (string-to-number txt 16)) 1131 (n (string-to-number txt 16))
1132 (fmt (format "0x%%0%dx" (length txt)))) 1132 (fmt (format "0x%%0%dx" (length txt))))
1133 (replace-match (format fmt (+ n increment))))) 1133 (replace-match (format fmt (+ n increment)))))
1134 ((re-search-forward "\\( *-?[0-9]+\\)" e t) 1134 ((re-search-forward "\\( *-?[0-9]+\\)" e t)
1135 (let* ((txt (buffer-substring-no-properties (match-beginning 1) (match-end 1))) 1135 (let* ((txt (filter-buffer-substring (match-beginning 1) (match-end 1) nil t))
1136 (prefix (if (= (aref txt 0) ?0) "0" "")) 1136 (prefix (if (= (aref txt 0) ?0) "0" ""))
1137 (n (string-to-number txt 10)) 1137 (n (string-to-number txt 10))
1138 (fmt (format "%%%s%dd" prefix (length txt)))) 1138 (fmt (format "%%%s%dd" prefix (length txt))))
1139 (replace-match (format fmt (+ n increment))))) 1139 (replace-match (format fmt (+ n increment)))))
1140 (t nil))))) 1140 (t nil)))))
1211 (let ((fill-column w)) 1211 (let ((fill-column w))
1212 (funcall format-fct (point-min) (point-max)))) 1212 (funcall format-fct (point-min) (point-max))))
1213 (when replace 1213 (when replace
1214 (goto-char (point-min)) 1214 (goto-char (point-min))
1215 (while (not (eobp)) 1215 (while (not (eobp))
1216 (setq z (cons (buffer-substring (point) (line-end-position)) z)) 1216 (setq z (cons (filter-buffer-substring (point) (line-end-position)) z))
1217 (forward-line 1)))) 1217 (forward-line 1))))
1218 (if (not cua--debug) 1218 (if (not cua--debug)
1219 (kill-buffer auxbuf)) 1219 (kill-buffer auxbuf))
1220 (when replace 1220 (when replace
1221 (setq z (reverse z)) 1221 (setq z (reverse z))