fix(emacs): Expand paths given to age.el

This commit is contained in:
Madeleine Sydney
2025-02-20 15:51:53 -07:00
parent e2193dbd53
commit 66773a7567
4 changed files with 6 additions and 80 deletions

View File

@@ -1,74 +0,0 @@
;;; syd-search.el --- Description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2025 Madeleine Sydney
;;
;; Author: Madeleine Sydney <lomiskiam@gmail.com>
;; Maintainer: Madeleine Sydney <lomiskiam@gmail.com>
;; Created: January 12, 2025
;; Modified: January 12, 2025
;; Version: 0.0.1
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex text tools unix vc
;; Homepage: https://github.com/crumb/syd-search
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Description
;;
;;; Code:
(cl-defun syd-search-region (beg end &key initial)
(save-restriction
(narrow-to-region beg end)
(consult-line initial)))
(defun syd-search--escape-regexp (str)
(require 'syd-text)
(replace-regexp-in-string " " "\\\\ "
(syd-pcre-quote str)))
(defun syd-search-buffer (buffer)
"Conduct a text search on BUFFER.
If a selection is active and multi-line, perform a search restricted to that
region.
If a selection is active and not multi-line, use the selection as the initial
input and search the whole buffer for it."
(interactive (list (current-buffer)))
(save-restriction
(let* ((beg (region-beginning))
(end (region-end))
(multiline-p (/= (line-number-at-pos beg)
(line-number-at-pos end))))
(if (and beg end (region-active-p))
(progn (deactivate-mark)
(if multiline-p
(syd-search-region beg end)
;; Treat as a single pattern, not several
;; space-separated patterns.
(consult-line (syd-search--escape-regexp
(buffer-substring-no-properties beg end)))))
(consult-line)))))
;;;###autoload
(defun syd-search-directory (dir)
(interactive (list (read-directory-name
"Search directory: "
default-directory nil t)))
(cond ((executable-find "rg")
(consult-ripgrep dir))
((executable-find "grep")
(message "Couldn't find ripgrep; using grep")
(consult-grep dir))))
;;;###autoload
(defun syd-search-current-directory ()
(interactive)
(syd-search-directory default-directory))
(provide 'syd-search)
;;; syd-search.el ends here