diff --git a/.circleci/config.yml b/.circleci/config.yml index def610ed..cb2679f8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,56 +1,131 @@ version: 2.1 -# Default actions to perform on each Emacs version -default: &default-steps - steps: - - checkout - - run: apt-get update && apt-get install make - - run: make elpa - - run: emacs --version - - run: make test - # Make sure to run test-checks before test-bytecomp, as test-bytecomp autogenerates - # files which won't pass test-checks. - - run: make test-checks - - run: make test-bytecomp +orbs: + win: circleci/windows@2.2.0 + +commands: + setup: + steps: + - checkout + - run: + name: Install Eldev + command: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/circle-eldev > x.sh && source ./x.sh + + setup-macos: + steps: + - checkout + - run: + name: Install Emacs latest + command: | + brew install homebrew/cask/emacs + - run: + name: Install Eldev + command: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/circle-eldev > x.sh && source ./x.sh + + setup-windows: + steps: + - checkout + - run: + name: Install Eldev + command: | + # Remove expired DST Root CA X3 certificate. Workaround + # for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51038 + # bug on Emacs 27.2. + gci cert:\LocalMachine\Root\DAC9024F54D8F6DF94935FB1732638CA6AD77C13 + gci cert:\LocalMachine\Root\DAC9024F54D8F6DF94935FB1732638CA6AD77C13 | Remove-Item + (iwr https://raw.github.com/doublep/eldev/master/webinstall/circle-eldev.ps1).Content | powershell -command - + test: + steps: + - run: + name: Run regression tests + command: eldev -dtT -p test + lint: + steps: + - run: + name: Lint + command: eldev lint -c + compile: + steps: + - run: + name: Check for byte-compilation errors + command: eldev -dtT compile --warnings-as-errors -# Enumerated list of Emacs versions jobs: - test-emacs-25: + test-ubuntu-emacs-26: docker: - - image: silex/emacs:25-ci-cask + - image: silex/emacs:26-ci entrypoint: bash - <<: *default-steps - - test-emacs-26: + steps: + - setup + - test + - lint + - compile + test-ubuntu-emacs-27: docker: - - image: silex/emacs:26-ci-cask + - image: silex/emacs:27-ci entrypoint: bash - <<: *default-steps - - test-emacs-27: + steps: + - setup + - test + - lint + - compile + test-ubuntu-emacs-28: docker: - - image: silex/emacs:27-ci-cask + - image: silex/emacs:28-ci entrypoint: bash - <<: *default-steps - - test-emacs-28: + steps: + - setup + - test + - lint + - compile + test-ubuntu-emacs-29: docker: - - image: silex/emacs:28-ci-cask + - image: silex/emacs:29-ci entrypoint: bash - <<: *default-steps - - test-emacs-master: + steps: + - setup + - test + - lint + - compile + test-ubuntu-emacs-master: docker: - - image: silex/emacs:master-ci-cask + - image: silex/emacs:master-ci entrypoint: bash - <<: *default-steps + steps: + - setup + - test + - lint + - compile + test-macos-emacs-latest: + macos: + xcode: "14.2.0" + steps: + - setup-macos + - test + - lint + - compile + test-windows-emacs-latest: + executor: win/default + steps: + - run: + name: Install Emacs latest + command: | + choco install emacs + - setup-windows + - test + - lint + - compile workflows: - version: 2 + version: 2.1 ci-test-matrix: jobs: - - test-emacs-25 - - test-emacs-26 - - test-emacs-27 - - test-emacs-28 - - test-emacs-master + - test-ubuntu-emacs-26 + - test-ubuntu-emacs-27 + - test-ubuntu-emacs-28 + - test-ubuntu-emacs-29 + - test-ubuntu-emacs-master + - test-windows-emacs-latest + - test-macos-emacs-latest: + requires: + - test-ubuntu-emacs-29 diff --git a/.gitignore b/.gitignore index ef07d5a4..360a9941 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ elpa* /clojure-mode-autoloads.el /clojure-mode-pkg.el + +/.eldev +/Eldev-local diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2743702a..2eada5b9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,8 +39,8 @@ and description in grammatically correct, complete sentences. ## Development setup 1. Fork and clone the repository. -1. Install [Cask][7]. -1. Run `cask install` in the repository folder. +1. Install [Eldev][7]. +1. Run `eldev build` in the repository folder. 1. Run tests with `make test`. **Note:** macOS users should make sure that the `emacs` command resolves the version of Emacs they've installed @@ -53,5 +53,5 @@ See [this article][8] for more details. [4]: https://help.github.com/articles/using-pull-requests [5]: https://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html [6]: https://github.com/clojure-emacs/clojure-mode/blob/master/CHANGELOG.md -[7]: https://github.com/cask/cask +[7]: https://github.com/emacs-eldev/eldev [8]: https://emacsredux.com/blog/2015/05/09/emacs-on-os-x/ diff --git a/Cask b/Cask deleted file mode 100644 index abcd75fd..00000000 --- a/Cask +++ /dev/null @@ -1,9 +0,0 @@ -(source gnu) -(source melpa) - -(package-file "clojure-mode.el") - -(development - (depends-on "s") - (depends-on "buttercup") - (depends-on "paredit")) diff --git a/Eldev b/Eldev new file mode 100644 index 00000000..1becee18 --- /dev/null +++ b/Eldev @@ -0,0 +1,26 @@ +; -*- mode: emacs-lisp; lexical-binding: t -*- + +(eldev-require-version "1.6") + +(eldev-use-package-archive 'gnu-elpa) +(eldev-use-package-archive 'nongnu-elpa) +(eldev-use-package-archive 'melpa) + +(eldev-use-plugin 'autoloads) + +(eldev-add-extra-dependencies 'test 'paredit 's 'buttercup) + +(setq byte-compile-docstring-max-column 240) +(setq checkdoc-force-docstrings-flag nil) +(setq checkdoc-permit-comma-termination-flag t) +(setq checkdoc--interactive-docstring-flag nil) + +(setf eldev-lint-default '(elisp)) + +(with-eval-after-load 'elisp-lint + ;; We will byte-compile with Eldev. + (setf elisp-lint-ignored-validators '("package-lint" "fill-column" "byte-compile" "checkdoc") + enable-local-variables :safe + elisp-lint-indent-specs '((define-clojure-indent . 0)))) + +(setq eldev-project-main-file "clojure-mode.el") diff --git a/Makefile b/Makefile index 27503963..3e613538 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,17 @@ -CASK = cask -export EMACS ?= emacs -EMACSFLAGS = - -PKGDIR := $(shell EMACS=$(EMACS) $(CASK) package-directory) - -SRCS = $(wildcard *.el) -OBJS = $(SRCS:.el=.elc) - -.PHONY: compile test clean elpa - -all: compile - -elpa-$(EMACS): - $(CASK) install - $(CASK) update - touch $@ - -elpa: elpa-$(EMACS) - -elpaclean: - rm -f elpa* - rm -rf .cask # Clean packages installed for development - -compile: elpa - $(CASK) build +.PHONY: clean compile lint test all +.DEFAULT_GOAL := all clean: - rm -f $(OBJS) clojure-mode-autoloads.el + eldev clean -test: $(PKGDIR) - $(CASK) exec buttercup +lint: clean + eldev lint -c -test-checks: - $(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \ - -l test/test-checks.el ./ +# Checks for byte-compilation warnings. +compile: clean + eldev -dtT compile --warnings-as-errors -test-bytecomp: $(SRCS:.el=.elc-test) +test: clean + eldev -dtT -p test -%.elc-test: %.el elpa - $(CASK) exec $(EMACS) --no-site-file --no-site-lisp --batch \ - -l test/clojure-mode-bytecomp-warnings.el $< +all: clean compile lint test diff --git a/clojure-mode.el b/clojure-mode.el index 8dda5553..e3d554de 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -3129,7 +3129,7 @@ Assumes cursor is at beginning of function." "Add an arity to a function. Assumes cursor is at beginning of function." - (let ((beg-line (what-line)) + (let ((beg-line (line-number-at-pos)) (end (save-excursion (forward-sexp) (point)))) (down-list 2) @@ -3141,7 +3141,7 @@ Assumes cursor is at beginning of function." (insert "[") (save-excursion (insert "])\n("))) ((looking-back "\\[" 1) ;; single-arity fn - (let* ((same-line (string= beg-line (what-line))) + (let* ((same-line (= beg-line (line-number-at-pos))) (new-arity-text (concat (when same-line "\n") "(["))) (save-excursion (goto-char end) diff --git a/test/clojure-mode-bytecomp-warnings.el b/test/clojure-mode-bytecomp-warnings.el deleted file mode 100644 index 41b3230d..00000000 --- a/test/clojure-mode-bytecomp-warnings.el +++ /dev/null @@ -1,40 +0,0 @@ -;;; clojure-mode-bytecomp-warnings.el --- Check for byte-compilation problems -*- lexical-binding: t; -*- - -;; Copyright © 2012-2021 Bozhidar Batsov and contributors -;; -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;; This file is not part of GNU Emacs. - -;;; Commentary: - -;; This is a script to be loaded while visiting a `clojure-mode' source file. -;; It will prepare all requirements and then byte-compile the file and signal an -;; error on any warning. For example: -;; -;; emacs -Q --batch -l test/clojure-mode-bytecomp-warnings.el clojure-mode.el - -;; This assumes that all `clojure-mode' dependencies are already on the package -;; dir (probably from running `cask install'). - -(setq load-prefer-newer t) -(add-to-list 'load-path (expand-file-name "./")) -(require 'package) -(package-generate-autoloads 'clojure-mode default-directory) -(package-initialize) -(load-file "clojure-mode-autoloads.el") -(setq byte-compile-error-on-warn t) -(batch-byte-compile) - -;;; clojure-mode-bytecomp-warnings.el ends here diff --git a/test/clojure-mode-convert-collection-test.el b/test/clojure-mode-convert-collection-test.el index 28c5977e..14e52915 100644 --- a/test/clojure-mode-convert-collection-test.el +++ b/test/clojure-mode-convert-collection-test.el @@ -27,6 +27,7 @@ (require 'clojure-mode) (require 'buttercup) +(require 'test-helper "test/utils/test-helper") (describe "clojure-convert-collection-to-map" (when-refactoring-it "should convert a list to a map" diff --git a/test/clojure-mode-refactor-add-arity-test.el b/test/clojure-mode-refactor-add-arity-test.el index 9c75f128..5f1c5fb9 100644 --- a/test/clojure-mode-refactor-add-arity-test.el +++ b/test/clojure-mode-refactor-add-arity-test.el @@ -24,6 +24,7 @@ (require 'clojure-mode) (require 'buttercup) +(require 'test-helper "test/utils/test-helper") (describe "clojure-add-arity" diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index 565773d4..6157a3d0 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -46,7 +46,7 @@ (bb-edn-src (expand-file-name "src" temp-dir))) (write-region "{}" nil bb-edn) (make-directory bb-edn-src) - (expect (clojure-project-dir bb-edn-src) + (expect (expand-file-name (clojure-project-dir bb-edn-src)) :to-equal (file-name-as-directory temp-dir)))))) (describe "clojure-project-relative-path" diff --git a/test/test-checks.el b/test/test-checks.el deleted file mode 100644 index a4b4208f..00000000 --- a/test/test-checks.el +++ /dev/null @@ -1,30 +0,0 @@ -;; This is a script to be loaded from the root `clojure-mode' directory. It will -*- lexical-binding: t; -*- -;; prepare all requirements and then run `check-declare-directory' on -;; `default-directory'. For example: emacs -Q --batch -l test/test-checkdoc.el - -;; This assumes that all `clojure-mode' dependencies are already on the package -;; dir (probably from running `cask install'). - -(add-to-list 'load-path (expand-file-name "./")) -(require 'package) -(require 'check-declare) -(package-initialize) - -;; disable some annoying (or non-applicable) checkdoc checks -(setq checkdoc-package-keywords-flag nil) -(setq checkdoc-arguments-in-order-flag nil) -(setq checkdoc-verb-check-experimental-flag nil) - -(let ((files (directory-files default-directory t - "\\`[^.].*\\.el\\'" t))) - - ;; `checkdoc-file' was introduced in Emacs 25 - (when (fboundp 'checkdoc-file) - (dolist (file files) - (checkdoc-file file)) - (when (get-buffer "*Warnings*") - (message "Failing due to checkdoc warnings...") - (kill-emacs 1))) - - (when (apply #'check-declare-files files) - (kill-emacs 1))) diff --git a/test/utils/test-helper.el b/test/utils/test-helper.el index b359277c..e7894f04 100644 --- a/test/utils/test-helper.el +++ b/test/utils/test-helper.el @@ -26,7 +26,7 @@ (message "Running tests on Emacs %s" emacs-version) (let* ((current-file (if load-in-progress load-file-name (buffer-file-name))) - (source-directory (locate-dominating-file current-file "Cask")) + (source-directory (locate-dominating-file current-file "Eldev")) ;; Do not load outdated byte code for tests (load-prefer-newer t)) ;; Load the file under test