+(defun swiper--re-builder (str)
+ "Transform STR into a swiper regex.
+This is the regex used in the minibuffer, since the candidates
+there have line numbers. In the buffer, `ivy--regex' should be used."
+ (cond
+ ((equal str "")
+ "")
+ ((equal str "^")
+ ".")
+ ((string-match "^\\^" str)
+ (setq ivy--old-re "")
+ (let ((re (ivy--regex-plus (substring str 1))))
+ (format "^[0-9][0-9 ]\\{%d\\}%s"
+ swiper--width
+ (if (zerop ivy--subexps)
+ (prog1 (format "\\(%s\\)" re)
+ (setq ivy--subexps 1))
+ re))))
+ (t
+ (ivy--regex-plus str))))
+