[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 84996a7804 158/500: Fix checkdoc errors.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 84996a7804 158/500: Fix checkdoc errors. |
Date: |
Sat, 29 Jan 2022 08:27:02 -0500 (EST) |
branch: elpa/nix-mode
commit 84996a780496ef9a1c7762b31c17642edeeb78f0
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Fix checkdoc errors.
---
nix-company.el | 11 ++++++-
nix-mode.el | 27 +++++++++++++----
nix-prettify-mode.el | 2 +-
nix-repl.el | 80 +++++++++++++++++++++++++++----------------------
tests/nix-mode-tests.el | 7 +++++
5 files changed, 83 insertions(+), 44 deletions(-)
diff --git a/nix-company.el b/nix-company.el
index a1b589abf5..f097acbe2b 100644
--- a/nix-company.el
+++ b/nix-company.el
@@ -9,7 +9,11 @@
(require 'nix-repl)
(require 'cl)
-(defun company-nix (command &optional arg &rest ignored)
+(defun company-nix (command &optional arg &rest _)
+ "Company backend for Nix.
+
+COMMAND company command
+ARG company argument"
(interactive '(interactive))
(case command
(interactive (company-begin-backend 'company-nix))
@@ -20,6 +24,7 @@
(sorted t)))
(defun nix-grab-attr-path ()
+ "Get Nix attribute path at point."
(if (looking-at "[^a-zA-Z0-9'\\-_\\.]")
(buffer-substring (point) (save-excursion (skip-chars-backward
"a-zA-Z0-9'\\-_\\.")
(point)))
@@ -28,6 +33,9 @@
""))))
(defun nix--get-company-buffer (&optional buffer)
+ "Get the Nix repl buffer for company.
+
+BUFFER check for Nix-REPL in current buffer"
(let* ((buf (or buffer (current-buffer)))
(repl-buf (get-buffer "*Nix-REPL*")))
(if (or (equal buf "*Nix-REPL*") (equal buf repl-buf))
@@ -38,6 +46,7 @@
(defvar nix--company-last-buffer nil)
(defun nix--get-company-backend-buffer (buffer)
+ "Get Nix company backend from BUFFER."
(let* ((buf-file (buffer-file-name buffer))
(backend-buf (get-buffer-create nix-company-backend-buffer-name))
(last-buf nix--company-last-buffer)
diff --git a/nix-mode.el b/nix-mode.el
index a2c4e2bd2b..97162fd237 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -126,27 +126,36 @@
t))))))))
(defun nix--mark-string (pos string-type)
+ "Mark string as a Nix string.
+
+POS position of start of string
+STRING-TYPE type of string based off of Emacs syntax table types"
(put-text-property pos (1+ pos)
'syntax-table (string-to-syntax "|"))
(put-text-property pos (1+ pos)
'nix-string-type string-type))
(defun nix--get-parse-state (pos)
+ "Get the result of `syntax-ppss' at POS."
(save-excursion (save-match-data (syntax-ppss pos))))
(defun nix--get-string-type (parse-state)
+ "Get the type of string based on PARSE-STATE."
(let ((string-start (nth 8 parse-state)))
(and string-start (get-text-property string-start 'nix-string-type))))
(defun nix--open-brace-string-type (parse-state)
+ "Determine if this is an open brace string type based on PARSE-STATE."
(let ((open-brace (nth 1 parse-state)))
(and open-brace (get-text-property open-brace 'nix-string-type))))
(defun nix--open-brace-antiquote-p (parse-state)
+ "Determine if this is an open brace antiquote based on PARSE-STATE."
(let ((open-brace (nth 1 parse-state)))
(and open-brace (get-text-property open-brace 'nix-syntax-antiquote))))
(defun nix--single-quotes ()
+ "Handle Nix single quotes."
(let* ((start (match-beginning 0))
(end (match-end 0))
(context (nix--get-parse-state start))
@@ -166,6 +175,7 @@
(nix--mark-string (1- end) ?\')))))))
(defun nix--escaped-antiquote-dq-style ()
+ "Handle Nix escaped antiquote dq style."
(let* ((start (match-beginning 0))
(ps (nix--get-parse-state start))
(string-type (nix--get-string-type ps)))
@@ -173,6 +183,7 @@
(nix--antiquote-open-at (1+ start) ?\'))))
(defun nix--double-quotes ()
+ "Handle Nix double quotes."
(let* ((pos (match-beginning 0))
(ps (nix--get-parse-state pos))
(string-type (nix--get-string-type ps)))
@@ -180,14 +191,16 @@
(nix--mark-string pos ?\"))))
(defun nix--antiquote-open-at (pos string-type)
- (put-text-property pos (1+ pos)
- 'syntax-table (string-to-syntax "|"))
- (put-text-property pos (+ 2 pos)
- 'nix-string-type string-type)
- (put-text-property (1+ pos) (+ 2 pos)
- 'nix-syntax-antiquote t))
+ "Handle Nix antiquote open at based on POS and STRING-TYPE."
+ (put-text-property pos (1+ pos)
+ 'syntax-table (string-to-syntax "|"))
+ (put-text-property pos (+ 2 pos)
+ 'nix-string-type string-type)
+ (put-text-property (1+ pos) (+ 2 pos)
+ 'nix-syntax-antiquote t))
(defun nix--antiquote-open ()
+ "Handle Nix antiquote open."
(let* ((start (match-beginning 0))
(ps (nix--get-parse-state start))
(string-type (nix--get-string-type ps)))
@@ -195,6 +208,7 @@
(nix--antiquote-open-at start string-type))))
(defun nix--antiquote-close-open ()
+ "Handle Nix antiquote close then open."
(let* ((start (match-beginning 0))
(ps (nix--get-parse-state start))
(string-type (nix--get-string-type ps)))
@@ -210,6 +224,7 @@
'nix-syntax-antiquote t))))))
(defun nix--antiquote-close ()
+ "Handle Nix antiquote close."
(let* ((start (match-beginning 0))
(ps (nix--get-parse-state start)))
(unless (nix--get-string-type ps)
diff --git a/nix-prettify-mode.el b/nix-prettify-mode.el
index 3d17670e72..0ae8f28099 100644
--- a/nix-prettify-mode.el
+++ b/nix-prettify-mode.el
@@ -62,7 +62,7 @@ removed only from strings matching `nix-prettify-regexp', so
that compositions created by other modes are left untouched.
Set this variable to non-nil, if you want to remove any
-composition unconditionally (like `prettify-symbols-mode' does).
+composition unconditionally (like variable `prettify-symbols-mode' does).
Most likely it will do no harm and will make the process of
disabling `nix-prettify-mode' a little faster."
:type 'boolean
diff --git a/nix-repl.el b/nix-repl.el
index 40d7c41d4a..32a04101b4 100644
--- a/nix-repl.el
+++ b/nix-repl.el
@@ -22,6 +22,19 @@
(setq-local comint-prompt-regexp nix-prompt-regexp)
(setq-local comint-prompt-read-only t))
+(defmacro nix--with-temp-process-filter (proc &rest body)
+ "Use temp process PROC filter on BODY."
+ (declare (indent defun))
+ `(let* ((buf (generate-new-buffer " *temp-process-output*"))
+ (proc-filter-saved (process-filter ,proc))
+ (proc-marker (with-current-buffer buf (point-marker))))
+ (set-process-filter ,proc (nix--process-filter buf proc-marker))
+ (unwind-protect
+ (with-current-buffer buf
+ ,@body)
+ (set-process-filter ,proc proc-filter-saved)
+ (kill-buffer buf))))
+
(defun nix-repl-show ()
"Load the Nix-REPL."
(interactive)
@@ -32,58 +45,53 @@
(nix-repl-mode)))
(defun nix--make-repl-in-buffer (buffer)
+ "Make Nix Repl in BUFFER."
(make-comint-in-buffer "Nix-REPL" buffer nix-repl-executable))
(defun nix-get-completions (proc prefix)
+ "Get Nix completions from Nix-repl process PROC and based off of PREFIX."
(save-match-data
(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))))))))))
+ (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))))))))))
(defun nix--send-repl (input &optional process mute)
+ "Send INPUT to PROCESS.
+
+MUTE if true then don’t alert user."
(let ((proc (or process (get-buffer-process (current-buffer)))))
(if mute
(nix--with-temp-process-filter proc
- (process-send-string proc input))
+ (process-send-string proc input))
(process-send-string proc input))))
(defun nix--char-with-ctrl (char)
+ "Generate control character CHAR."
(char-to-string (logand #b10011111 char)))
-(defmacro nix--with-temp-process-filter (proc &rest body)
- (declare (indent defun))
- `(let* ((buf (generate-new-buffer " *temp-process-output*"))
- (proc-filter-saved (process-filter ,proc))
- (proc-marker (with-current-buffer buf (point-marker))))
- (set-process-filter ,proc (nix--process-filter buf proc-marker))
- (unwind-protect
- (with-current-buffer buf
- ,@body)
- (set-process-filter ,proc proc-filter-saved)
- (kill-buffer buf))))
-
(defun nix--process-filter (buf marker)
+ "Process filter for Nix-rel buffer BUF at MARKER."
(lambda (proc string)
(when (buffer-live-p buf)
(with-current-buffer buf
diff --git a/tests/nix-mode-tests.el b/tests/nix-mode-tests.el
index 3c004bb1a6..d92a02fef5 100644
--- a/tests/nix-mode-tests.el
+++ b/tests/nix-mode-tests.el
@@ -1,3 +1,9 @@
+;;; nix-mode-tests.el -- test nix-mode
+
+;;; Commentary:
+
+;;; Code:
+
(require 'ert)
(require 'nix-mode)
@@ -21,3 +27,4 @@
(eq (nix--get-string-type (nix--get-parse-state (point))) nil))))
(provide 'nix-mode-tests)
+;;; nix-mode-tests.el ends here
- [nongnu] elpa/nix-mode da7e6de79a 139/500: Move some unpolished elisp to "misc" folder., (continued)
- [nongnu] elpa/nix-mode da7e6de79a 139/500: Move some unpolished elisp to "misc" folder., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 55b0ea2d96 132/500: Merge pull request #18 from matthewbauer/more-modes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d9c1d4d4a4 152/500: Remove maintained modes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 594b979c91 140/500: Missed one, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d1650d795c 151/500: Cleanup documentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode be839f971b 157/500: Use nix-mode-mmm when mmm-mode is available, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a1860c6bde 144/500: Handle projectile projects, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 50470960c6 154/500: Don’t require nix-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ccf4c9ad64 164/500: Update URLs to this repository, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode bd7d93998f 163/500: Fix some grammar issues in README, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 84996a7804 158/500: Fix checkdoc errors.,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 14322f186f 189/500: Use locate-library instead of find-library, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a3eb135716 492/500: nix-flake: Fix miscomparison to avoid repeatedly adding to registry, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2a24b400b6 485/500: chore: Bump install-nix-action to v14.1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ce7996c6e7 476/500: nix-flake: Cosmetics, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3d4f24b2b6 472/500: nix-flake: Allow switching the flake inside nix-flake-dispatch, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 5fb9df6f69 497/500: chore(deps): bump cachix/install-nix-action from 14.1 to 16, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 687665a6b0 001/500: Initial commit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e6b9f1b939 016/500: Add menu bar., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ae68b456f8 022/500: Refactor font lock, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7b47e2b4bc 042/500: Fix formatting., ELPA Syncer, 2022/01/29