]> code.delx.au - gnu-emacs/blobdiff - lisp/rect.el
Fix right and left key remapping issue (bug#12317)
[gnu-emacs] / lisp / rect.el
index 174e31f87d099a5942e0473bb2b2fb23c66d1649..574d96a8c102b9883a9a6700d382d7c28cc3b127 100644 (file)
@@ -1,6 +1,6 @@
 ;;; rect.el --- rectangle functions for GNU Emacs
 
-;; Copyright (C) 1985, 1999-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1999-2012 Free Software Foundation, Inc.
 
 ;; Maintainer: Didier Verna <didier@xemacs.org>
 ;; Keywords: internal
@@ -93,8 +93,9 @@ Point is at the end of the segment of this line within the rectangle."
   "Call FUNCTION for each line of rectangle with corners at START, END.
 FUNCTION is called with two arguments: the start and end columns of the
 rectangle, plus ARGS extra arguments.  Point is at the beginning of line when
-the function is called."
-  (let (startcol startpt endcol endpt)
+the function is called.
+The final point after the last operation will be returned."
+  (let (startcol startpt endcol endpt final-point)
     (save-excursion
       (goto-char start)
       (setq startcol (current-column))
@@ -112,8 +113,9 @@ the function is called."
       (goto-char startpt)
       (while (< (point) endpt)
        (apply function startcol endcol args)
+       (setq final-point (point))
        (forward-line 1)))
-    ))
+    final-point))
 
 (defun delete-rectangle-line (startcol endcol fill)
   (when (= (move-to-column startcol (if fill t 'coerce)) startcol)
@@ -281,7 +283,7 @@ no text on the right side of the rectangle."
                 (= (point) (point-at-eol)))
       (indent-to endcol))))
 
-(defun delete-whitespace-rectangle-line (startcol endcol fill)
+(defun delete-whitespace-rectangle-line (startcol _endcol fill)
   (when (= (move-to-column startcol (if fill t 'coerce)) startcol)
     (unless (= (point) (point-at-eol))
       (delete-region (point) (progn (skip-syntax-forward " ") (point))))))
@@ -323,7 +325,8 @@ Called from a program, takes three args; START, END and STRING."
                                (or (car string-rectangle-history) ""))
                        nil 'string-rectangle-history
                        (car string-rectangle-history)))))
-  (apply-on-rectangle 'string-rectangle-line start end string t))
+  (goto-char
+   (apply-on-rectangle 'string-rectangle-line start end string t)))
 
 ;;;###autoload
 (defalias 'replace-rectangle 'string-rectangle)
@@ -373,7 +376,7 @@ rectangle which were empty."
 ;; Line numbers for `rectangle-number-line-callback'.
 (defvar rectangle-number-line-counter)
 
-(defun rectangle-number-line-callback (start end format-string)
+(defun rectangle-number-line-callback (start _end format-string)
   (move-to-column start t)
   (insert (format format-string rectangle-number-line-counter))
   (setq rectangle-number-line-counter