mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Subject: (mouse-drag-and-drop-region): Simplify and remove assumptions
* lisp/mouse.el (mouse-drag-and-drop-region): Use insert-for-yank for insertion, remove rectangular-region-specific variables. Use text-property-not-all. * lisp/rect.el (rectangle-dimensions): New function. (rectangle-position-as-coordinates): Use the usual 1-origin for lines.
This commit is contained in:
parent
f172ceda8a
commit
8fffac14b1
2 changed files with 26 additions and 32 deletions
22
lisp/rect.el
22
lisp/rect.el
|
|
@ -170,21 +170,19 @@ The final point after the last operation will be returned."
|
|||
(defun rectangle-position-as-coordinates (position)
|
||||
"Return cons of the column and line values of POSITION.
|
||||
POSITION specifies a position of the current buffer. The value
|
||||
returned is a cons of the current column of POSITION and its line
|
||||
number."
|
||||
returned has the form (COLUMN . LINE)."
|
||||
(save-excursion
|
||||
(goto-char position)
|
||||
(let ((col (current-column))
|
||||
(line (1- (line-number-at-pos))))
|
||||
(line (line-number-at-pos)))
|
||||
(cons col line))))
|
||||
|
||||
(defun rectangle-intersect-p (pos1 size1 pos2 size2)
|
||||
"Return non-nil if two rectangles intersect.
|
||||
POS1 and POS2 specify the positions of the upper-left corners of
|
||||
the first and second rectangle as conses of their column and line
|
||||
values. SIZE1 and SIZE2 specify the dimensions of the first and
|
||||
second rectangle, as conses of their width and height measured in
|
||||
columns and lines."
|
||||
the first and second rectangles as conses of the form (COLUMN . LINE).
|
||||
SIZE1 and SIZE2 specify the dimensions of the first and second
|
||||
rectangles, as conses of the form (WIDTH . HEIGHT)."
|
||||
(let ((x1 (car pos1))
|
||||
(y1 (cdr pos1))
|
||||
(x2 (car pos2))
|
||||
|
|
@ -198,6 +196,16 @@ columns and lines."
|
|||
(<= (+ y1 h1) y2)
|
||||
(<= (+ y2 h2) y1)))))
|
||||
|
||||
(defun rectangle-dimensions (start end)
|
||||
"Return the dimensions of the rectangle with corners at START
|
||||
and END. The returned value has the form of (WIDTH . HEIGHT)."
|
||||
(save-excursion
|
||||
(let* ((height (1+ (abs (- (line-number-at-pos end)
|
||||
(line-number-at-pos start)))))
|
||||
(cols (rectangle--pos-cols start end))
|
||||
(width (abs (- (cdr cols) (car cols)))))
|
||||
(cons width height))))
|
||||
|
||||
(defun delete-rectangle-line (startcol endcol fill)
|
||||
(when (= (move-to-column startcol (if fill t 'coerce)) startcol)
|
||||
(delete-region (point)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue