diff options
author | Helmut Eller <eller.helmut@gmail.com> | 2023-08-03 08:33:40 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-08-08 18:23:00 +0200 |
commit | 3e79fd3d4e810c2ef4cf9925a747c93e036fddca (patch) | |
tree | a978150f0fbeca9823e3d89d54ea1886558cef65 /test/lisp/emacs-lisp | |
parent | efb3ef0fe07a1fe8c713921ceba74f476c8aa40b (diff) | |
download | emacs-3e79fd3d4e810c2ef4cf9925a747c93e036fddca.tar.gz emacs-3e79fd3d4e810c2ef4cf9925a747c93e036fddca.tar.bz2 emacs-3e79fd3d4e810c2ef4cf9925a747c93e036fddca.zip |
Check keyword args of make-process
The functions make-process and make-network-process have many
keyword args and it's easy to misspell some of them.
Use a compiler macro to warn about some possible mistakes.
* lisp/emacs-lisp/bytecomp.el (bytecomp--check-keyword-args): New
helper.
(make-process, make-network-process): Define a compiler macro that
performs some checks but doesn't anything else.
* test/lisp/emacs-lisp/bytecomp-tests.el: Add some tests.
* test/lisp/emacs-lisp/bytecomp-resources/:
(warn-make-process-missing-keyword-arg.el,
warn-make-process-missing-keyword-value.el,
warn-make-process-repeated-keyword-arg.el,
warn-make-process-unknown-keyword-arg.el): New test files
Diffstat (limited to 'test/lisp/emacs-lisp')
5 files changed, 29 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-missing-keyword-arg.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-missing-keyword-arg.el new file mode 100644 index 00000000000..9369e78ff54 --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-missing-keyword-arg.el @@ -0,0 +1,3 @@ +;;; -*- lexical-binding: t -*- +(defun foo () + (make-process :name "ls")) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-missing-keyword-value.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-missing-keyword-value.el new file mode 100644 index 00000000000..4226349afef --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-missing-keyword-value.el @@ -0,0 +1,3 @@ +;;; -*- lexical-binding: t -*- +(defun foo () + (make-process :name "ls" :command)) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-repeated-keyword-arg.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-repeated-keyword-arg.el new file mode 100644 index 00000000000..18250f14ee9 --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-repeated-keyword-arg.el @@ -0,0 +1,3 @@ +;;; -*- lexical-binding: t -*- +(defun foo () + (make-process :name "ls" :command "ls" :name "ls")) diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-unknown-keyword-arg.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-unknown-keyword-arg.el new file mode 100644 index 00000000000..4721035780b --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-make-process-unknown-keyword-arg.el @@ -0,0 +1,4 @@ +;;; -*- lexical-binding: t -*- +(defun foo () + (make-process :name "ls" :command "ls" + :coding-system 'binary)) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 19e08e8d199..26325c1ef11 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -1204,6 +1204,22 @@ byte-compiled. Run with dynamic binding." "nowarn-inline-after-defvar.el" "Lexical argument shadows" 'reverse) +(bytecomp--define-warning-file-test + "warn-make-process-missing-keyword-arg.el" + "called without required keyword argument :command") + +(bytecomp--define-warning-file-test + "warn-make-process-unknown-keyword-arg.el" + "called with unknown keyword argument :coding-system") + +(bytecomp--define-warning-file-test + "warn-make-process-repeated-keyword-arg.el" + "called with repeated keyword argument :name") + +(bytecomp--define-warning-file-test + "warn-make-process-missing-keyword-value.el" + "missing value for keyword argument :command") + ;;;; Macro expansion. |