Many changes by GLM
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
orgTrivialBuild,
|
||||
epkgs,
|
||||
pkgs,
|
||||
} : orgTrivialBuild {
|
||||
}:
|
||||
orgTrivialBuild {
|
||||
pname = "azos-emacs-lauretta";
|
||||
version = "0.1.6";
|
||||
src = ./elisp/azos-emacs-lauretta.org;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
#+title: Aner's Emacs Lauretta Configuration
|
||||
#+property: header-args :results silent
|
||||
|
||||
@@ -31,6 +32,7 @@
|
||||
** Agent Shell
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq agent-shell-opencode-default-model-id "opencode/glm-5")
|
||||
(setq agent-shell-preferred-agent-config (agent-shell-opencode-make-agent-config))
|
||||
#+end_src
|
||||
|
||||
@@ -58,6 +60,75 @@
|
||||
(azos/audio/enable-tab-display))
|
||||
#+end_src
|
||||
|
||||
** Nixpkgs Search
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun azos/nixpkgs-parse-json-lines (str)
|
||||
"Parse JSON Lines format (one JSON object per line) from STR."
|
||||
(mapcar (lambda (line)
|
||||
(and (not (string-empty-p line))
|
||||
(string-match "^{" line)
|
||||
(condition-case nil
|
||||
(json-parse-string line)
|
||||
(error nil))))
|
||||
(split-string (string-trim str) "\n" t)))
|
||||
|
||||
(defun azos/nixpkgs-g (key hash)
|
||||
"Get KEY from HASH table."
|
||||
(when (hash-table-p hash)
|
||||
(gethash key hash)))
|
||||
|
||||
(defun azos/nixpkgs-search ()
|
||||
"Search for a nixpkgs package and show its info."
|
||||
(interactive)
|
||||
(let* ((pattern (read-string "Search pattern: "))
|
||||
(json-output (shell-command-to-string
|
||||
(format "nix-search --json --max-results 50 '%s'" pattern)))
|
||||
(results (and json-output
|
||||
(not (string-empty-p json-output))
|
||||
(azos/nixpkgs-parse-json-lines json-output)))
|
||||
(packages (delq nil (mapcar (lambda (item)
|
||||
(let ((pname (azos/nixpkgs-g "package_pname" item)))
|
||||
(when pname
|
||||
(cons pname item))))
|
||||
results))))
|
||||
(if packages
|
||||
(let* ((selected (completing-read "Package: " (mapcar #'car packages) nil t))
|
||||
(package-data (cdr (assoc-string selected packages))))
|
||||
(let ((buf (get-buffer-create "*nixpkgs-package-info*")))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(if package-data
|
||||
(progn
|
||||
(insert (format "Package: %s\n\n" selected))
|
||||
(insert (format "Version: %s\n" (or (azos/nixpkgs-g "package_pversion" package-data) "unknown")))
|
||||
(insert (format "Attr: %s\n" (or (azos/nixpkgs-g "package_attr_name" package-data) "unknown")))
|
||||
(insert (format "\nDescription: %s\n"
|
||||
(or (azos/nixpkgs-g "package_description" package-data) "none")))
|
||||
(let ((programs (azos/nixpkgs-g "package_programs" package-data)))
|
||||
(when (vectorp programs)
|
||||
(insert (format "\nPrograms: %s\n"
|
||||
(mapconcat #'identity (append programs nil) " ")))))
|
||||
(let ((homepage (let ((h (azos/nixpkgs-g "package_homepage" package-data)))
|
||||
(when (vectorp h) (aref h 0)))))
|
||||
(when homepage
|
||||
(insert (format "\nHomepage: %s\n" homepage))))
|
||||
(let ((licenses (azos/nixpkgs-g "package_license" package-data)))
|
||||
(when (vectorp licenses)
|
||||
(insert (format "\nLicense: %s\n"
|
||||
(mapconcat (lambda (l)
|
||||
(or (azos/nixpkgs-g "fullName" l) ""))
|
||||
(append licenses nil) ", ")))))
|
||||
(insert (format "Package: %s\n\n" selected)
|
||||
"\nNo additional info available.")))
|
||||
(goto-char (point-min)))
|
||||
(display-buffer buf)))
|
||||
(message "No packages found matching '%s'" pattern))))
|
||||
|
||||
(define-key azos/global-minor-mode/open-keymap
|
||||
(kbd "n") 'azos/nixpkgs-search)
|
||||
#+end_src
|
||||
|
||||
* Provide
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
||||
Reference in New Issue
Block a user