branch: elpa/nix-mode
commit af35742d5574b0d5486e0753038bdddf2a0c9d14
Merge: 14322f186f 0fde15d938
Author: Matthew Justin Bauer <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #39 from purcell/master
Misc fixes
---
nix-company.el | 9 +++++----
nix-mode.el | 4 ++--
nix-prettify-mode.el | 4 ++--
nix-repl.el | 47 ++++++++++++++++++++++++-----------------------
nix-shell.el | 3 ++-
5 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/nix-company.el b/nix-company.el
index 19ca5cb617..9cc0648cf1 100644
--- a/nix-company.el
+++ b/nix-company.el
@@ -10,6 +10,7 @@
(require 'cl-lib)
(require 'company)
+;;;###autoload
(defun company-nix (command &optional arg &rest _)
"Company backend for Nix.
@@ -18,7 +19,7 @@ ARG company argument"
(interactive '(interactive))
(cl-case command
(interactive (company-begin-backend 'company-nix))
- (prefix (and (member major-mode '(nix-mode nix-repl-mode))
+ (prefix (and (derived-mode-p 'nix-mode 'nix-repl-mode)
(nix-grab-attr-path)))
(candidates
(nix-get-completions (get-buffer-process (nix--get-company-buffer)) arg))
@@ -29,9 +30,9 @@ ARG company argument"
(if (looking-at "[^a-zA-Z0-9'\\-_\\.]")
(buffer-substring (point) (save-excursion (skip-chars-backward
"a-zA-Z0-9'\\-_\\.")
(point)))
- (unless (and (char-after)
- (string-match "[a-zA-Z0-9'\\-_]" (char-to-string
(char-after)))
- ""))))
+ (and (char-after)
+ (string-match "[a-zA-Z0-9'\\-_]" (char-to-string (char-after)))
+ "")))
(defun nix--get-company-buffer (&optional buffer)
"Get the Nix repl buffer for company.
diff --git a/nix-mode.el b/nix-mode.el
index c3463b72b4..38a33d46c2 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -15,8 +15,8 @@
;;; Code:
-(require 'nix-format nil 'noerror)
-(require 'nix-shebang nil 'noerror)
+(require 'nix-format)
+(require 'nix-shebang)
(defgroup nix nil
"Nix-related customizations"
diff --git a/nix-prettify-mode.el b/nix-prettify-mode.el
index 0ae8f28099..5d78615b46 100644
--- a/nix-prettify-mode.el
+++ b/nix-prettify-mode.el
@@ -191,11 +191,11 @@ See `nix-prettify-special-modes' for details."
(nix-prettify-mode)))
;;;###autoload
-(define-globalized-minor-mode global-nix-prettify-mode
+(define-globalized-minor-mode nix-prettify-global-mode
nix-prettify-mode nix-prettify-turn-on)
;;;###autoload
-(defalias 'nix-prettify-global-mode 'global-nix-prettify-mode)
+(define-obsolete-function-alias 'global-nix-prettify-mode
'nix-prettify-global-mode)
(provide 'nix-prettify-mode)
diff --git a/nix-repl.el b/nix-repl.el
index 32a04101b4..ed2db6974e 100644
--- a/nix-repl.el
+++ b/nix-repl.el
@@ -15,7 +15,8 @@
:group 'nix)
(defcustom nix-repl-executable "nix-repl"
- "Location of nix-repl command.")
+ "Location of nix-repl command."
+ :type 'string)
(define-derived-mode nix-repl-mode comint-mode "Nix-REPL"
"Interactive prompt for Nix."
@@ -54,27 +55,27 @@
(nix--with-temp-process-filter proc
(goto-char (point-min))
(process-send-string proc (concat prefix
"\t\"" (nix--char-with-ctrl ?a) "\"\n"))
- (setq i 0)
- (while (and (< (setq i (1+ i)) 100)
- (not (search-forward-regexp
"\"\\([^\"]*\\)\"[\n]*nix-repl>" nil t)))
- (sleep-for 0.01))
- (let ((new-prefix (match-string 1))
- (start-compl (point)))
- (if (string-suffix-p " " new-prefix)
- (list (substring new-prefix 0 -1))
- (process-send-string proc (concat
new-prefix "\t\t" (nix--char-with-ctrl ?u) "\n"))
- (goto-char start-compl)
- (setq i 0)
- (while (and (< (setq i (1+ i)) 100)
- (not (search-forward-regexp
-
"[\n]+nix-repl>\\|Display all \\([0-9]+\\)" nil t)))
- (sleep-for 0.01))
- (if (match-string 1)
- (progn
- (process-send-string proc "n")
- '())
- (search-backward "\n" nil t)
- (split-string (buffer-substring
start-compl (1- (point))))))))))
+ (let ((i 0))
+ (while (and (< (setq i (1+ i)) 100)
+ (not (search-forward-regexp
"\"\\([^\"]*\\)\"[\n]*nix-repl>" nil t)))
+ (sleep-for 0.01))
+ (let ((new-prefix (match-string 1))
+ (start-compl (point)))
+ (if (string-suffix-p " " new-prefix)
+ (list (substring new-prefix 0 -1))
+ (process-send-string proc (concat
new-prefix "\t\t" (nix--char-with-ctrl ?u) "\n"))
+ (goto-char start-compl)
+ (setq i 0)
+ (while (and (< (setq i (1+ i)) 100)
+ (not
(search-forward-regexp
+
"[\n]+nix-repl>\\|Display all \\([0-9]+\\)" nil t)))
+ (sleep-for 0.01))
+ (if (match-string 1)
+ (progn
+ (process-send-string proc "n")
+ '())
+ (search-backward "\n" nil t)
+ (split-string (buffer-substring
start-compl (1- (point)))))))))))
(defun nix--send-repl (input &optional process mute)
"Send INPUT to PROCESS.
@@ -92,7 +93,7 @@ MUTE if true then don’t alert user."
(defun nix--process-filter (buf marker)
"Process filter for Nix-rel buffer BUF at MARKER."
- (lambda (proc string)
+ (lambda (_proc string)
(when (buffer-live-p buf)
(with-current-buffer buf
(save-excursion
diff --git a/nix-shell.el b/nix-shell.el
index 713b223fec..0177e6a07a 100644
--- a/nix-shell.el
+++ b/nix-shell.el
@@ -25,7 +25,8 @@
(defcustom nix-shell-executable "nix-shell"
"Location of nix-shell executable."
- :group 'nix-shell)
+ :group 'nix-shell
+ :type 'string)
;;;###autoload
(defun nix-shell (path attribute)