tvl-depot/configs/shared/emacs/.emacs.d/elpa/nix-mode-20180908.2240/nix-drv-mode.el
William Carroll 9da3ffee41 Update Emacs packages
This is a massive diff that I had to do in a hurry - when leaving
Urbint. I'm pretty sure that most of these are updating Emacs packages,
but I'm not positive.
2018-10-02 09:54:39 -04:00

48 lines
1.3 KiB
EmacsLisp
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; nix-drv-mode.el --- Major mode for viewing .drv files
;; Maintainer: Matthew Bauer <mjbauer95@gmail.com>
;; Homepage: https://github.com/NixOS/nix-mode
;; Version: 1.2.1
;; Keywords: nix, languages, tools, unix
;; Package-Requires: ((emacs "24.3"))
;; This file is NOT part of GNU Emacs.
;;; Commentary:
;; A major mode for viewing Nix derivations (.drv files). See the Nix
;; manual for more information available at
;; https://nixos.org/nix/manual/.
;;; Code:
(require 'json-mode)
(require 'nix)
(defvar-local nix-drv-mode nil)
;;;###autoload
(defun nix-drv-mode ()
"Pretty print Nixs .drv files."
(interactive)
(when (string-match (format "^%s/" nix-store-dir) (buffer-file-name))
(if nix-drv-mode
(progn
(erase-buffer)
(insert-file-contents (buffer-file-name))
(setq nix-drv-mode nil)
(set-buffer-modified-p nil)
(read-only-mode nil))
(let ((inhibit-read-only t))
(setq nix-drv-mode t)
(erase-buffer)
(insert (shell-command-to-string
(format "%s show-derivation \"%s\""
nix-executable
(buffer-file-name))))
(json-mode)
(set-buffer-modified-p nil)
(read-only-mode 1)))))
(provide 'nix-drv-mode)
;;; nix-drv-mode.el ends here