Skip to content

added straight-x-open-straight-package-readme function #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions straight-x.el
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,32 @@ those listed."
(straight-freeze-versions)
(straight-x-freeze-pinned-versions))

(defun straight-x-open-straight-package-readme (package-name)
"Open the README file of a straight package in read-only mode."
(interactive
(let* ((repos-dir (expand-file-name "straight/repos/" straight-base-dir))
(package-names (if (file-directory-p repos-dir)
(cl-remove-if-not
(lambda (dir)
(seq-some
(lambda (file)
(string-match-p "^README\\(?:\\..*\\)?$" file))
(directory-files (expand-file-name dir repos-dir) nil "^[^.]+")))
(directory-files repos-dir nil "^[^.]+"))
(error "Repositories directory not found: %s" repos-dir))))
(list (completing-read "Enter package name: " package-names nil t))))
(let* ((repo-path (expand-file-name package-name (expand-file-name "straight/repos/" straight-base-dir)))
(readme-path (seq-some
(lambda (file)
(when (string-match-p "^README\\(?:\\..*\\)?$" file)
(expand-file-name file repo-path)))
(directory-files repo-path))))
(if readme-path
(let ((buffer (find-file-read-only readme-path)))
(message "Opened %s in read-only mode." readme-path)
buffer)
(message "No README file found for package: %s" package-name))))


(provide 'straight-x)

Expand Down
Loading