[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/kotlin-mode e75f8b0113 144/162: Make compatible with Emacs
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/kotlin-mode e75f8b0113 144/162: Make compatible with Emacs 24.3 |
Date: |
Sat, 29 Jan 2022 08:25:31 -0500 (EST) |
branch: elpa/kotlin-mode
commit e75f8b0113fd926b1271faefee4a79d443d1f0be
Author: taku0 <mxxouy6x3m_github@tatapa.org>
Commit: taku0 <mxxouy6x3m_github@tatapa.org>
Make compatible with Emacs 24.3
Use `defun` instead of `cl-defmethod`. `cl-defmethod` is not defined
before 25.1 while `defmehod` is deprecated from 25.1. We don't need
polymorphism anyway.
Drop 24.1 and 24.2 from .travis.yml as kotlin-mode.el declares it
supports only from 24.3.
In 24.x, object constructor needs `object-name` parameter, which is
deprecated since 25.1. So we use `make-instance` which is compatible
with both 24.x and 25.x.
Set `kotlin-tab-width` locally during tests for stability.
---
.travis.yml | 9 +++-----
kotlin-mode.el | 22 +++++++-----------
test/kotlin-mode-test.el | 59 ++++++++++++++++++++++++++++--------------------
3 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0f43318a8e..d96fd63142 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,12 +5,9 @@ before_install:
- evm install $EVM_EMACS --use --skip
- cask
env:
- # https://github.com/Emacs-Kotlin-Mode-Maintainers/kotlin-mode/issues/46
- #- EVM_EMACS=emacs-24.1-travis
- #- EVM_EMACS=emacs-24.2-travis
- #- EVM_EMACS=emacs-24.3-travis
- #- EVM_EMACS=emacs-24.4-travis
- #- EVM_EMACS=emacs-24.5-travis
+ - EVM_EMACS=emacs-24.3-travis
+ - 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
diff --git a/kotlin-mode.el b/kotlin-mode.el
index ec398c3b93..a0ce272048 100644
--- a/kotlin-mode.el
+++ b/kotlin-mode.el
@@ -391,8 +391,7 @@
We scroll backwards until the net-bracket-count is zero, and this point
determines the desired indentation level for the current line.")
-(cl-defmethod kotlin-mode--count-to-line-start
- ((counter kotlin-mode--bracket-counter))
+(defun kotlin-mode--count-to-line-start (counter)
"Count the brackets on the current line, starting from the cursor
position, and working backward, incrementing the count
+1 for open-brackets, -1 for close-brackets.
@@ -424,15 +423,13 @@
(kotlin-mode--add-indent counter
(- position (re-search-backward "^"))))))))
-(cl-defmethod kotlin-mode--count-leading-close-brackets
- ((counter kotlin-mode--bracket-counter))
+(defun kotlin-mode--count-leading-close-brackets (counter)
"Count any close-bracket at the start of the current line."
(if (looking-at "\\s)")
(oset counter use-base nil))
(kotlin-mode--subtract-count counter (skip-syntax-forward ")")))
-(cl-defmethod kotlin-mode--count-trailing-open-brackets
- ((counter kotlin-mode--bracket-counter))
+(defun kotlin-mode--count-trailing-open-brackets (counter)
"If the bracket count is at zero, and there are open-brackets at the end
of the line, do not count them, but add a single indentation level."
(if (= (oref counter count) 0)
@@ -440,19 +437,16 @@
(kotlin-mode--add-indent counter kotlin-tab-width)
(oset counter use-base nil)))))
-(cl-defmethod kotlin-mode--add-count
- ((counter kotlin-mode--bracket-counter) val)
+(defun kotlin-mode--add-count (counter val)
(cl-incf (oref counter count) val))
-(cl-defmethod kotlin-mode--subtract-count
- ((counter kotlin-mode--bracket-counter) val)
+(defun kotlin-mode--subtract-count (counter val)
(cl-decf (oref counter count) val))
-(cl-defmethod kotlin-mode--add-indent
- ((counter kotlin-mode--bracket-counter) val)
+(defun kotlin-mode--add-indent (counter val)
(cl-incf (oref counter indent) val))
-(cl-defmethod kotlin-mode--finished ((counter kotlin-mode--bracket-counter))
+(defun kotlin-mode--finished (counter)
(oref counter finished))
(defun kotlin-mode--in-comment-block ()
@@ -484,7 +478,7 @@
(kotlin-mode--beginning-of-buffer-indent)
(let ((cur-indent 0))
;; Find bracket-based indentation first
- (let ((bracket-counter (kotlin-mode--bracket-counter)))
+ (let ((bracket-counter (make-instance 'kotlin-mode--bracket-counter)))
(save-excursion
(skip-syntax-forward "-")
(kotlin-mode--count-leading-close-brackets bracket-counter))
diff --git a/test/kotlin-mode-test.el b/test/kotlin-mode-test.el
index 0dd7e27748..5f901717ed 100644
--- a/test/kotlin-mode-test.el
+++ b/test/kotlin-mode-test.el
@@ -1,7 +1,3 @@
-;; Tests assume a tab is represented by 4 spaces
-(setq-default indent-tabs-mode nil)
-(setq-default tab-width 4)
-
(require 'kotlin-mode)
(ert-deftest kotlin-mode--top-level-indent-test ()
@@ -14,6 +10,11 @@ import bar.Bar as bBar
"))
(insert text)
(beginning-of-buffer)
+ (kotlin-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local tab-width 4)
+ (setq-local kotlin-tab-width 4)
+
(kotlin-mode--indent-line)
(should (equal text (buffer-string)))
@@ -42,6 +43,10 @@ return a + b
(insert text)
(beginning-of-buffer)
+ (kotlin-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local tab-width 4)
+ (setq-local kotlin-tab-width 4)
(next-line)
(kotlin-mode--indent-line)
@@ -58,6 +63,10 @@ return a + b
(insert text)
(beginning-of-buffer)
+ (kotlin-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local tab-width 4)
+ (setq-local kotlin-tab-width 4)
(kotlin-mode--indent-line)
@@ -83,24 +92,24 @@ return a + b
(ert-deftest kotlin-mode--sample-test ()
(with-temp-buffer
- (insert-file-contents "test/sample.kt")
- (beginning-of-buffer)
- (while (not (eobp))
- (let ((expected-line (thing-at-point 'line)))
-
- ;; Remove existing indentation
- (beginning-of-line)
- (delete-region (point) (progn (skip-chars-forward " \t") (point)))
-
- ;; Indent the line
- (kotlin-mode--indent-line)
-
- ;; Check that the correct indentation is re-applied
- (should (equal expected-line (thing-at-point 'line)))
-
- ;; Go to the next non-empty line
- (next-non-empty-line)
- )
- )
- )
- )
+ (insert-file-contents "test/sample.kt")
+ (beginning-of-buffer)
+ (kotlin-mode)
+ (setq-local indent-tabs-mode nil)
+ (setq-local tab-width 4)
+ (setq-local kotlin-tab-width 4)
+ (while (not (eobp))
+ (let ((expected-line (thing-at-point 'line)))
+
+ ;; Remove existing indentation
+ (beginning-of-line)
+ (delete-region (point) (progn (skip-chars-forward " \t") (point)))
+
+ ;; Indent the line
+ (kotlin-mode--indent-line)
+
+ ;; Check that the correct indentation is re-applied
+ (should (equal expected-line (thing-at-point 'line)))
+
+ ;; Go to the next non-empty line
+ (next-non-empty-line)))))
- [nongnu] elpa/kotlin-mode 78db8656d4 047/162: Fixed font lock for types, (continued)
- [nongnu] elpa/kotlin-mode 78db8656d4 047/162: Fixed font lock for types, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 1624e7d795 052/162: add 'nested' and 'inner' class modifiers, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 4787bf94c1 058/162: Ignore dist folder produce by `cask package`, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode d4e97ffa4b 095/162: Switch from using a Bash script to using Make for the tests. Though 'cask exec eert-runner' also works to run the tests., ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode b86f9b4607 147/162: Fix indentation after comment containing close brackets, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode fe905c587a 023/162: kotlin-mode: Highlight classes/enums, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode c91a82b864 031/162: kotlin-mode: Highlight try-`catch-finally', ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 9314dd61f6 040/162: kotlin-mode: Use syntax-propertize-function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 748fcbbec9 049/162: Fix bug in regular expression, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 4f1d0a3919 055/162: Add 'interface' as a type decl keyword, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode e75f8b0113 144/162: Make compatible with Emacs 24.3,
ELPA Syncer <=
- [nongnu] elpa/kotlin-mode b9d03a769b 158/162: Add version attribute, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 36b030022e 120/162: Improve identification and handling of line continuation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 639203bf84 143/162: Require cl-lib instead of cl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 8e6dd578f2 154/162: Merge pull request #52 from taku0/add-makefile, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode ffeb70e788 048/162: Temporarily disable syntax highlighting for "by", "get", "set", "in", and "out", ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 86b94d7d34 160/162: Add LICENSE file, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 39db5b6208 033/162: kotlin-mode: Highlight properties, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 300acc2341 036/162: kotlin-mode: Highlight package names, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode a174f5ba44 039/162: kotlin-mode: Add kotlin-mode--match-interpolation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/kotlin-mode 42b7af8122 046/162: 'data class' -> 'data', ELPA Syncer, 2022/01/29