Faster line-number-at-pos calculation

This commit is contained in:
Renato Ferreira
2019-05-02 21:41:14 -03:00
parent 5ffb19af48
commit b39e9631d6
4 changed files with 21 additions and 8 deletions

View File

@@ -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)))