abo-abo / swiper

Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
https://oremacs.com/swiper/
2.3k stars 338 forks source link

A call to counsel-locate errors out when first character in search is a minus sign #3033

Open nordlow opened 8 months ago

nordlow commented 8 months ago

Solution: If first character is a minus sign it needs to be prefixed with a backslash.

basil-conto commented 8 months ago

(By now) I'm not sure how much counsel-locate can do about this by default.

We could change the default way of formatting the command line from locate -i --regex %s to locate -i --regex -- %s, but I don't know how portable this is.

Without more insight into that, my best suggestion is to set the user option counsel-locate-cmd to a custom function such as:

(defun my-counsel-locate-cmd (input)
  "Return a `locate' command to search for an INPUT string."
  (list locate-command "-i" "--regex" "--" input))

Of course I find it quite unfortunate that counsel-locate did not integrate from the beginning with user options like locate-make-command-line which have been with us since Emacs 20.