<commit_before>;;; config/default/autoload/search.el -*- lexical-binding: t; -*-

;;;###autoload
(defun +default/search-cwd (&optional arg)
  "Conduct a text search in files under the current folder.
If prefix ARG is set, prompt for a directory to search from."
  (interactive "P")
  (let ((default-directory
          (if arg
              (read-directory-name "Search directory: ")
            default-directory)))
    (call-interactively
     (cond ((featurep! :completion ivy)     #'+ivy/project-search-from-cwd)
           ((featurep! :completion helm)    #'+helm/project-search-from-cwd)
           ((featurep! :completion vertico) #'+vertico/project-search-from-cwd)
           (#'rgrep)))))

;;;###autoload
(defun +default/search-other-cwd ()
  "Conduct a text search in another directory."
  (interactive)
  (+default/search-cwd 'other))

;;;###autoload
(defun +default/search-buffer ()
  "Conduct a text search on the current buffer.
If a selection is active, pre-fill the prompt with it."
  (interactive)
  (cond ((or (featurep! :completion helm) (featurep! :completion ivy))
         (call-interactively
          (if (region-active-p)
              #'swiper-isearch-thing-at-point
            #'swiper-isearch)))
        ((featurep! :completion vertico)
         (if (region-active-p)
             (let ((start (region-beginning))
                   (end   (region-end)))
               (deactivate-mark)
               (consult-line (buffer-substring-no-properties start end)))
           (call-interactively #'consult-line)))))

;;;###autoload
(defun +default/search-project (&optional arg)
  "Conduct a text search in the current project root.
If prefix ARG is set, include ignored/hidden files."
  (interactive "P")
  (let* ((projectile-project-root nil)
         (disabled-command-function nil)
         (current-prefix-arg (unless (eq arg 'other) arg))
         (default-directory
           (if (eq arg 'other)
               (if-let (projects (projectile-relevant-known-projects))
                   (completing-read "Search project: " projects nil t)
                 (user-error "There are no known projects"))
             default-directory)))
    (call-interactively
     (cond ((featurep! :completion ivy)     #'+ivy/project-search)
           ((featurep! :completion helm)    #'+helm/project-search)
           ((featurep! :completion vertico) #'+vertico/project-search)
           (#'projectile-ripgrep)))))

;;;###autoload
(defun +default/search-other-project ()
  "Conduct a text search in a known project."<commit_msg>fix(default): search region literally in +default/search-buffer<commit_after>;;; config/default/autoload/search.el -*- lexical-binding: t; -*-

;;;###autoload
(defun +default/search-cwd (&optional arg)
  "Conduct a text search in files under the current folder.
If prefix ARG is set, prompt for a directory to search from."
  (interactive "P")
  (let ((default-directory
          (if arg
              (read-directory-name "Search directory: ")
            default-directory)))
    (call-interactively
     (cond ((featurep! :completion ivy)     #'+ivy/project-search-from-cwd)
           ((featurep! :completion helm)    #'+helm/project-search-from-cwd)
           ((featurep! :completion vertico) #'+vertico/project-search-from-cwd)
           (#'rgrep)))))

;;;###autoload
(defun +default/search-other-cwd ()
  "Conduct a text search in another directory."
  (interactive)
  (+default/search-cwd 'other))

;;;###autoload
(defun +default/search-buffer ()
  "Conduct a text search on the current buffer.
If a selection is active, pre-fill the prompt with it."
  (interactive)
  (cond ((or (featurep! :completion helm)
             (featurep! :completion ivy))
         (call-interactively
          (if (region-active-p)
              #'swiper-isearch-thing-at-point
            #'swiper-isearch)))
        ((featurep! :completion vertico)
         (if (region-active-p)
             (let ((start (region-beginning))
                   (end   (region-end)))
               (deactivate-mark)
               (consult-line
                (replace-regexp-in-string
                 " " "\\\\ "
                 (rxt-quote-pcre
                  (buffer-substring-no-properties start end)))))
           (call-interactively #'consult-line)))))

;;;###autoload
(defun +default/search-project (&optional arg)
  "Conduct a text search in the current project root.
If prefix ARG is set, include ignored/hidden files."
  (interactive "P")
  (let* ((projectile-project-root nil)
         (disabled-command-function nil)
         (current-prefix-arg (unless (eq arg 'other) arg))
         (default-directory
           (if (eq arg 'other)
               (if-let (projects (projectile-relevant-known-projects))
                   (completing-read "Search project: " projects nil t)
                 (user-error "There are no known projects"))
             default-directory)))
    (call-interactively
     (cond ((featurep! :completion ivy)     #'+ivy/project-search)
           ((featurep! :completion helm)    #'+helm/project-search)
           ((featurep! :completion vertico) #'+vertico/project-search)
           (#'projectile-ripgrep)))))

;;;###autoload
(defun +default/search-other-project ()
  "Conduct a text search in a known project."
{'fraction_non_alphanumeric': 0.14172185430463577, 'fraction_numerical': 0.0, 'mean_word_length': 2.496031746031746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3212889', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1554, 'n_words': 412}