[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tiny e3474f3 3/4: tiny.el (tiny-mapconcat-parse): Less
From: |
Stefan Monnier |
Subject: |
[elpa] externals/tiny e3474f3 3/4: tiny.el (tiny-mapconcat-parse): Less false positives |
Date: |
Mon, 15 Mar 2021 22:25:36 -0400 (EDT) |
branch: externals/tiny
commit e3474f3a11173b112a8fbd31aaf7d73a476884ff
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>
tiny.el (tiny-mapconcat-parse): Less false positives
After this chage, tiny won't try to expand this (point is at |):
(+ my-variable-1 asdf|)
Previously, it would be interpretted as ("m", "y-variable-", "1").
Now, the restriction is that if you want it to be interpretted like
that, put the cursor right after my-variable-1.
One new restriction is that the separator can't contain digits. It
didn't make sense before anyway, now it's enforced.
---
tiny.el | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/tiny.el b/tiny.el
index 3d5110d..652fe51 100644
--- a/tiny.el
+++ b/tiny.el
@@ -251,14 +251,21 @@ Return nil if nothing was matched, otherwise
(setq n2 n1
n1 nil)
(throw 'done t)))
- ;; else capture the whole thing
- ((looking-back "\\bm\\([^%|\n]*[0-9][^\n]*\\)"
+ ;; else capture separator, end number, formatter
+ ((looking-back "\\bm\\([^%|\n0-9]*\\)\\([0-9]+\\)\\([^\n]*\\)"
(line-beginning-position))
- (setq str (match-string-no-properties 1)
- tiny-beg (match-beginning 0)
- tiny-end (match-end 0))
- (when (zerop (length str))
- (throw 'done nil)))
+ (setq tiny-beg (match-beginning 0))
+ (setq tiny-end (match-end 0))
+ (let ((separator (match-string-no-properties 1))
+ (end-numbr (match-string-no-properties 2))
+ (formatter (match-string-no-properties 3)))
+ (if (or (string-match-p "[%|]" formatter)
+ (string= "" formatter))
+ (progn
+ (setq str (concat separator end-numbr formatter))
+ (when (zerop (length str))
+ (throw 'done nil)))
+ (throw 'done nil))))
(t (throw 'done nil)))
;; at this point, `str' should be either [sep]<num>[expr][fmt]
;; or [expr][fmt]