Function: rectangle--*-char
rectangle--*-char is a byte-compiled function defined in rect.el.gz.
Signature
(rectangle--*-char CMD N &optional OTHER-CMD)
Source Code
;; Defined in /usr/src/emacs/lisp/rect.el.gz
(defun rectangle--*-char (cmd n &optional other-cmd)
;; Part of the complexity here is that I'm trying to avoid making assumptions
;; about the L2R/R2L direction of text around point, but this is largely
;; useless since the rectangles implemented in this file are "logical
;; rectangles" and not "visual rectangles", so in the presence of
;; bidirectional text things won't work well anyway.
(if (< n 0) (rectangle--*-char other-cmd (- n))
(let ((col (rectangle--point-col (point)))
(step 1))
(while (> n 0)
(let* ((bol (line-beginning-position))
(eol (line-end-position))
(curcol (current-column))
(nextcol
(condition-case nil
(save-excursion
(funcall cmd step)
(cond
((> bol (point)) (- curcol 1))
((< eol (point)) (+ col (1+ n)))
(t (current-column))))
(end-of-buffer (+ col (1+ n)))
(beginning-of-buffer (- curcol 1))))
(diff (abs (- nextcol col))))
(cond
((and (< nextcol curcol) (< curcol col))
(let ((curdiff (- col curcol)))
(if (<= curdiff n)
(progn (decf n curdiff) (setq col curcol))
(setq col (- col n) n 0))))
((< nextcol 0) (ding) (setq n 0 col 0)) ;Bumping into BOL!
((= nextcol curcol) (funcall cmd 1))
(t ;; (> nextcol curcol)
(if (<= diff n)
(progn (decf n diff) (setq col nextcol))
(setq col (if (< col nextcol) (+ col n) (- col n)) n 0))))
(setq step (1+ step))))
;; FIXME: This rectangle--col-pos's move-to-column is wasted!
(rectangle--col-pos col 'point))))