branch: elpa/swift-mode commit 19d909be4279faaea6d31234874f583c09377ebe Author: taku0 <mxxouy6x3m_git...@tatapa.org> Commit: taku0 <mxxouy6x3m_git...@tatapa.org>
Migrate to Eldev Fix warnings from linters. --- .dir-locals.el | 13 +++--- .github/workflows/run-test.yml | 35 +++++++++++++++ .gitignore | 2 +- .travis.yml | 31 ------------- Cask | 4 -- Eldev | 64 ++++++++++++++++++++++++++ Makefile | 48 +++++++++----------- README.md | 6 +-- scripts/invoke_eldev.sh | 19 ++++++++ scripts/run_test.sh | 15 +++++++ scripts/test_in_docker.sh | 18 ++++++++ swift-mode-beginning-of-defun.el | 10 ++--- swift-mode-font-lock.el | 24 +++++----- swift-mode-imenu.el | 11 ++--- swift-mode-indent.el | 14 +++--- swift-mode-lexer.el | 62 ++++++++++++------------- swift-mode-repl.el | 72 ++++++++++++++++-------------- swift-mode-standard-types.el | 4 -- swift-mode.el | 6 ++- test/swift-mode-test-beginning-of-defun.el | 5 --- test/swift-mode-test-imenu.el | 5 --- test/swift-mode-test-indent.el | 5 --- test/swift-mode-test.el | 5 --- 23 files changed, 282 insertions(+), 196 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 9d000e5..b8fa683 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,6 +1,7 @@ -((emacs-lisp-mode - (eval . (checkdoc-minor-mode)) - (indent-tabs-mode . nil) - (fill-column . 80) - (sentence-end-double-space . t) - (emacs-lisp-docstring-fill-column . 75))) +((emacs-lisp-mode . ((package-lint-main-file . "swift-mode.el") + (eval . (checkdoc-minor-mode)) + (indent-tabs-mode . nil) + (fill-column . 80) + (tab-width . 8) + (sentence-end-double-space . t) + (emacs-lisp-docstring-fill-column . 75)))) diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml new file mode 100644 index 0000000..5089607 --- /dev/null +++ b/.github/workflows/run-test.yml @@ -0,0 +1,35 @@ +name: Run Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + continue-on-error: ${{matrix.emacs_version == 'snapshot'}} + + strategy: + matrix: + version: ['24.4', '24.5', '25.1', '25.2', '25.3', '26.1', '26.2', '26.3', '27.1', 'snapshot'] + + env: + ELDEV_DIR: .eldev + ELDEV: .eldev/bin/eldev + + steps: + - uses: actions/checkout@v2 + - uses: purcell/setup-emacs@master + with: + version: ${{ matrix.version }} + - name: Install Eldev + run: | + mkdir -p $ELDEV_DIR/bin + curl -fsSL https://raw.github.com/doublep/eldev/master/bin/eldev > $ELDEV_DIR/bin/eldev + chmod a+x $ELDEV_DIR/bin/eldev + - name: Run linters + run: find ./*.el test/*.el '!' -name '*autoloads.el' -exec ${ELDEV} lint '{}' '+' + - name: Run tests + run: ./scripts/run_test.sh diff --git a/.gitignore b/.gitignore index f613485..b8693b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *~ -/.cask/ +/.eldev/ *.elc /dist/ swift-mode-autoloads.el diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a5f417a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: generic -sudo: false - -env: - - EVM_EMACS=emacs-24.4-travis - - EVM_EMACS=emacs-24.5-travis - - EVM_EMACS=emacs-25.1-travis - - EVM_EMACS=emacs-25.2-travis - - EVM_EMACS=emacs-25.3-travis - - EVM_EMACS=emacs-26.1-travis-linux-xenial - - EVM_EMACS=emacs-26.2-travis-linux-xenial - - EVM_EMACS=emacs-26.3-travis-linux-xenial - -before_install: - - curl -fsSkL https://raw.github.com/rejeep/evm/master/go | bash - - export PATH="/home/travis/.evm/bin:$PATH" - - evm config path /tmp - - evm install $EVM_EMACS --skip --use - - export EMACS=$(evm bin) - - curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python - - export PATH="/home/travis/.cask/bin:$PATH" - - cask info - - cask install - - emacs --version - - cask --version - -matrix: - fast_finish: true - -script: - - make deps test diff --git a/Cask b/Cask deleted file mode 100644 index 9960ec2..0000000 --- a/Cask +++ /dev/null @@ -1,4 +0,0 @@ -(source gnu) -(source melpa) - -(package-file "swift-mode.el") diff --git a/Eldev b/Eldev new file mode 100644 index 0000000..aba1566 --- /dev/null +++ b/Eldev @@ -0,0 +1,64 @@ +;;; -*- mode: emacs-lisp; lexical-binding: t; no-byte-compile: t -*- + +(eldev-use-package-archive 'gnu) +(eldev-use-package-archive 'melpa) +(setq elisp-lint-indent-specs + '((swift-mode:with-temp-comment-buffer . 0))) + +(setq-default package-lint-main-file "swift-mode.el") +(setq-default indent-tabs-mode nil) +(setq-default fill-column 80) +(setq-default tab-width 8) + +(with-eval-after-load 'package-lint + (advice-add #'package-lint--check-symbol-separators :override + (lambda (&rest args) + t)) + (advice-add #'package-lint--valid-definition-name-p :around + (lambda (oldfun name prefix &rest args) + (or (equal name "run-swift") + (apply oldfun name prefix args))))) + +(defvar elisp-lint--url-in-document-regexp + (concat "^" + "[[:blank:]]*" + "\\(?:;+\\|\"\\)?" + "[[:blank:]]*" + "https?://" + "[][;,/?:@&=+$_.!~*'()#%[:alnum:]-]+" + "[[:blank:]]*\"?[[:blank:]]*" + "[[:blank:]]*)*[[:blank:]]*" + "$") + "This regexp must match a URL in comments or strings.") + +(with-eval-after-load 'elisp-lint + (advice-add + #'elisp-lint--fill-column :override + ;; Copied from elisp-lint.el and modified. + ;; Copyright (C) 2013-2015 Nikolaj Schumacher + ;; Copyright (C) 2018-2020 Neil Okamoto + ;; GPL2+. + ;; https://github.com/gonewest818/elisp-lint/ + (lambda (&rest args) + (save-excursion + (let ((line-number 1) + (too-long-lines nil)) + (goto-char (point-min)) + (while (not (eobp)) + (let ((text (buffer-substring-no-properties + (line-beginning-position) + (line-end-position)))) + (when + (and (not + (string-match elisp-lint--package-summary-regexp text)) + (not + (string-match elisp-lint--package-requires-regexp text)) + (not + (string-match elisp-lint--url-in-document-regexp text)) + (> (length text) fill-column)) + (push (list line-number 0 'fill-column + (format "line length %s exceeded" fill-column)) + too-long-lines))) + (setq line-number (1+ line-number)) + (forward-line 1)) + too-long-lines))))) diff --git a/Makefile b/Makefile index c19102f..94ec60b 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,9 @@ -CASK ?= cask -EMACS ?= emacs -VERSION := $(shell EMACS=$(EMACS) $(CASK) version) +ELDEV_DIR ?= .eldev +ELDEV ?= eldev -SRC = $(wildcard *.el) -PACKAGE = dist/swift-mode-$(VERSION).tar +INVOKE_ELDEV = ELDEV_DIR="${ELDEV_DIR}" ELDEV="${ELDEV}" ./scripts/invoke_eldev.sh -.PHONY: help all deps package install test clean +.PHONY: help all deps package install clean test test_in_docker lint help: ## Shows this message. @@ -18,43 +16,39 @@ help: # - Replace /^## / to " ". # - Remove other comment lines. # - Insert newline before rules. - @sed -e '/^\s*$$/d; /^[ .A-Z]/d; /## no-doc/d; s/^\([^#][^:]*\):.*/\1/; s/^## / /; /^#/d; s/^[^ ]/\n&/' Makefile + @sed -e '/^\s*$$/d; /^[ _.A-Z]/d; /## no-doc/d; s/^\([^#][^:]*\):.*/\1/; s/^## / /; /^#/d; s/^[^ ]/\n&/' Makefile all: package ## Builds the package. deps: ## Installs the dependencies. - $(CASK) install + ${INVOKE_ELDEV} prepare -$(PACKAGE): $(SRC) deps ## no-doc - rm -rf dist - $(CASK) package - -package: $(PACKAGE) +package: ## Builds the package. + ${INVOKE_ELDEV} package install: package ## Installs the package. - $(CASK) exec $(EMACS) --batch \ + ${INVOKE_ELDEV} emacs --batch \ -l package \ -f package-initialize \ -f package-refresh-contents \ - --eval '(package-install-file "$(PACKAGE)")' + --eval '(package-install-file "'"$$( ls dist/*.tar | sort | tail -n 1 )"'")' clean: -## Cleans the dist directory and *.elc. - rm -rf dist *.elc +## Cleans the dist directory, *.elc, and .eldev. + ${INVOKE_ELDEV} clean all test: ## Tests the package. - $(CASK) exec $(EMACS) --batch -q \ - --eval "(add-to-list 'load-path \""$(shell readlink -f .)"\")" \ - --eval "(add-to-list 'load-path \""$(shell readlink -f .)"/test\")" \ - -f batch-byte-compile \ - *.el - $(CASK) exec $(EMACS) --batch -q \ - --eval "(add-to-list 'load-path \""$(shell readlink -f .)"\")" \ - --eval "(add-to-list 'load-path \""$(shell readlink -f .)"/test\")" \ - -l test/swift-mode-test.el \ - -f swift-mode:run-test + ELDEV_DIR="${ELDEV_DIR}" ELDEV="${ELDEV}" ./scripts/run_test.sh + +test_in_docker: +## Run tests in Docker. + ./scripts/test_in_docker.sh + +lint: +## Run linters. + find ./*.el test/*.el '!' -name '*autoloads.el' -exec env ${INVOKE_ELDEV} lint '{}' '+' diff --git a/README.md b/README.md index 98018cd..420d3af 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![License GPL 3][badge-license]][copying] -[![Build Status][badge-travis]][travis] +[![Run Tests][badge-run-test]][action-run-test] [](https://melpa.org/#/swift-mode) [](https://melpa.org/#/swift-mode) @@ -222,6 +222,6 @@ Thanks to [@purcell](https://github.com/purcell) (Steve Purcell) for advices on GPLv3. See [COPYING][] for details. Copyright (C) 2014-2016 taku0, Chris Barrett, Bozhidar Batsov, Arthur Evstifeev. [badge-license]: https://img.shields.io/badge/license-GPL_3-green.svg -[badge-travis]: https://travis-ci.org/swift-emacs/swift-mode.png?branch=master -[travis]: https://travis-ci.org/swift-emacs/swift-mode +[badge-run-test]: https://github.com/swift-emacs/swift-mode/workflows/Run%20Tests/badge.svg +[action-run-test]: https://github.com/swift-emacs/swift-mode/actions?query=workflow%3A%22Run+Tests%22 [COPYING]: ./COPYING diff --git a/scripts/invoke_eldev.sh b/scripts/invoke_eldev.sh new file mode 100755 index 0000000..ce43c38 --- /dev/null +++ b/scripts/invoke_eldev.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# A little wrapper for eldev. Used in Makefile. +# If ${ELDEV} is executable, use it. +# Otherwise, download the eldev to .eldev/bin/eldev if not exists, then +# execute it. + +if command -v "${ELDEV}" > /dev/null +then + "${ELDEV}" "$@" +elif command -v .eldev/bin/eldev > /dev/null +then + .eldev/bin/eldev "$@" +else + mkdir -p ./.eldev/bin || exit 1 + curl -fsSL https://raw.github.com/doublep/eldev/master/bin/eldev -o .eldev/bin/eldev || exit 1 + chmod a+x .eldev/bin/eldev || exit 1 + .eldev/bin/eldev "$@" +fi diff --git a/scripts/run_test.sh b/scripts/run_test.sh new file mode 100755 index 0000000..484e170 --- /dev/null +++ b/scripts/run_test.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Run tests. Used in Makefile. + +./scripts/invoke_eldev.sh emacs --version || exit 1 +./scripts/invoke_eldev.sh emacs --batch -q \ + --eval "(add-to-list 'load-path \"$(readlink -f .)\")" \ + --eval "(add-to-list 'load-path \"$(readlink -f .)/test\")" \ + -f batch-byte-compile \ + ./*.el || exit 1 +./scripts/invoke_eldev.sh emacs --batch -q \ + --eval "(add-to-list 'load-path \"$(readlink -f .)\")" \ + --eval "(add-to-list 'load-path \"$(readlink -f .)/test\")" \ + -l test/swift-mode-test.el \ + -f swift-mode:run-test diff --git a/scripts/test_in_docker.sh b/scripts/test_in_docker.sh new file mode 100755 index 0000000..113fcd4 --- /dev/null +++ b/scripts/test_in_docker.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Run tests in Docker. Used in Makefile. + +for version in 24.4 24.5 25.1 25.2 25.3 26.1 26.2 26.3 27.1 +do + docker \ + run \ + --rm \ + --volume="$(pwd)":/src \ + --user "$(id -u):$(id -g)" \ + silex/emacs:${version} \ + bash -c \ + "cd /src && ELDEV_DIR=/src/.eldev HOME=/tmp ./scripts/run_test.sh" \ + || exit 1 +done + +echo "done" diff --git a/swift-mode-beginning-of-defun.el b/swift-mode-beginning-of-defun.el index d91fec6..4c423a8 100644 --- a/swift-mode-beginning-of-defun.el +++ b/swift-mode-beginning-of-defun.el @@ -3,10 +3,6 @@ ;; Copyright (C) 2014-2019 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. @@ -866,7 +862,7 @@ Both functions return t if succeeded, return nil otherwise." nil)))) (defun swift-mode:backward-sentence (&optional arg) -"Skip backward sentences or statements. + "Skip backward sentences or statements. In comments or strings, skip a sentence. Otherwise, skip a statement. @@ -1338,14 +1334,14 @@ or preceding (if the point is after the mark) sentence." region))) (defun swift-mode:narrow-to-sentence (&optional include-comments) -"Make text outside current sentence invisible. + "Make text outside current sentence invisible. If the point is between sentences, narrow depend on `swift-mode:mark-defun-preference'. Preceding comments are included if INCLUDE-COMMENTS is non-nil. Interactively, the behavior depends on ‘narrow-to-defun-include-comments’." -(interactive (list (and (boundp 'narrow-to-defun-include-comments) + (interactive (list (and (boundp 'narrow-to-defun-include-comments) narrow-to-defun-include-comments))) (let ((region (swift-mode:narrow-to-generic-block include-comments diff --git a/swift-mode-font-lock.el b/swift-mode-font-lock.el index c0a6320..398cfed 100644 --- a/swift-mode-font-lock.el +++ b/swift-mode-font-lock.el @@ -8,10 +8,6 @@ ;; Bozhidar Batsov <bozhi...@batsov.com> ;; Arthur Evstifeev <l...@pisem.net> ;; Michael Sanders <michael.sand...@fastmail.com> -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. @@ -398,16 +394,16 @@ LIST-OF-SETS is a list of set of names." (limit2 (make-symbol "limit")) (matched (make-symbol "matched")) (names (make-symbol "names"))) - `(swift-mode:font-lock-match-expr - ,limit - (lambda (,pos ,limit2) - (seq-reduce - (lambda (,matched ,names) - (or ,matched - (and ,names - (funcall ,f ,names ,pos ,limit2)))) - (list ,@list-of-sets) - nil))))) + `(swift-mode:font-lock-match-expr + ,limit + (lambda (,pos ,limit2) + (seq-reduce + (lambda (,matched ,names) + (or ,matched + (and ,names + (funcall ,f ,names ,pos ,limit2)))) + (list ,@list-of-sets) + nil))))) (defun swift-mode:font-lock-match-builtin-type-names (limit) "Move the cursor just after a builtin type name. diff --git a/swift-mode-imenu.el b/swift-mode-imenu.el index 065a2e6..34f1b8c 100644 --- a/swift-mode-imenu.el +++ b/swift-mode-imenu.el @@ -3,10 +3,6 @@ ;; Copyright (C) 2019 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. @@ -330,12 +326,13 @@ and \"c\". func foo(a b: Int, c: Int)" (let* ((name-token - (swift-mode:forward-token-or-list-except-curly-bracket)) + (swift-mode:forward-token-or-list-except-curly-bracket)) next-token parameter-end (parameter-names '()) - (is-operator (seq-contains "/=-+!*%<>&|^~?." - (elt (swift-mode:token:text name-token) 0)))) + (is-operator (seq-contains + "/=-+!*%<>&|^~?." + (elt (swift-mode:token:text name-token) 0)))) (cond ((eq (swift-mode:token:type name-token) 'identifier) (while (progn diff --git a/swift-mode-indent.el b/swift-mode-indent.el index 3180fd5..84cb45e 100644 --- a/swift-mode-indent.el +++ b/swift-mode-indent.el @@ -1,15 +1,12 @@ ;;; swift-mode-indent.el --- Major-mode for Apple's Swift programming language, indentation. -*- lexical-binding: t -*- -;; Copyright (C) 2014-2020 taku0, Chris Barrett, Bozhidar Batsov, Arthur Evstifeev +;; Copyright (C) 2014-2020 taku0, Chris Barrett, Bozhidar Batsov, +;; Arthur Evstifeev ;; Authors: taku0 (http://github.com/taku0) ;; Chris Barrett <chris.d.barr...@me.com> ;; Bozhidar Batsov <bozhi...@batsov.com> ;; Arthur Evstifeev <l...@pisem.net> -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. @@ -689,8 +686,11 @@ declaration and its offset is `swift-mode:basic-offset'." (goto-char (swift-mode:token:start previous-token)) (swift-mode:find-parent-and-align-with-next swift-mode:statement-parent-tokens - (let ((relative-case-offset (- swift-mode:basic-offset swift-mode:switch-case-offset))) - (if (<= relative-case-offset 0) swift-mode:basic-offset relative-case-offset)))) + (let ((relative-case-offset + (- swift-mode:basic-offset swift-mode:switch-case-offset))) + (if (<= relative-case-offset 0) + swift-mode:basic-offset + relative-case-offset)))) ;; Before ; on the current line ((and next-is-on-current-line (eq next-type '\;)) diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el index 69dbbd2..00a4c23 100644 --- a/swift-mode-lexer.el +++ b/swift-mode-lexer.el @@ -1,15 +1,12 @@ ;;; swift-mode-lexer.el --- Major-mode for Apple's Swift programming language, lexer. -*- lexical-binding: t -*- -;; Copyright (C) 2014-2020 taku0, Chris Barrett, Bozhidar Batsov, Arthur Evstifeev +;; Copyright (C) 2014-2020 taku0, Chris Barrett, Bozhidar Batsov, +;; Arthur Evstifeev ;; Authors: taku0 (http://github.com/taku0) ;; Chris Barrett <chris.d.barr...@me.com> ;; Bozhidar Batsov <bozhi...@batsov.com> ;; Arthur Evstifeev <l...@pisem.net> -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. @@ -106,7 +103,8 @@ END is the point after the token." ;; - postfix-operator ;; - binary-operator (including as, as?, as!, is, =, ., and ->) ;; - attribute (e.g. @objc, @abc(def)) -;; - identifier (including keywords, numbers, implicit parameters, and unknown tokens) +;; - identifier (including keywords, numbers, implicit parameters, and unknown +;; tokens) ;; - [ ;; - ] ;; - { @@ -118,12 +116,16 @@ END is the point after the token." ;; - implicit-; ;; - < (as an angle bracket) ;; - > (as an angle bracket) -;; - supertype-: (colon for supertype declaration or type declaration of let or var) +;; - supertype-: (colon for supertype declaration or type declaration of let or +;; var) ;; - case-: (colon for case or default label) -;; - : (part of conditional operator, key-value separator, label-statement separator) +;; - : (part of conditional operator, key-value separator, label-statement +;; separator) ;; - anonymous-function-parameter-in ("in" after anonymous function parameter) -;; - string-chunk-after-interpolated-expression (part of a string ending with ")") -;; - string-chunk-before-interpolated-expression (part of a string ending with "\\(") +;; - string-chunk-after-interpolated-expression (part of a string ending with +;; ")") +;; - string-chunk-before-interpolated-expression (part of a string ending with +;; "\\(") ;; - outside-of-buffer ;; ;; Additionally, `swift-mode:backward-token-or-list' may return a parenthesized @@ -268,12 +270,12 @@ stops where the level becomes zero." (skip-chars-backward "#") (setq pound-count (- start (point))) (setq start (point))) - (put-text-property start (1+ start) - 'syntax-table - (string-to-syntax "|")) - (swift-mode:syntax-propertize:end-of-string - end quotation pound-count) - (put-text-property start (point) 'syntax-multiline t))) + (put-text-property start (1+ start) + 'syntax-table + (string-to-syntax "|")) + (swift-mode:syntax-propertize:end-of-string + end quotation pound-count) + (put-text-property start (point) 'syntax-multiline t))) ((equal "//" (match-string-no-properties 0)) (goto-char (match-beginning 0)) @@ -1113,20 +1115,20 @@ This function does not return `implicit-;' or `type-:'." ;; Attribute or close-parenthesis ((eq (char-before) ?\)) - (let ((pos-before-comment (point))) - (condition-case nil - (progn - (backward-list) - (forward-comment (- (point))) - (forward-symbol -1) - (unless (eq (char-after) ?@) - (goto-char (1- pos-before-comment)))) - (scan-error (goto-char (1- pos-before-comment)))) - (swift-mode:token - (if (eq (char-after) ?@) 'attribute '\)) - (buffer-substring-no-properties (point) pos-before-comment) - (point) - pos-before-comment))) + (let ((pos-before-comment (point))) + (condition-case nil + (progn + (backward-list) + (forward-comment (- (point))) + (forward-symbol -1) + (unless (eq (char-after) ?@) + (goto-char (1- pos-before-comment)))) + (scan-error (goto-char (1- pos-before-comment)))) + (swift-mode:token + (if (eq (char-after) ?@) 'attribute '\)) + (buffer-substring-no-properties (point) pos-before-comment) + (point) + pos-before-comment))) ;; Separators and parentheses ((memq (char-before) '(?, ?\; ?\{ ?\} ?\[ ?\] ?\( ?\) ?:)) diff --git a/swift-mode-repl.el b/swift-mode-repl.el index 0b49a35..b7b9322 100644 --- a/swift-mode-repl.el +++ b/swift-mode-repl.el @@ -8,10 +8,6 @@ ;; Bozhidar Batsov <bozhi...@batsov.com> ;; Arthur Evstifeev <l...@pisem.net> ;; Michael Sanders <michael.sand...@fastmail.com> -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. @@ -346,7 +342,9 @@ Return a directory satisfying the PREDICATE if exists. Otherwise, return nil." (swift-mode:find-ancestor-or-self-directory predicate parent))))) (defun swift-mode:swift-project-directory-p (directory) - "Return t if the DIRECTORY contains a file Package.swift." + ;; supress warnings: + ;; (checkdoc) Probably "contains" should be imperative "contain" + "Return t if the DIRECTORY contain\u0073 a file Package.swift." (file-exists-p (expand-file-name "Package.swift" directory))) (defun swift-mode:find-swift-project-directory (&optional directory) @@ -361,7 +359,9 @@ Return a directory path if found. Return nil otherwise." (expand-file-name (read-directory-name "Project directory: " default nil t))) (defun swift-mode:ensure-swift-project-directory (project-directory) - "Check PROJECT-DIRECTORY contains the manifest file Package.swift. + ;; supress warnings: + ;; (checkdoc) Probably "contains" should be imperative "contain" + "Check PROJECT-DIRECTORY contain\u0073 the manifest file Package.swift. If PROJECT-DIRECTORY is nil, this function searches it from `default-directory' or its ancestors." @@ -374,11 +374,15 @@ or its ancestors." project-directory) (defun swift-mode:xcode-project-directory-p (directory) - "Return t if the DIRECTORY contains a file *.xcodeproj." + ;; supress warnings: + ;; (checkdoc) Probably "contains" should be imperative "contain" + "Return t if the DIRECTORY contain\u0073 a file *.xcodeproj." (consp (directory-files directory nil ".*\\.xcodeproj"))) (defun swift-mode:xcode-workspace-directory-p (directory) - "Return t if the DIRECTORY contains a file *.xcworkspace." + ;; supress warnings: + ;; (checkdoc) Probably "contains" should be imperative "contain" + "Return t if the DIRECTORY contain\u0073 a file *.xcworkspace." (consp (directory-files directory nil ".*\\.xcworkspace"))) (defun swift-mode:find-xcode-project-directory (&optional directory) @@ -396,7 +400,9 @@ Return a directory path if found. Return nil otherwise." 'swift-mode:xcode-workspace-directory-p directory)) (defun swift-mode:ensure-xcode-project-directory (project-directory) - "Check PROJECT-DIRECTORY contains *.xcworkspace or *.xcodeproj. + ;; supress warnings: + ;; (checkdoc) Probably "contains" should be imperative "contain" + "Check PROJECT-DIRECTORY contain\u0073 *.xcworkspace or *.xcodeproj. If PROJECT-DIRECTORY is nil, this function searches it from `default-directory' or its ancestors." @@ -467,10 +473,10 @@ passed as a destination to xcodebuild." (not (equal device-identifier swift-mode:ios-local-device-identifier))) (setq arglist - (append arglist - `("-destination" - ,(concat "platform=iOS Simulator,id=" device-identifier) - )))) + (append + arglist + `("-destination" + ,(concat "platform=iOS Simulator,id=" device-identifier))))) (unless (zerop (apply #'swift-mode:call-process arglist)) (error "%s %s" "Cannot read Xcode build settings" (buffer-string)))) (goto-char (point-min)) @@ -545,9 +551,9 @@ An list ARGS are appended for builder command line arguments." (unless (zerop (apply 'swift-mode:call-process - swift-mode:swift-build-executable - "--package-path" project-directory - args)) + swift-mode:swift-build-executable + "--package-path" project-directory + args)) (compilation-mode) (goto-char (point-min)) (pop-to-buffer (current-buffer)) @@ -564,7 +570,7 @@ Build it for iOS device DEVICE-IDENTIFIER for the given SCHEME. If PROJECT-DIRECTORY is nil or omitted, it is searched from `default-directory' or its ancestors. DEVICE-IDENTIFIER is the device identifier of the iOS simulator. If it is nil -or omitted, the value of `swift-mode:ios-device-identifier' is used. If it is +or omitted, the value of `swift-mode:ios-device-identifier' is used. If it is equal to `swift-mode:ios-local-device-identifier', a local device is used via `ios-deploy' instead. SCHEME is the name of the project scheme in Xcode. If it is nil or omitted, @@ -575,9 +581,9 @@ the value of `swift-mode:ios-project-scheme' is used." (swift-mode:find-xcode-workspace-directory) (swift-mode:find-xcode-project-directory))) (project-directory - (if current-prefix-arg - (swift-mode:read-project-directory default-project-directory) - default-project-directory))) + (if current-prefix-arg + (swift-mode:read-project-directory default-project-directory) + default-project-directory))) (list project-directory (if current-prefix-arg @@ -615,7 +621,7 @@ the value of `swift-mode:ios-project-scheme' is used." `("-destination" ,(concat "platform=iOS Simulator,id=" device-identifier) "-sdk" "iphonesimulator")))) - (unless + (unless (zerop (let ((default-directory project-directory)) (apply 'swift-mode:call-process xcodebuild-args))) @@ -849,13 +855,13 @@ in Xcode build settings." (progress-reporter (make-progress-reporter "Waiting for simulator..."))) (cond - (target-booted + (target-booted ;; The target device is already booted. Does nothing. t) - (simulator-running + (simulator-running (swift-mode:kill-ios-simulator) (swift-mode:open-ios-simulator device-identifier)) - (t (swift-mode:open-ios-simulator device-identifier))) + (t (swift-mode:open-ios-simulator device-identifier))) (swift-mode:wait-for-ios-simulator device-identifier) @@ -867,21 +873,21 @@ in Xcode build settings." (let ((progress-reporter (make-progress-reporter "Launching app...")) (process-identifier - (swift-mode:launch-ios-app + (swift-mode:launch-ios-app device-identifier product-bundle-identifier t))) (progress-reporter-done progress-reporter) (swift-mode:run-repl - (append + (append (swift-mode:command-string-to-list swift-mode:debugger-executable) (list "--" codesigning-folder-path)) - nil t) + nil t) (swift-mode:enqueue-repl-commands - "platform select ios-simulator" - (concat "platform connect " device-identifier) - (concat "process attach --pid " (number-to-string process-identifier)) - "breakpoint set --one-shot true --name UIApplicationMain" - "cont" - (cons + "platform select ios-simulator" + (concat "platform connect " device-identifier) + (concat "process attach --pid " (number-to-string process-identifier)) + "breakpoint set --one-shot true --name UIApplicationMain" + "cont" + (cons (lambda (_string) (swift-mode:search-process-stopped-message process-identifier)) "repl"))))) diff --git a/swift-mode-standard-types.el b/swift-mode-standard-types.el index 7bb2a67..222a51b 100644 --- a/swift-mode-standard-types.el +++ b/swift-mode-standard-types.el @@ -3,10 +3,6 @@ ;; Copyright (C) 2018-2020 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift ;; This file is not part of GNU Emacs. diff --git a/swift-mode.el b/swift-mode.el index ffa414a..f64f2d5 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -1,6 +1,7 @@ -;;; swift-mode.el --- Major-mode for Apple's Swift programming language. -*- lexical-binding: t -*- +;;; swift-mode.el --- Major-mode for Apple's Swift programming language -*- lexical-binding: t -*- -;; Copyright (C) 2014-2019 taku0, Chris Barrett, Bozhidar Batsov, Arthur Evstifeev +;; Copyright (C) 2014-2019 taku0, Chris Barrett, Bozhidar Batsov, +;; Arthur Evstifeev ;; Authors: taku0 (http://github.com/taku0) ;; Chris Barrett <chris.d.barr...@me.com> @@ -146,6 +147,7 @@ Signal `scan-error' if it hits opening parentheses." ;;;###autoload (defsubst swift-mode:add-supported-extension-for-speedbar () + "Register .swfit to speedbar." (if (fboundp 'speedbar-add-supported-extension) (speedbar-add-supported-extension ".swift") (add-hook 'speedbar-load-hook diff --git a/test/swift-mode-test-beginning-of-defun.el b/test/swift-mode-test-beginning-of-defun.el index bd3cc7e..6c0807a 100644 --- a/test/swift-mode-test-beginning-of-defun.el +++ b/test/swift-mode-test-beginning-of-defun.el @@ -3,11 +3,6 @@ ;; Copyright (C) 2017-2019 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift -;; URL: https://github.com/swift-emacs/swift-mode ;; This file is not part of GNU Emacs. diff --git a/test/swift-mode-test-imenu.el b/test/swift-mode-test-imenu.el index 45b3ca9..1db6ca0 100644 --- a/test/swift-mode-test-imenu.el +++ b/test/swift-mode-test-imenu.el @@ -3,11 +3,6 @@ ;; Copyright (C) 2019 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift -;; URL: https://github.com/swift-emacs/swift-mode ;; This file is not part of GNU Emacs. diff --git a/test/swift-mode-test-indent.el b/test/swift-mode-test-indent.el index 6bec54b..c0f936a 100644 --- a/test/swift-mode-test-indent.el +++ b/test/swift-mode-test-indent.el @@ -3,11 +3,6 @@ ;; Copyright (C) 2016-2018 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift -;; URL: https://github.com/swift-emacs/swift-mode ;; This file is not part of GNU Emacs. diff --git a/test/swift-mode-test.el b/test/swift-mode-test.el index ccdb880..e2c4508 100644 --- a/test/swift-mode-test.el +++ b/test/swift-mode-test.el @@ -3,11 +3,6 @@ ;; Copyright (C) 2016-2019 taku0 ;; Authors: taku0 (http://github.com/taku0) -;; -;; Version: 8.1.1 -;; Package-Requires: ((emacs "24.4") (seq "2.3")) -;; Keywords: languages swift -;; URL: https://github.com/swift-emacs/swift-mode ;; This file is not part of GNU Emacs.