From 483a7caf0f0cc29f9aefdb991d04c17338ac8c60 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 14 Apr 2020 15:37:11 -0400 Subject: [PATCH] Fix (cached-)nix-shell interpreter-mode-alist entries By combining them. Also emit a more helpful message if the sub-interpreter cannot be read. --- modules/lang/nix/autoload.el | 3 ++- modules/lang/nix/config.el | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/lang/nix/autoload.el b/modules/lang/nix/autoload.el index d0f950569..69abe8978 100644 --- a/modules/lang/nix/autoload.el +++ b/modules/lang/nix/autoload.el @@ -46,7 +46,8 @@ (save-excursion (goto-char (point-min)) (save-match-data - (when (re-search-forward "#! *\\(?:cached-\\)?nix-shell +-i +\\([^ \n]+\\)" 256 t) + (if (not (re-search-forward "#! *\\(?:cached-\\)?nix-shell +-i +\\([^ \n]+\\)" 256 t)) + (message "Couldn't determine mode for this script") (let* ((interp (match-string 1)) (mode (assoc-default diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index f8c0a0a5e..02d5ef0f6 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -1,8 +1,7 @@ ;;; lang/nix/config.el -*- lexical-binding: t; -*- (use-package! nix-mode - :interpreter ("cached-nix-shell" . +nix-shell-init-mode) - :interpreter ("nix-shell" . +nix-shell-init-mode) + :interpreter ("\\(?:cached-\\)?nix-shell" . +nix-shell-init-mode) :mode "\\.nix\\'" :config (set-company-backend! 'nix-mode 'company-nixos-options)