aboutsummaryrefslogtreecommitdiff
path: root/evil-common.el
diff options
context:
space:
mode:
authorAxel Forsman <axelsfor@gmail.com>2023-07-14 22:06:07 +0200
committerAxel Forsman <axelsfor@gmail.com>2023-07-17 19:02:11 +0200
commitf84d3453b312bd8ec0a1c092d075bbc3d91e157b (patch)
tree332c2d802dbda3eef60de8c29e0480e0de1b562e /evil-common.el
parent4b45f2619258374ebb34b07212806e77bc2997c3 (diff)
Read Ex commands from buffer
When lexing a string with string-match and its START argument, there is no way to anchor matches to the START position. Instead, one must either allocate substrings - as done prior to commit 56b43b6f7e014e905f85df1c542c67f46ea99566 - or use looking-at etc., instead. This commit opts for the latter. The Ex completion-at-point functions are also rewritten in order to avoid having to add ex-index text properties to the command string, since evil--ex-syntactic-context could be extended to provide that information just as easily.
Diffstat (limited to 'evil-common.el')
-rw-r--r--evil-common.el27
1 files changed, 12 insertions, 15 deletions
diff --git a/evil-common.el b/evil-common.el
index 7e6b568..51d55b0 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -811,14 +811,13 @@ Inhibits echo area messages, mode line updates and cursor changes."
,@body))
(defun evil-count-lines (beg end)
- "Return absolute line-number-difference betweeen `beg` and `end`.
-This should give the same results no matter where on the line `beg`
-and `end` are."
+ "Return absolute line-number-difference betweeen BEG and END.
+This should give the same results no matter where on the line BEG
+and END are."
(if (= beg end)
0
- (let* ((last (max beg end))
- (end-at-bol (save-excursion (goto-char last)
- (bolp))))
+ (let ((end-at-bol (save-excursion (goto-char (max beg end))
+ (bolp))))
(if end-at-bol
(count-lines beg end)
(1- (count-lines beg end))))))
@@ -978,14 +977,13 @@ argument. Movement is constrained to the current field."
"Return the position of LINE.
If COLUMN is specified, return its position on the line.
A negative number means the end of the line."
- (declare-function evil-goto-line "evil-commands")
(save-excursion
- (evil-goto-line line)
- (if (numberp column)
- (if (< column 0)
- (beginning-of-line 2)
- (move-to-column column))
- (beginning-of-line))
+ (goto-char (point-min))
+ (forward-line (1- line))
+ (when (numberp column)
+ (if (< column 0)
+ (forward-line)
+ (move-to-column column)))
(point)))
(defun evil-column (&optional pos)
@@ -2007,8 +2005,7 @@ The following special registers are supported.
(t search-ring)))
(user-error "No previous regular expression")))
((eq register ?:)
- (or (car-safe evil-ex-history)
- (user-error "No previous command line")))
+ (or (car evil-ex-history) (user-error "No previous command line")))
((eq register ?.)
evil-last-insertion)
((eq register ?-)