X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/dcf0481c7b91816815e6aa95c24915289d286bbd..8dd28885e9e27463ed358d977a58eb3511b0d17c:/packages/adjust-parens/adjust-parens-tests.el diff --git a/packages/adjust-parens/adjust-parens-tests.el b/packages/adjust-parens/adjust-parens-tests.el index 5b249c5d2..9909d76d7 100644 --- a/packages/adjust-parens/adjust-parens-tests.el +++ b/packages/adjust-parens/adjust-parens-tests.el @@ -32,9 +32,23 @@ (buffer-substring-no-properties (point) (point-max))))) +(ert-deftest apt-mode-test () + (with-temp-buffer + (emacs-lisp-mode) + (adjust-parens-mode -1) + (should-not (eq (key-binding (kbd "TAB")) + #'lisp-indent-adjust-parens)) + (adjust-parens-mode 1) + (should (eq (key-binding (kbd "TAB")) + #'lisp-indent-adjust-parens)) + (adjust-parens-mode -1) + (should-not (eq (key-binding (kbd "TAB")) + #'lisp-indent-adjust-parens)))) + (ert-deftest apt-near-bob-test () (with-temp-buffer (emacs-lisp-mode) + (adjust-parens-mode 1) (insert "(foo)\n") (lisp-indent-adjust-parens) (apt-check-buffer "(foo\n " ")"))) @@ -42,11 +56,12 @@ (ert-deftest apt-indent-dedent-test () (with-temp-buffer (emacs-lisp-mode) + (adjust-parens-mode 1) (setq indent-tabs-mode nil) (insert ";;\n" "(let ((x 10) (y (some-func 20))))\n" "; Comment") - (beginning-of-line) + (back-to-indentation) (lisp-indent-adjust-parens) (apt-check-buffer (concat ";;\n" "(let ((x 10) (y (some-func 20)))\n" @@ -61,6 +76,32 @@ (apt-check-buffer (concat ";;\n" "(let ((x 10) (y (some-func 20))\n" " ") - ")); Comment"))) + ")); Comment") + ;; Check what happens when point is not at the indentation, or + ;; indentation is not correct, or both + (beginning-of-line) ; Point not at indentation + ;; Should simply move point to indentation and not change buffer + (lisp-indent-adjust-parens) + (apt-check-buffer (concat ";;\n" + "(let ((x 10) (y (some-func 20))\n" + " ") + ")); Comment") + + (delete-backward-char 3) ; Incorrect indentation + ;; Should reindent line via indent-for-tab-command and move point to + ;; indentation but not change parens + (lisp-indent-adjust-parens) + (apt-check-buffer (concat ";;\n" + "(let ((x 10) (y (some-func 20))\n" + " ") + ")); Comment") + (insert " ") ; Wrong indentation + (forward-char 2) ; Point is past indentation + ;; Should reindent line without moving point or changing parens + (lisp-indent-adjust-parens) + (apt-check-buffer (concat ";;\n" + "(let ((x 10) (y (some-func 20))\n" + " ))") + "; Comment"))) ;;; adjust-parens-tests.el ends here