[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search 0809f99 072/332: New user option: el-search-u
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search 0809f99 072/332: New user option: el-search-use-sloppy-strings |
Date: |
Tue, 1 Dec 2020 15:48:14 -0500 (EST) |
branch: externals/el-search
commit 0809f9949d0dad8026ddc2f07d431dd5c6eeadaa
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
New user option: el-search-use-sloppy-strings
---
el-search.el | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/el-search.el b/el-search.el
index a1bdd23..f5db2eb 100644
--- a/el-search.el
+++ b/el-search.el
@@ -264,6 +264,26 @@ done independently for every single matching operation.
If nil, the value of `case-fold-search' is decisive."
:type 'boolean)
+(defcustom el-search-use-sloppy-strings nil
+ "Whether to allow the usage of \"sloppy strings\".
+When this option is turned on, for faster typing you are allowed
+to specify symbols instead of strings as arguments to an
+\"el-search\" pattern type that would otherwise accept only
+strings, and their names will be used as input (with other words,
+this spares you to type the string delimiters in many cases).
+
+For example,
+
+ \(source ^cl\)
+
+is then equivalent to
+
+ \(source \"^cl\"\)
+
+When this option is off, the first form would just signal an
+error."
+ :type 'boolean)
+
;;;; Helpers
@@ -592,9 +612,13 @@ matches the list (1 2 3 4 5 6 7 8 9) and binds `x' to (4 5
6)."
(,'\, ,(car more-patterns)))))))
(t `(append ,pattern (append ,@more-patterns)))))))
+(defun el-search--stringish-p (thing)
+ (or (stringp thing) (and el-search-use-sloppy-strings (symbolp thing))))
+
(el-search-defpattern string (&rest regexps)
"Matches any string that is matched by all REGEXPS."
- (el-search--check-pattern-args 'string regexps #'stringp)
+ (el-search--check-pattern-args 'string regexps #'el-search--stringish-p
+ "Argument not a string")
(let ((string (make-symbol "string"))
(regexp (make-symbol "regexp")))
`(and (pred stringp)
@@ -605,7 +629,8 @@ matches the list (1 2 3 4 5 6 7 8 9) and binds `x' to (4 5
6)."
(el-search-defpattern symbol (&rest regexps)
"Matches any symbol whose name is matched by all REGEXPS."
- (el-search--check-pattern-args 'symbol regexps #'stringp)
+ (el-search--check-pattern-args 'symbol regexps #'el-search--stringish-p
+ "Argument not a string")
`(and (pred symbolp)
(app symbol-name (string ,@regexps))))
@@ -662,8 +687,9 @@ REGEXP can also be a symbol, in which case
(concat \"^\" (symbol-name regexp) \"$\")
is used as regular expression."
- (el-search--check-pattern-args 'source (list regexp) #'stringp)
- `(pred (el-search--match-symbol-file ,regexp)))
+ (el-search--check-pattern-args 'source (list regexp) #'el-search--stringish-p
+ "Argument not a string")
+ `(pred (el-search--match-symbol-file ,(if (symbolp regexp) (symbol-name
regexp) regexp))))
(defun el-search--match-key-sequence (keys expr)
(when-let ((expr-keys (pcase expr
- [elpa] externals/el-search 9ab546b 017/332: drop el-search-expression-contains-match-p, (continued)
- [elpa] externals/el-search 9ab546b 017/332: drop el-search-expression-contains-match-p, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1694128 029/332: some doc tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 7886e33 031/332: fix el-search--repair-replacement-layout: don't move when replacing, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 672def6 034/332: fix whitespace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search daa7f92 039/332: improve docs; new: el-search-defpattern; add some pattern types, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e14236a 038/332: fix whitespace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 00d6af1 040/332: remove search wrapping functionality, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3b5cce3 043/332: fix compiler errors and warnings, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 06af085 044/332: edit TODO list, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search ec0c3e8 053/332: el-search: new pattern type `not', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0809f99 072/332: New user option: el-search-use-sloppy-strings,
Stefan Monnier <=
- [elpa] externals/el-search ba82854 022/332: rename a local variable, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1222012 046/332: prerequisites to allow replace with multiple expressions, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 0af261a 050/332: el-search: some cleanup, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 3370594 060/332: el-search: New pattern type `l', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b936a28 062/332: Go to isearch left end when starting replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 59c6139 064/332: Complete and document what a SYMBOL in `l' matches, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 2c1cdeb 066/332: factor out minibuffer setup hook fun; treat empty input, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 02168e0 068/332: Tweak docstring of el-search--ensure-sexp-start, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d6ae854 070/332: Minor change in `string' pattern, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search a0b44dd 078/332: Improve documentation and argument names of el-search-query-replace, Stefan Monnier, 2020/12/01