[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/multiple-cursors b9b851a 426/434: Merge pull request #358
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/multiple-cursors b9b851a 426/434: Merge pull request #358 from renatofdds/master |
Date: |
Sat, 7 Aug 2021 09:21:14 -0400 (EDT) |
branch: elpa/multiple-cursors
commit b9b851a7670f4348f3a08b11ef12ed99676c8b84
Merge: 5ffb19a b39e963
Author: Magnar Sveen <magnars@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #358 from renatofdds/master
Faster line-number-at-pos calculation
---
mc-edit-lines.el | 6 +++---
mc-mark-more.el | 4 ++--
multiple-cursors-core.el | 13 +++++++++++++
rectangular-region-mode.el | 6 +++---
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/mc-edit-lines.el b/mc-edit-lines.el
index e38d1c1..55772af 100644
--- a/mc-edit-lines.el
+++ b/mc-edit-lines.el
@@ -54,8 +54,8 @@ other non-nil value will cause short lines to be padded."
(error "Mark a set of lines first"))
(mc/remove-fake-cursors)
(let* ((col (current-column))
- (point-line (line-number-at-pos))
- (mark-line (progn (exchange-point-and-mark) (line-number-at-pos)))
+ (point-line (mc/line-number-at-pos))
+ (mark-line (progn (exchange-point-and-mark) (mc/line-number-at-pos)))
(direction (if (< point-line mark-line) :up :down))
(style (cond
;; called from lisp
@@ -71,7 +71,7 @@ other non-nil value will cause short lines to be padded."
(previous-logical-line 1 nil)
(move-to-column col))
;; Add the cursors
- (while (not (eq (line-number-at-pos) point-line))
+ (while (not (eq (mc/line-number-at-pos) point-line))
;; Pad the line
(when (eq style 'pad)
(while (< (current-column) col)
diff --git a/mc-mark-more.el b/mc-mark-more.el
index da8cedf..2e63130 100644
--- a/mc-mark-more.el
+++ b/mc-mark-more.el
@@ -579,8 +579,8 @@ If the region is inactive or on a single line, it will
behave like
(interactive "P")
(if (and (use-region-p)
(not (> (mc/num-cursors) 1))
- (not (= (line-number-at-pos (region-beginning))
- (line-number-at-pos (region-end)))))
+ (not (= (mc/line-number-at-pos (region-beginning))
+ (mc/line-number-at-pos (region-end)))))
(if arg
(call-interactively 'mc/edit-lines)
(call-interactively 'mc/mark-all-in-region))
diff --git a/multiple-cursors-core.el b/multiple-cursors-core.el
index 12e9e75..d93ace9 100644
--- a/multiple-cursors-core.el
+++ b/multiple-cursors-core.el
@@ -109,6 +109,19 @@
(and (listp cursor-type)
(eq (car cursor-type) 'bar))))
+(defun mc/line-number-at-pos (&optional pos absolute)
+ "Faster implementation of `line-number-at-pos'."
+ (if pos
+ (save-excursion
+ (if absolute
+ (save-restriction
+ (widen)
+ (goto-char pos)
+ (string-to-number (format-mode-line "%l")))
+ (goto-char pos)
+ (string-to-number (format-mode-line "%l"))))
+ (string-to-number (format-mode-line "%l"))))
+
(defun mc/make-cursor-overlay-at-eol (pos)
"Create overlay to look like cursor at end of line."
(let ((overlay (make-overlay pos pos nil nil nil)))
diff --git a/rectangular-region-mode.el b/rectangular-region-mode.el
index 01a078d..d8051cc 100644
--- a/rectangular-region-mode.el
+++ b/rectangular-region-mode.el
@@ -75,9 +75,9 @@ an exceedingly quick way of adding multiple cursors to
multiple lines."
(rrm/remove-rectangular-region-overlays)
(let* ((annoying-arrows-mode nil)
(point-column (current-column))
- (point-line (line-number-at-pos))
+ (point-line (mc/line-number-at-pos))
(anchor-column (save-excursion (goto-char rrm/anchor)
(current-column)))
- (anchor-line (save-excursion (goto-char rrm/anchor)
(line-number-at-pos)))
+ (anchor-line (save-excursion (goto-char rrm/anchor)
(mc/line-number-at-pos)))
(left-column (if (< point-column anchor-column) point-column
anchor-column))
(right-column (if (> point-column anchor-column) point-column
anchor-column))
(navigation-step (if (< point-line anchor-line) 1 -1)))
@@ -85,7 +85,7 @@ an exceedingly quick way of adding multiple cursors to
multiple lines."
(set-mark (point))
(move-to-column point-column)
(mc/save-excursion
- (while (not (= anchor-line (line-number-at-pos)))
+ (while (not (= anchor-line (mc/line-number-at-pos)))
(forward-line navigation-step)
(move-to-column anchor-column)
(when (= anchor-column (current-column))
- [nongnu] elpa/multiple-cursors 4c52fb1 358/434: Merge pull request #239 from ilohmar/dwim-mouse-select, (continued)
- [nongnu] elpa/multiple-cursors 4c52fb1 358/434: Merge pull request #239 from ilohmar/dwim-mouse-select, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e31b1eb 360/434: Merge pull request #240 from ilohmar/toggle-click-improvements, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6a62e60 367/434: Fix issue #131 (#247), ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 2329611 380/434: Merge remote-tracking branch 'upstream/master', ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 60b9ef8 385/434: Updated readme according to `mc/always-run-for-all, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors ad95d28 386/434: Update docstring of `mc/cursor-is-bar`, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 21e4825 387/434: mc/mark-previous-like-this-word/symbol., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 95f2e41 391/434: Add @AndreaOrru to list of contributors, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors e14fdb7 401/434: Merge pull request #298 from Quasilyte/update_readme, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 8172edd 417/434: Realign the file according to Elisp conventions, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors b9b851a 426/434: Merge pull request #358 from renatofdds/master,
ELPA Syncer <=
- [nongnu] elpa/multiple-cursors 6a04a14 428/434: Fix docstrings, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 7b13b03 433/434: Add homepage, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 84ab4ee 196/434: Fix mc/dump-list (take 2): it looses old setting, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6e15923 229/434: Use uninterned symbols in macros to avoid surprising local vars, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors cb848b2 239/434: Add @smithzvk to contributors list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 6745142 250/434: Move from Carton to Cask, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors bf01772 230/434: Use phi-search for C-s in mc-mode when available., ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors 186cb3b 255/434: Release 1.2.3, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors c94eca5 254/434: Fix broken let binding, ELPA Syncer, 2021/08/07
- [nongnu] elpa/multiple-cursors d8c5227 268/434: Merge pull request #103 from mathrick/compat-24.2, ELPA Syncer, 2021/08/07