Klimi's new dotfiles with stow.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

38 wiersze
1.0 KiB

4 lat temu
  1. ;;; nix-edit.el -- run nix commands in Emacs -*- lexical-binding: t -*-
  2. ;; Author: Matthew Bauer <mjbauer95@gmail.com>
  3. ;; Homepage: https://github.com/NixOS/nix-mode
  4. ;; Keywords: nix
  5. ;; Version: 1.4.0
  6. ;; This file is NOT part of GNU Emacs.
  7. ;;; Commentary:
  8. ;;; Code:
  9. (require 'nix)
  10. (require 'nix-search)
  11. (defun nix-edit (&optional file attr)
  12. "Open the nix log.
  13. FILE the nix file to load from.
  14. ATTR the attribute to find in nix expressions."
  15. (interactive (list (nix-read-file) nil))
  16. (unless attr (setq attr (nix-read-attr file)))
  17. (let ((stdout (generate-new-buffer "nix-edit"))
  18. (process-environment (cons "EDITOR=echo" process-environment))
  19. result)
  20. (call-process nix-executable nil (list stdout nil) nil
  21. "edit" "-f" file attr)
  22. (with-current-buffer stdout
  23. (when (eq (buffer-size) 0)
  24. (error
  25. "Error: nix edit failed to produce any output"))
  26. (setq result (substring (buffer-string) 0 (- (buffer-size) 1))))
  27. (kill-buffer stdout)
  28. (find-file result)))
  29. (provide 'nix-edit)
  30. ;;; nix-edit.el ends here