[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c307ae9 055/184: swiper.el (swiper--re-builder): Fix symbo
From: |
Oleh Krehel |
Subject: |
[elpa] master c307ae9 055/184: swiper.el (swiper--re-builder): Fix symbol bounds with char-fold-to-regexp |
Date: |
Wed, 16 Oct 2019 13:14:48 -0400 (EDT) |
branch: master
commit c307ae974c0224d47d038a3a260c64d4d8f8bed7
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper--re-builder): Fix symbol bounds with char-fold-to-regexp
With this setting:
(setq search-default-mode #'char-fold-to-regexp)
and the input "\_<symbol-name\_>", prevent the symbol bounds from
being quoted by `char-fold-to-regexp'.
* ivy-test.el (swiper--re-builder): Add test.
Fixes #2177
---
ivy-test.el | 6 +++++-
swiper.el | 17 +++++++++++------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 2a9931b..2c859c1 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -186,7 +186,11 @@ will bring the behavior in line with the newer Emacsen."
(should (string= (swiper--re-builder "^a")
"^ ?\\(a\\)"))
(should (string= (swiper--re-builder "^a b")
- "^ \\(a\\).*?\\(b\\)")))
+ "^ \\(a\\).*?\\(b\\)"))
+ (should
+ (string-match-p
+ "\\`\\\\_<.*\\\\_>\\'"
+ (swiper--re-builder "\\_<iv\\_>"))))
(ert-deftest swiper--re-builder-char-fold ()
:expected-result (if (>= emacs-major-version 25)
diff --git a/swiper.el b/swiper.el
index 8ada395..2766485 100644
--- a/swiper.el
+++ b/swiper.el
@@ -731,12 +731,17 @@ line numbers. For the buffer, use `ivy--regex' instead."
(setq ivy--subexps 1))
(format "^ %s" re))))
((eq (bound-and-true-p search-default-mode)
'char-fold-to-regexp)
- (let ((subs (ivy--split str)))
- (setq ivy--subexps (length subs))
- (mapconcat
- (lambda (s) (format "\\(%s\\)" (char-fold-to-regexp s)))
- subs
- ".*?")))
+ (if (string-match "\\`\\\\_<\\(.+\\)\\\\_>\\'" str)
+ (concat
+ "\\_<"
+ (char-fold-to-regexp (match-string 1 str))
+ "\\_>")
+ (let ((subs (ivy--split str)))
+ (setq ivy--subexps (length subs))
+ (mapconcat
+ (lambda (s) (format "\\(%s\\)" (char-fold-to-regexp s)))
+ subs
+ ".*?"))))
(t
(funcall re-builder str)))))
re))
- [elpa] master 1a4ebda 048/184: Allow virtual-buffers customization, (continued)
- [elpa] master 1a4ebda 048/184: Allow virtual-buffers customization, Oleh Krehel, 2019/10/16
- [elpa] master b4af1a6 040/184: swiper.el (swiper-recenter-top-bottom): Works for swiper-isearch, Oleh Krehel, 2019/10/16
- [elpa] master 327dbd6 058/184: counsel.el (counsel-rg-base-command): Don't include directory on non-Windows, Oleh Krehel, 2019/10/16
- [elpa] master 5140127 046/184: ivy.el: Run ispell-comments-and-strings, Oleh Krehel, 2019/10/16
- [elpa] master 2ecbd7d 054/184: ivy.el (ivy-read-action-ivy): Show the selected item in the prompt, Oleh Krehel, 2019/10/16
- [elpa] master ae70443 060/184: counsel.el (counsel-major): Add, Oleh Krehel, 2019/10/16
- [elpa] master f66eec5 059/184: Add counsel-buffer-or-recentf, Oleh Krehel, 2019/10/16
- [elpa] master 1303e10 061/184: counsel.el (counsel-M-x-action): Extract, Oleh Krehel, 2019/10/16
- [elpa] master ca5040d 078/184: counsel.el (counsel-rg-base-command): Remove "-S" flag, Oleh Krehel, 2019/10/16
- [elpa] master 20d604c 069/184: ivy.el (ivy-restrict-to-matches): Fix for ivy-resume, Oleh Krehel, 2019/10/16
- [elpa] master c307ae9 055/184: swiper.el (swiper--re-builder): Fix symbol bounds with char-fold-to-regexp,
Oleh Krehel <=
- [elpa] master 5424a564 082/184: ivy.el (ivy--handle-directory): Extract, Oleh Krehel, 2019/10/16
- [elpa] master d73376f 010/184: ivy.el (ivy--trim-trailing-re): Add, Oleh Krehel, 2019/10/16
- [elpa] master 824f8d7 072/184: counsel.el (counsel--find-return-list): Works with or without "./" prefix, Oleh Krehel, 2019/10/16
- [elpa] master 4fef498 065/184: Use file-name-at-point-functions for file commands, Oleh Krehel, 2019/10/16
- [elpa] master 3d0fcb5 064/184: ivy.el (ivy-partial): Fix trailing space issue, Oleh Krehel, 2019/10/16
- [elpa] master 7dea040 066/184: ivy.el (ivy-pre-prompt-function): Add, Oleh Krehel, 2019/10/16
- [elpa] master cd7e924 077/184: ivy.el (ivy-read): Fix docstring, Oleh Krehel, 2019/10/16
- [elpa] master da7e546 085/184: ivy.el (ivy-previous-line-and-call): Fix typo, Oleh Krehel, 2019/10/16
- [elpa] master 03fdaea 087/184: doc/ivy.org: Add more recommended key bindings, Oleh Krehel, 2019/10/16
- [elpa] master 941d408 086/184: doc/ivy.org: Fix "C-M-n" description, Oleh Krehel, 2019/10/16