[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 41fc28b 01/24: New user option: el-search-use-sloppy-strin
From: |
Michael Heerdegen |
Subject: |
[elpa] master 41fc28b 01/24: New user option: el-search-use-sloppy-strings |
Date: |
Thu, 19 May 2016 20:46:37 +0000 (UTC) |
branch: master
commit 41fc28b91e17b168401d404078a77fbee0c86d21
Author: Michael Heerdegen <address@hidden>
Commit: Michael Heerdegen <address@hidden>
New user option: el-search-use-sloppy-strings
---
packages/el-search/el-search.el | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index a1bdd23..f5db2eb 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/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] master updated (24ce066 -> c835174), Michael Heerdegen, 2016/05/19
- [elpa] master f9980f6 05/24: Replacing: make C-g an alternative key for quitting, Michael Heerdegen, 2016/05/19
- [elpa] master f178717 12/24: Clarify the operation scope of replacing, Michael Heerdegen, 2016/05/19
- [elpa] master 91192f5 10/24: Add patterns for character properties, Michael Heerdegen, 2016/05/19
- [elpa] master 246e1ff 17/24: Small fix in el-search--setup-minibuffer, Michael Heerdegen, 2016/05/19
- [elpa] master 098582b 20/24: Reduce duration of a `sit-for', Michael Heerdegen, 2016/05/19
- [elpa] master 01e5bcd 22/24: Clean up el-search-read-expression-map; add some doc, Michael Heerdegen, 2016/05/19
- [elpa] master 0b9fe9c 23/24: Set initial input for replace when coming from el-search-pattern, Michael Heerdegen, 2016/05/19
- [elpa] master c0d9ca7 14/24: Make el-search-pattern accept an optional NO-ERROR arg, Michael Heerdegen, 2016/05/19
- [elpa] master 41fc28b 01/24: New user option: el-search-use-sloppy-strings,
Michael Heerdegen <=
- [elpa] master 149acb9 07/24: Improve documentation and argument names of el-search-query-replace, Michael Heerdegen, 2016/05/19
- [elpa] master 3d0a12e 13/24: Fix el-search--ensure-sexp-start error at bob, Michael Heerdegen, 2016/05/19
- [elpa] master 03dd4e7 06/24: Comment and whitespace changes only, Michael Heerdegen, 2016/05/19
- [elpa] master b885ef1 03/24: el-search--check-pattern-args: make arg TYPE a string, Michael Heerdegen, 2016/05/19
- [elpa] master 3d72d1d 11/24: Address compiler warnings, Michael Heerdegen, 2016/05/19
- [elpa] master 536fab6 15/24: Give el-search--s a more meaningful name, Michael Heerdegen, 2016/05/19
- [elpa] master 4b11cb8 09/24: Rename two functions, Michael Heerdegen, 2016/05/19
- [elpa] master 8d7b29c 21/24: Make sure not to lose the minibuffer-prompt face, Michael Heerdegen, 2016/05/19
- [elpa] master c356b2d 19/24: Rename a local variable, Michael Heerdegen, 2016/05/19
- [elpa] master bb98a1d 04/24: Rewrite replacement layout restoration, Michael Heerdegen, 2016/05/19