oantolin / orderless

Emacs completion style that matches multiple regexps in any order
GNU General Public License v3.0
776 stars 27 forks source link

`orderless-not` ignores smart case #174

Closed mentalisttraceur closed 5 months ago

mentalisttraceur commented 5 months ago

I've noticed that orderless-not seems to always be case insensitive. (Or it follows the value of case-fold-search, since it uses string-match-p.)

Seems easy to enhance orderless-not to support orderless-smart-case:

(defun orderless-not (pred regexp)
  "Match strings that do *not* match PRED and REGEXP."
  (let ((ignore-case (orderless--ignore-case-p (list regexp))))
    (lambda (str)
      (let ((case-fold-search ignore-case))
         (not (orderless--match-p pred regexp str))))))
 (defun orderless-not (pred regexp)
   "Match strings that do *not* match PRED and REGEXP."
+  (let ((ignore-case (orderless--ignore-case-p (list regexp))))
     (lambda (str)
+      (let ((case-fold-search ignore-case))
         (not (orderless--match-p pred regexp str))))
+))

(This doesn't handle the case where regexp is nil. I don't know enough about that case to decide what the right logic is for it.)

This enables intuitive and convenient consistency. Even when orderless-smart-case is t and capitals are involved, we can type a match that we want to negate, check that it matches exactly what we want to unmatch, and then just add "!".