summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Antolín <omar.antolin@gmail.com>2020-05-24 13:02:21 -0500
committerOmar Antolín <omar.antolin@gmail.com>2020-05-24 13:02:21 -0500
commitbc9e48216e6e3016ea2acb329435573c9c6b1a41 (patch)
tree1fd769500fa43e58c8b8cfc8e553c1ab038a0103
parent1f985d0e07251efa4b7925d763b7c9c09f4d88c4 (diff)
Add option for "smart case" matchingsmart-case
-rw-r--r--orderless.el22
1 files changed, 21 insertions, 1 deletions
diff --git a/orderless.el b/orderless.el
index 5df1f3e..8f7cc40 100644
--- a/orderless.el
+++ b/orderless.el
@@ -207,6 +207,21 @@ consult this variable at all."
:type 'function
:group 'orderless)
+(defcustom orderless-smart-case t
+ "Whether to use smart case.
+If this variable is t, then case-sensitivity is decided as
+follows: if any component contains upper case letters, the
+matches are case sensitive; otherwise case-insensitive. This
+like the behavior of `isearch' when `search-upper-case' is
+non-nil.
+
+On the other hand, if this variable is nil, then case-sensitivity
+is determined by the values of `completion-ignore-case',
+`read-file-name-completion-ignore-case' and
+`read-buffer-completion-ignore-case', as usual for completion."
+ :type 'boolean
+ :group 'orderless)
+
;;; Matching styles
(defalias 'orderless-regexp #'identity
@@ -440,7 +455,12 @@ The predicate PRED is used to constrain the entries in TABLE."
(pcase-let* ((`(,prefix . ,pattern)
(orderless--prefix+pattern string table pred))
(completion-regexp-list
- (funcall orderless-pattern-compiler pattern)))
+ (funcall orderless-pattern-compiler pattern))
+ (completion-ignore-case
+ (if orderless-smart-case
+ (cl-loop for regexp in completion-regexp-list
+ always (isearch-no-upper-case-p regexp t))
+ completion-ignore-case)))
(all-completions prefix table pred)))
(invalid-regexp nil)))