[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/editorconfig 5a80a5a11e: Drop Emacs 24.x and 25.x (#286)
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/editorconfig 5a80a5a11e: Drop Emacs 24.x and 25.x (#286) |
Date: |
Tue, 3 Jan 2023 06:58:50 -0500 (EST) |
branch: elpa/editorconfig
commit 5a80a5a11edf891f29354bcde090918527a80ba2
Author: Jen-Chieh Shen <jcs090218@gmail.com>
Commit: GitHub <noreply@github.com>
Drop Emacs 24.x and 25.x (#286)
* Drop Emacs 24.x and 25.x
* test(build.yaml): Make fail-fast to false
* Update CI test
* docs: Update changelog
* Revert author information
---
.github/workflows/build.yaml | 40 ++++++--
.gitignore | 8 ++
CHANGELOG.md | 3 +
Eask | 20 ++++
Makefile | 18 ++--
editorconfig-conf-mode.el | 20 ++--
editorconfig-core-handle.el | 55 ++++-------
editorconfig-core.el | 57 ++++-------
editorconfig-fnmatch.el | 21 ++--
editorconfig.el | 174 ++++++++++++++--------------------
ert-tests/editorconfig-core-handle.el | 40 ++++++--
ert-tests/editorconfig-core.el | 39 ++++++--
ert-tests/editorconfig-fnmatch.el | 30 +++++-
ert-tests/editorconfig.el | 72 ++++++++------
ert-tests/metadata.el | 33 ++++++-
15 files changed, 352 insertions(+), 278 deletions(-)
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 30b6d53c76..8793fee6c8 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -1,4 +1,3 @@
----
name: build
on:
@@ -12,30 +11,53 @@ on:
release:
types: [published]
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
test:
- runs-on: ubuntu-latest
+ runs-on: ${{ matrix.os }}
strategy:
+ fail-fast: false
matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
emacs_version:
- - "24.5"
- - "25.3"
- "26.3"
- "27.2"
- "28.2"
experimental: [false]
include:
- - emacs_version: snapshot
+ - os: ubuntu-latest
+ emacs_version: snapshot
+ experimental: true
+ - os: macos-latest
+ emacs_version: snapshot
+ experimental: true
+ - os: windows-latest
+ emacs_version: snapshot
experimental: true
continue-on-error: ${{ matrix.experimental }}
+
steps:
- name: Checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v3
with:
submodules: recursive
+
- name: Setup Emacs
- uses: purcell/setup-emacs@master
+ uses: jcs090218/setup-emacs@master
with:
version: ${{ matrix.emacs_version }}
- - name: Run tests
- run: make check
+
+ - uses: emacs-eask/setup-eask@master
+ with:
+ version: 'snapshot'
+
+ - name: Run tests (Unix)
+ if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
+ run: make check-unix
+
+ - name: Run tests (Windows)
+ if: matrix.os == 'windows-latest'
+ run: make check-dos
diff --git a/.gitignore b/.gitignore
index f24ee0f685..9a16283ba1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,11 @@
\#*
.\#*
*.autosave
+
+# eask packages
+.eask/
+dist/
+
+# packaging
+*-autoloads.el
+*-pkg.el
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57dd2f0653..f55cd6c274 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0
### Changed
+- Drop Emacs 24.x and 25.x ([#286])
+
### Deprecated
### Removed
@@ -270,6 +272,7 @@ and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0
[0.3]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.2...v0.3
[0.2]: https://github.com/editorconfig/editorconfig-emacs/compare/v0.1...v0.2
[0.1]: https://github.com/editorconfig/editorconfig-emacs/releases/tag/v0.1
+[#286]: https://github.com/editorconfig/editorconfig-emacs/issues/286
[#280]: https://github.com/editorconfig/editorconfig-emacs/issues/280
[#263]: https://github.com/editorconfig/editorconfig-emacs/issues/263
[#260]: https://github.com/editorconfig/editorconfig-emacs/issues/260
diff --git a/Eask b/Eask
new file mode 100644
index 0000000000..8d32ac56e7
--- /dev/null
+++ b/Eask
@@ -0,0 +1,20 @@
+(package "editorconfig"
+ "0.9.1"
+ "EditorConfig Emacs Plugin")
+
+(website-url "https://github.com/editorconfig/editorconfig-emacs#readme")
+(keywords "convenience" "editorconfig")
+
+(package-file "editorconfig.el")
+
+(files "editorconfig-*.el")
+
+(script "test" "echo \"Error: no test specified\" && exit 1")
+
+(source "gnu")
+(source "melpa")
+
+(depends-on "emacs" "26.1")
+(depends-on "nadvice")
+
+(setq network-security-level 'low) ; see
https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432
diff --git a/Makefile b/Makefile
index 5be903f2d9..963f6de2ed 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@
TEXI_CHAPTER := EditorConfig Emacs Plugin
EMACS = emacs
+EASK = eask
PANDOC = pandoc
AWK = awk
@@ -16,21 +17,26 @@ MAIN_SRC = editorconfig.el
SRCS = $(wildcard $(PROJECT_ROOT_DIR)/*.el)
OBJS = $(SRCS:.el=.elc)
-.PHONY: check \
+.PHONY: check-unix check-dos \
compile clean \
test test-ert test-core \
sandbox doc
-check: compile test
+# CI entry
+check-unix: package install compile test
+check-dos: package install compile test-ert
+package:
+ $(EASK) package
-compile: $(OBJS)
+install:
+ $(EASK) install
-$(OBJS): %.elc: %.el
- $(EMACS) $(BATCHFLAGS) -f batch-byte-compile $^
+compile:
+ $(EASK) compile
clean:
- -rm -f $(OBJS)
+ $(EASK) clean elc
doc: doc/editorconfig.texi
diff --git a/editorconfig-conf-mode.el b/editorconfig-conf-mode.el
index f4f7de944a..07c443693c 100644
--- a/editorconfig-conf-mode.el
+++ b/editorconfig-conf-mode.el
@@ -77,25 +77,19 @@
;; Highlight all key values
(dolist (key-value key-value-list)
- (push
- `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value)
- 1 font-lock-constant-face)
- font-lock-value
- ))
+ (push `(,(format "[=:][ \t]*\\(%s\\)\\([ \t]\\|$\\)" key-value)
+ 1 font-lock-constant-face)
+ font-lock-value))
;; Highlight all key properties
(dolist (key-property key-property-list)
- (push
- `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property)
- 1 font-lock-builtin-face)
- font-lock-value
- ))
+ (push `(,(format "^[ \t]*\\(%s\\)[ \t]*[=:]" key-property)
+ 1 font-lock-builtin-face)
+ font-lock-value))
(conf-mode-initialize "#" font-lock-value)))
;;;###autoload
-(add-to-list 'auto-mode-alist
- '("\\.editorconfig\\'" . editorconfig-conf-mode))
+(add-to-list 'auto-mode-alist '("\\.editorconfig\\'" . editorconfig-conf-mode))
(provide 'editorconfig-conf-mode)
-
;;; editorconfig-conf-mode.el ends here
diff --git a/editorconfig-core-handle.el b/editorconfig-core-handle.el
index c0dedb68f5..f5f3f6f33a 100644
--- a/editorconfig-core-handle.el
+++ b/editorconfig-core-handle.el
@@ -57,9 +57,7 @@ Slots:
DIR should be the directory where .editorconfig file which has SECTION lives.
IF not match, return nil."
(when (editorconfig-core-handle--fnmatch-p
- file
- (editorconfig-core-handle-section-name section)
- dir)
+ file (editorconfig-core-handle-section-name section) dir)
(editorconfig-core-handle-section-props section)))
(cl-defstruct editorconfig-core-handle
@@ -89,13 +87,10 @@ Slots:
If CONF does not exist return nil."
(when (file-readable-p conf)
- (let ((cached (gethash conf
- editorconfig-core-handle--cache-hash))
- (mtime (nth 5
- (file-attributes conf))))
+ (let ((cached (gethash conf editorconfig-core-handle--cache-hash))
+ (mtime (nth 5 (file-attributes conf))))
(if (and cached
- (equal (editorconfig-core-handle-mtime cached)
- mtime))
+ (equal (editorconfig-core-handle-mtime cached) mtime))
cached
(let ((parsed (editorconfig-core-handle--parse-file conf)))
(puthash conf
@@ -151,16 +146,10 @@ If pattern has slash, pattern should be relative to DIR.
This function is a fnmatch with a few modification for EditorConfig usage."
(if (string-match-p "/" pattern)
- (let ((pattern (replace-regexp-in-string "^/"
- ""
- pattern))
+ (let ((pattern (replace-regexp-in-string "^/" "" pattern))
(dir (file-name-as-directory dir)))
- (editorconfig-fnmatch-p name
- (concat dir
- pattern)))
- (editorconfig-fnmatch-p name
- (concat "**/"
- pattern))))
+ (editorconfig-fnmatch-p name (concat dir pattern)))
+ (editorconfig-fnmatch-p name (concat "**/" pattern))))
(defsubst editorconfig-core-handle--string-trim (str)
"Remove leading and trailing whitespaces from STR."
@@ -196,8 +185,7 @@ If CONF is not found return nil."
(props ())
;; Current line num
- (current-line-number 1)
- )
+ (current-line-number 1))
(while (not (eq (point) point-max))
(setq line
(buffer-substring-no-properties (line-beginning-position)
@@ -224,21 +212,14 @@ If CONF is not found return nil."
(setq pattern (match-string 1 line)))
(t
- (let ((idx (string-match "=\\|:"
- line)))
+ (let ((idx (string-match "=\\|:" line)))
(unless idx
(error "Error while reading config file: %s:%d:\n %s\n"
- conf
- current-line-number
- line))
- (let (
- (key (downcase (editorconfig-core-handle--string-trim
- (substring line
- 0
- idx))))
+ conf current-line-number line))
+ (let ((key (downcase (editorconfig-core-handle--string-trim
+ (substring line 0 idx))))
(value (editorconfig-core-handle--string-trim
- (substring line
- (1+ idx)))))
+ (substring line (1+ idx)))))
(when (and (< (length key) 51)
(< (length value) 256))
(if pattern
@@ -246,13 +227,10 @@ If CONF is not found return nil."
(setq props
`(,@props (,key . ,value))))
(setq top-props
- `(,@top-props (,key . ,value))))))))
- )
- (setq current-line-number
- (1+ current-line-number))
+ `(,@top-props (,key . ,value)))))))))
+ (setq current-line-number (1+ current-line-number))
(goto-char (point-min))
- (forward-line (1- current-line-number))
- )
+ (forward-line (1- current-line-number)))
(when pattern
(setq sections
`(,@sections ,(make-editorconfig-core-handle-section
@@ -262,5 +240,4 @@ If CONF is not found return nil."
:sections sections)))))
(provide 'editorconfig-core-handle)
-
;;; editorconfig-core-handle.el ends here
diff --git a/editorconfig-core.el b/editorconfig-core.el
index b60a253c0b..3e0097b9f4 100644
--- a/editorconfig-core.el
+++ b/editorconfig-core.el
@@ -80,24 +80,20 @@ RESULT is used internally and normally should not be used."
(let ((handle (editorconfig-core-handle (concat (file-name-as-directory dir)
confname)))
(parent (file-name-directory (directory-file-name dir))))
- (if (or (string= parent
- dir)
- (and handle
- (editorconfig-core-handle-root-p handle)))
- (cl-remove-if-not 'identity
- (cons handle result))
+ (if (or (string= parent dir)
+ (and handle (editorconfig-core-handle-root-p handle)))
+ (cl-remove-if-not 'identity (cons handle result))
(editorconfig-core--get-handles parent
confname
- (cons handle
- result)))))
+ (cons handle result)))))
;;;###autoload
(defun editorconfig-core-get-nearest-editorconfig (directory)
"Return path to .editorconfig file that is closest to DIRECTORY."
- (let ((handle (car (last (editorconfig-core--get-handles directory
+ (when-let ((handle (car (last
+ (editorconfig-core--get-handles directory
".editorconfig")))))
- (when handle
- (editorconfig-core-handle-path handle))))
+ (editorconfig-core-handle-path handle)))
;;;###autoload
(defun editorconfig-core-get-properties (&optional file confname confversion)
@@ -111,9 +107,7 @@ This functions returns alist of properties. Each element
will look like
(let ((hash (editorconfig-core-get-properties-hash file confname
confversion))
(result nil))
(maphash (lambda (key value)
- (add-to-list 'result
- (cons (symbol-name key)
- value)))
+ (add-to-list 'result (cons (symbol-name key) value)))
hash)
result))
@@ -122,11 +116,7 @@ This functions returns alist of properties. Each element
will look like
This is a destructive function, hash INTO will be modified.
When the same key exists in both two hashes, values of UPDATE takes
precedence."
- (maphash (lambda (key value)
- (puthash key
- value
- into))
- update)
+ (maphash (lambda (key value) (puthash key value into)) update)
into)
;;;###autoload
@@ -142,10 +132,8 @@ hash object instead."
(expand-file-name (or file
buffer-file-name
(error "FILE is not given and `buffer-file-name'
is nil"))))
- (setq confname (or confname
- ".editorconfig"))
- (setq confversion (or confversion
- "0.12.0"))
+ (setq confname (or confname ".editorconfig"))
+ (setq confversion (or confversion "0.12.0"))
(let ((result (make-hash-table)))
(dolist (handle (editorconfig-core--get-handles (file-name-directory file)
confname))
@@ -154,16 +142,10 @@ hash object instead."
file)))
;; Downcase known boolean values
- (dolist (key '(
- end_of_line indent_style indent_size insert_final_newline
- trim_trailing_whitespace charset
- ))
- (let ((val (gethash key
- result)))
- (when val
- (puthash key
- (downcase val)
- result))))
+ (dolist (key '( end_of_line indent_style indent_size insert_final_newline
+ trim_trailing_whitespace charset))
+ (when-let ((val (gethash key result)))
+ (puthash key (downcase val) result)))
;; Add indent_size property
(let ((v-indent-size (gethash 'indent_size result))
@@ -182,21 +164,16 @@ hash object instead."
(when (and v-indent-size
(not v-tab-width)
(not (string= v-indent-size "tab")))
- (puthash 'tab_width
- v-indent-size
- result)))
+ (puthash 'tab_width v-indent-size result)))
;; Update indent-size property
(let ((v-indent-size (gethash 'indent_size result))
(v-tab-width (gethash 'tab_width result)))
(when (and v-indent-size
v-tab-width
(string= v-indent-size "tab"))
- (puthash 'indent_size
- v-tab-width
- result)))
+ (puthash 'indent_size v-tab-width result)))
result))
(provide 'editorconfig-core)
-
;;; editorconfig-core.el ends here
diff --git a/editorconfig-fnmatch.el b/editorconfig-fnmatch.el
index 94c2580f59..50a5d66448 100644
--- a/editorconfig-fnmatch.el
+++ b/editorconfig-fnmatch.el
@@ -213,12 +213,10 @@ translation is found for PATTERN."
(setq pos index
has-comma nil)
(while (and (or (and (< pos length)
- (not (= (aref pattern pos)
- ?})))
+ (not (= (aref pattern pos) ?})))
is-escaped)
(not has-comma))
- (if (and (eq (aref pattern pos)
- ?,)
+ (if (and (eq (aref pattern pos) ?,)
(not is-escaped))
(setq has-comma t)
(setq is-escaped (and (eq (aref pattern pos)
@@ -242,8 +240,7 @@ translation is found for PATTERN."
"\\|")
"\\)"))))
(let ((inner (editorconfig-fnmatch--do-translate
pattern-sub t)))
- (setq result `(,@result ,(format "{%s}"
- inner)))))
+ (setq result `(,@result ,(format "{%s}" inner)))))
(setq index (1+ pos)))
(if matching-braces
(setq result `(,@result "\\(?:")
@@ -264,17 +261,14 @@ translation is found for PATTERN."
(setq result `(,@result "}"))))
(?/
- (if (and (<= (+ index 3)
- (length pattern))
- (string= (substring pattern index (+ index 3))
- "**/"))
+ (if (and (<= (+ index 3) (length pattern))
+ (string= (substring pattern index (+ index 3)) "**/"))
(setq result `(,@result "\\(?:/\\|/.*/\\)")
index (+ index 3))
(setq result `(,@result "/"))))
(t
- (unless (= current-char
- ?\\)
+ (unless (= current-char ?\\)
(setq result `(,@result ,(regexp-quote (char-to-string
current-char)))))))
(if (= current-char ?\\)
@@ -284,8 +278,7 @@ translation is found for PATTERN."
(setq is-escaped nil))))
(unless nested
(setq result `("^" ,@result "\\'")))
- (apply 'concat result)))
+ (apply #'concat result)))
(provide 'editorconfig-fnmatch)
-
;;; editorconfig-fnmatch.el ends here
diff --git a/editorconfig.el b/editorconfig.el
index 7c4859ffb5..87bc0a0a62 100644
--- a/editorconfig.el
+++ b/editorconfig.el
@@ -5,7 +5,8 @@
;; Author: EditorConfig Team <editorconfig@googlegroups.com>
;; Version: 0.9.1
;; URL: https://github.com/editorconfig/editorconfig-emacs#readme
-;; Package-Requires: ((emacs "24") (cl-lib "0.5") (nadvice "0.3"))
+;; Package-Requires: ((emacs "26.1") (nadvice "0.3"))
+;; Keywords: convenience editorconfig
;; See
;; https://github.com/editorconfig/editorconfig-emacs/graphs/contributors
@@ -38,8 +39,12 @@
;; version control systems.
;;; Code:
+
(require 'cl-lib)
+(require 'pcase)
+
(require 'nadvice)
+
(eval-when-compile
(require 'rx)
(defvar tex-indent-basic)
@@ -357,7 +362,7 @@ number - `lisp-indent-offset' is not set only if
indent_size is
`lisp-indent-offset' will not be set only if indent_size is 2.")
(define-error 'editorconfig-error
- "Error thrown from editorconfig lib")
+ "Error thrown from editorconfig lib")
(defun editorconfig-error (&rest args)
"Signal an `editorconfig-error'.
@@ -374,7 +379,7 @@ Make a message by passing ARGS to `format-message'."
(defun editorconfig--disabled-for-majormode (majormode)
"Return non-nil when Editorconfig is disabled for MAJORMODE."
(cl-assert majormode)
- (or (editorconfig--provided-mode-derived-p majormode 'special-mode)
+ (or (provided-mode-derived-p majormode 'special-mode)
(memq majormode
editorconfig-exclude-modes)))
@@ -385,37 +390,30 @@ Make a message by passing ARGS to `format-message'."
(defun editorconfig-set-indentation-python-mode (size)
"Set `python-mode' indent size to SIZE."
- (set (make-local-variable (if (or (> emacs-major-version 24)
- (and (= emacs-major-version 24)
- (>= emacs-minor-version 3)))
- 'python-indent-offset
- 'python-indent))
- size)
+ (setq-local python-indent-offset size)
;; For https://launchpad.net/python-mode
(when (boundp 'py-indent-offset)
- (set (make-local-variable 'py-indent-offset) size)))
+ (setq-local py-indent-offset size)))
(defun editorconfig-set-indentation-latex-mode (size)
"Set `latex-mode' indent size to SIZE."
- (set (make-local-variable 'tex-indent-basic) size)
- (set (make-local-variable 'tex-indent-item) size)
- (set (make-local-variable 'tex-indent-arg) (* 2 size))
+ (setq-local tex-indent-basic size)
+ (setq-local tex-indent-item size)
+ (setq-local tex-indent-arg (* 2 size))
;; For AUCTeX
(when (boundp 'TeX-brace-indent-level)
- (set (make-local-variable 'TeX-brace-indent-level) size))
+ (setq-local TeX-brace-indent-level size))
(when (boundp 'LaTeX-indent-level)
- (set (make-local-variable 'LaTeX-indent-level) size))
+ (setq-local LaTeX-indent-level size))
(when (boundp 'LaTeX-item-indent)
- (set (make-local-variable 'LaTeX-item-indent) (- size))))
+ (setq-local LaTeX-item-indent (- size))))
(defun editorconfig--should-set (size symbol)
"Determines if editorconfig should set SYMBOL using SIZE."
(if (eq symbol 'lisp-indent-offset)
(cond
- ((eql nil editorconfig-lisp-use-default-indent)
- t)
- ((eql t editorconfig-lisp-use-default-indent)
- nil)
+ ((null editorconfig-lisp-use-default-indent) t)
+ ((eql t editorconfig-lisp-use-default-indent) nil)
((numberp editorconfig-lisp-use-default-indent)
(not (eql size editorconfig-lisp-use-default-indent)))
(t t))
@@ -425,7 +423,7 @@ Make a message by passing ARGS to `format-message'."
"Set indentation type from STYLE, SIZE and TAB_WIDTH."
(if (editorconfig-string-integer-p size)
(setq size (string-to-number size))
- (when (not (equal size "tab")) (setq size nil)))
+ (unless (equal size "tab") (setq size nil)))
(cond (tab_width
(setq tab-width (string-to-number tab_width)))
((numberp size)
@@ -438,7 +436,7 @@ Make a message by passing ARGS to `format-message'."
(setq indent-tabs-mode t)))
(when size
(when (featurep 'evil)
- (set (make-local-variable 'evil-shift-width) size))
+ (setq-local evil-shift-width size))
(let ((parent major-mode)
entry)
;; Find the closet parent mode of `major-mode' in
@@ -461,9 +459,8 @@ Make a message by passing ARGS to `format-message'."
((integerp spec) (* spec size))
(t spec))))))))))))))
-(defvar editorconfig--apply-coding-system-currently nil
+(defvar-local editorconfig--apply-coding-system-currently nil
"Used internally.")
-(make-variable-buffer-local 'editorconfig--apply-coding-system-currently)
(put 'editorconfig--apply-coding-system-currently
'permanent-local
t)
@@ -513,29 +510,27 @@ This function will revert buffer when the coding-system
has been changed."
;; Revert functions might call editorconfig-apply again
(unwind-protect
(progn
- (setq editorconfig--apply-coding-system-currently
- coding-system)
+ (setq editorconfig--apply-coding-system-currently coding-system)
;; Revert without query if buffer is not modified
(let ((revert-without-query '(".")))
(revert-buffer-with-coding-system coding-system)))
- (setq editorconfig--apply-coding-system-currently
- nil)))))
+ (setq editorconfig--apply-coding-system-currently nil)))))
(defun editorconfig-set-trailing-nl (final-newline)
"Set up requiring final newline by FINAL-NEWLINE.
This function will set `require-final-newline' and `mode-require-final-newline'
to non-nil when FINAL-NEWLINE is true."
- (cond
- ((equal final-newline "true")
- ;; keep prefs around how/when the nl is added, if set - otherwise add on
save
- (set (make-local-variable 'require-final-newline) (or
require-final-newline t))
- (set (make-local-variable 'mode-require-final-newline) (or
mode-require-final-newline t)))
- ((equal final-newline "false")
- ;; FIXME: Add functionality for actually REMOVING any trailing newlines
here!
- ;; (rather than just making sure we don't automagically ADD a new
one)
- (set (make-local-variable 'require-final-newline) nil)
- (set (make-local-variable 'mode-require-final-newline) nil))))
+ (pcase final-newline
+ ("true"
+ ;; keep prefs around how/when the nl is added, if set - otherwise add on
save
+ (setq-local require-final-newline (or require-final-newline t))
+ (setq-local mode-require-final-newline (or mode-require-final-newline t)))
+ ("false"
+ ;; FIXME: Add functionality for actually REMOVING any trailing newlines
here!
+ ;; (rather than just making sure we don't automagically ADD a new
one)
+ (setq-local require-final-newline nil)
+ (setq-local mode-require-final-newline nil))))
(defun editorconfig-set-trailing-ws (trim-trailing-ws)
"Set up trimming of trailing whitespace at end of lines by TRIM-TRAILING-WS."
@@ -546,20 +541,15 @@ to non-nil when FINAL-NEWLINE is true."
;; to write-file-functions
(if editorconfig-trim-whitespaces-mode
(funcall editorconfig-trim-whitespaces-mode 1)
- (add-to-list
- 'write-file-functions
- 'delete-trailing-whitespace)))
+ (add-to-list 'write-file-functions 'delete-trailing-whitespace)))
(when (or (equal trim-trailing-ws "false")
buffer-read-only)
;; when false we remove every delete-trailing-whitespace
;; from write-file-functions
(when editorconfig-trim-whitespaces-mode
(funcall editorconfig-trim-whitespaces-mode 0))
- (setq
- write-file-functions
- (delete
- 'delete-trailing-whitespace
- write-file-functions))))
+ (setq write-file-functions
+ (delete 'delete-trailing-whitespace write-file-functions))))
(defun editorconfig-set-line-length (length)
"Set the max line length (`fill-column') to LENGTH."
@@ -567,17 +557,6 @@ to non-nil when FINAL-NEWLINE is true."
(> (string-to-number length) 0))
(setq fill-column (string-to-number length))))
-;; Emacs<26 does not have provided-mode-derived-p
-(defun editorconfig--provided-mode-derived-p (mode &rest modes)
- "Non-nil if MODE is derived from one of MODES.
-Uses the `derived-mode-parent' property of the symbol to trace backwards.
-If you just want to check `major-mode', use `derived-mode-p'."
- (if (fboundp 'provided-mode-derived-p)
- (apply 'provided-mode-derived-p mode modes)
- (while (and (not (memq mode modes))
- (setq mode (get mode 'derived-mode-parent))))
- mode))
-
(defun editorconfig--execute-editorconfig-exec (filename)
"Execute EditorConfig core with FILENAME and return output."
@@ -611,9 +590,8 @@ If you just want to check `major-mode', use
`derived-mode-p'."
(defun editorconfig--parse-properties (props-string)
"Create properties hash table from PROPS-STRING."
- (let (props-list properties)
- (setq props-list (split-string props-string "\n")
- properties (make-hash-table))
+ (let ((props-list (split-string props-string "\n"))
+ (properties (make-hash-table)))
(dolist (prop props-list properties)
(let ((key-val (split-string prop " *= *")))
(when (> (length key-val) 1)
@@ -734,8 +712,7 @@ This function also executes
`editorconfig-after-apply-functions' functions."
major-mode
editorconfig-properties-hash)
:debug)
- (when (and (boundp 'editorconfig-mode)
- editorconfig-mode
+ (when (and (bound-and-true-p editorconfig-mode)
editorconfig-properties-hash)
(editorconfig-set-local-variables editorconfig-properties-hash)
(condition-case err
@@ -772,8 +749,7 @@ F is that function, and FILENAME and ARGS are arguments
passed to F."
(cdr editorconfig--cons-filename-codingsystem)
(not (eq (cdr editorconfig--cons-filename-codingsystem)
'undecided)))
- (let (
- (coding-system-for-read (cdr
editorconfig--cons-filename-codingsystem))
+ (let ((coding-system-for-read (cdr
editorconfig--cons-filename-codingsystem))
;; (coding-system-for-read 'undecided)
)
(apply f filename args))
@@ -837,7 +813,6 @@ F is that function, and FILENAME and ARGS are arguments
passed to F."
;; execute this explicitly here.
(editorconfig-set-local-variables props)
-
(condition-case err
(run-hook-with-args 'editorconfig-after-apply-functions props)
(error
@@ -865,14 +840,13 @@ To disable EditorConfig in some buffers, modify
:lighter editorconfig-mode-lighter
(if (not editorconfig--legacy-version)
(let ((modehooks '(prog-mode-hook
- text-mode-hook
- read-only-mode-hook
- ;; Some modes call `kill-all-local-variables' in
their init
- ;; code, which clears some values set by
editorconfig.
- ;; For those modes, editorconfig-apply need to be
called
- ;; explicitly through their hooks.
- rpm-spec-mode-hook
- )))
+ text-mode-hook
+ read-only-mode-hook
+ ;; Some modes call `kill-all-local-variables' in
their init
+ ;; code, which clears some values set by editorconfig.
+ ;; For those modes, editorconfig-apply need to be
called
+ ;; explicitly through their hooks.
+ rpm-spec-mode-hook)))
(if editorconfig-mode
(progn
(advice-add 'find-file-noselect :around
'editorconfig--advice-find-file-noselect)
@@ -884,8 +858,7 @@ To disable EditorConfig in some buffers, modify
(advice-remove 'find-file-noselect
'editorconfig--advice-find-file-noselect)
(advice-remove 'insert-file-contents
'editorconfig--advice-insert-file-contents)
(dolist (hook modehooks)
- (remove-hook hook
- 'editorconfig-major-mode-hook))))
+ (remove-hook hook 'editorconfig-major-mode-hook))))
;; editorconfig--legacy-version is enabled
;; See https://github.com/editorconfig/editorconfig-emacs/issues/141 for
why
@@ -896,8 +869,7 @@ To disable EditorConfig in some buffers, modify
;; code, which clears some values set by editorconfig.
;; For those modes, editorconfig-apply need to be called
;; explicitly through their hooks.
- rpm-spec-mode-hook
- ))
+ rpm-spec-mode-hook))
(if editorconfig-mode
(add-hook hook 'editorconfig-mode-apply)
(remove-hook hook 'editorconfig-mode-apply)))))
@@ -911,18 +883,16 @@ To disable EditorConfig in some buffers, modify
"Find the closest .editorconfig file for current file."
(interactive)
(eval-and-compile (require 'editorconfig-core))
- (let ((file (editorconfig-core-get-nearest-editorconfig
- default-directory)))
- (when file
- (find-file file))))
+ (when-let ((file (editorconfig-core-get-nearest-editorconfig
+ default-directory)))
+ (find-file file)))
;;;###autoload
(defun editorconfig-display-current-properties ()
"Display EditorConfig properties extracted for current buffer."
(interactive)
(if editorconfig-properties-hash
- (let (
- (buf (get-buffer-create "*EditorConfig Properties*"))
+ (let ((buf (get-buffer-create "*EditorConfig Properties*"))
(file buffer-file-name)
(props editorconfig-properties-hash))
(with-current-buffer buf
@@ -942,10 +912,10 @@ To disable EditorConfig in some buffers, modify
(defun editorconfig-format-buffer()
"Format buffer according to .editorconfig indent_style and indent_width."
(interactive)
- (if (string= (gethash 'indent_style editorconfig-properties-hash) "tab")
- (tabify (point-min) (point-max)))
- (if (string= (gethash 'indent_style editorconfig-properties-hash) "space")
- (untabify (point-min) (point-max)))
+ (when (string= (gethash 'indent_style editorconfig-properties-hash) "tab")
+ (tabify (point-min) (point-max)))
+ (when (string= (gethash 'indent_style editorconfig-properties-hash) "space")
+ (untabify (point-min) (point-max)))
(indent-region (point-min) (point-max)))
@@ -967,31 +937,25 @@ To disable EditorConfig in some buffers, modify
If called interactively or if SHOW-VERSION is non-nil, show the
version in the echo area and the messages buffer."
(interactive (list t))
- (let* ((version
- (with-temp-buffer
- (require 'find-func)
- (insert-file-contents (find-library-name "editorconfig"))
- (require 'lisp-mnt)
- (lm-version)))
- (pkg
- (and (eval-and-compile (require 'package nil t))
- (cadr (assq 'editorconfig
- package-alist))))
- (pkg-version
- (and pkg
- (package-version-join (package-desc-version pkg))))
+ (let* ((version (with-temp-buffer
+ (require 'find-func)
+ (insert-file-contents (find-library-name "editorconfig"))
+ (require 'lisp-mnt)
+ (lm-version)))
+ (pkg (and (eval-and-compile (require 'package nil t))
+ (cadr (assq 'editorconfig
+ package-alist))))
+ (pkg-version (and pkg
+ (package-version-join (package-desc-version pkg))))
(version-full (if (and pkg-version
- (not (string= version
- pkg-version)))
+ (not (string= version pkg-version)))
(concat version "-" pkg-version)
version)))
(when show-version
- (message "EditorConfig Emacs v%s"
- version-full))
+ (message "EditorConfig Emacs v%s" version-full))
version-full))
(provide 'editorconfig)
-
;;; editorconfig.el ends here
;; Local Variables:
diff --git a/ert-tests/editorconfig-core-handle.el
b/ert-tests/editorconfig-core-handle.el
index 96855ed22a..2c28137394 100644
--- a/ert-tests/editorconfig-core-handle.el
+++ b/ert-tests/editorconfig-core-handle.el
@@ -1,14 +1,38 @@
+;;; editorconfig-core-handle.el --- Tests editorconfig-core-handle -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2011-2022 EditorConfig Team
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin 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.
+
+;; EditorConfig Emacs Plugin 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
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests editorconfig-core-handle
+
+;;; Code:
+
(require 'editorconfig-core-handle)
-(defconst fixtures (concat (file-name-directory load-file-name)
- "fixtures/"))
+(defconst fixtures (concat (file-name-directory load-file-name) "fixtures/")
+ "Path to fixtures.")
(set-variable 'vc-handled-backends nil)
(ert-deftest test-editorconfig-core-handle ()
;; handle.ini
- (let* ((conf (concat fixtures
- "handle.ini"))
+ (let* ((conf (concat fixtures "handle.ini"))
(handle (editorconfig-core-handle conf)))
(should (editorconfig-core-handle-root-p handle))
(should (equal (editorconfig-core-handle-get-properties handle
@@ -20,8 +44,7 @@
"a.js"))
'((("key1" . "value1")) (("key2" . "value2"))))))
;; Test twice for checking cache
- (let* ((conf (concat fixtures
- "handle.ini"))
+ (let* ((conf (concat fixtures "handle.ini"))
(handle (editorconfig-core-handle conf)))
(should (editorconfig-core-handle-root-p handle))
(should (equal (editorconfig-core-handle-get-properties handle
@@ -34,8 +57,7 @@
'((("key1" . "value1")) (("key2" . "value2"))))))
;; handle2.ini
- (let* ((conf (concat fixtures
- "handle2.ini"))
+ (let* ((conf (concat fixtures "handle2.ini"))
(handle (editorconfig-core-handle conf)))
(should-not (editorconfig-core-handle-root-p handle))
(should (equal (editorconfig-core-handle-get-properties handle
@@ -53,3 +75,5 @@
(handle (editorconfig-core-handle conf)))
(should (editorconfig-core-handle-p handle)))
)
+
+;;; editorconfig-core-handle.el ends here
diff --git a/ert-tests/editorconfig-core.el b/ert-tests/editorconfig-core.el
index b7261fbac2..126ee1f514 100644
--- a/ert-tests/editorconfig-core.el
+++ b/ert-tests/editorconfig-core.el
@@ -1,16 +1,39 @@
+;;; editorconfig-core.el --- Tests editorconfig-core -*- lexical-binding: t
-*-
+
+;; Copyright (C) 2011-2022 EditorConfig Team
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin 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.
+
+;; EditorConfig Emacs Plugin 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
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests editorconfig-core
+
+;;; Code:
+
(require 'editorconfig-core)
(set-variable 'vc-handled-backends nil)
(ert-deftest test-editorconfig-core--get-handles ()
- (let* ((fixtures (concat default-directory
- "/ert-tests/fixtures/"))
- (dir (concat fixtures
- "dir1"))
+ (let* ((fixtures (concat default-directory "/ert-tests/fixtures/"))
+ (dir (concat fixtures "dir1"))
(confname "parent.ini")
- (handles (editorconfig-core--get-handles dir
- confname)))
- (should (= 2
- (length handles)))
+ (handles (editorconfig-core--get-handles dir confname)))
+ (should (= 2 (length handles)))
(should (editorconfig-core-handle-p (car handles)))
(should (editorconfig-core-handle-p (cadr handles)))))
+
+;;; editorconfig-core.el ends here
diff --git a/ert-tests/editorconfig-fnmatch.el
b/ert-tests/editorconfig-fnmatch.el
index 2c98eeb32b..6f2bd71786 100644
--- a/ert-tests/editorconfig-fnmatch.el
+++ b/ert-tests/editorconfig-fnmatch.el
@@ -1,3 +1,28 @@
+;;; editorconfig-fnmatch.el --- Tests editorconfig-fnmatch -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2011-2022 EditorConfig Team
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin 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.
+
+;; EditorConfig Emacs Plugin 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
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests editorconfig-fnmatch
+
+;;; Code:
+
(require 'editorconfig-fnmatch)
(set-variable 'vc-handled-backends nil)
@@ -103,8 +128,7 @@
("-1.js" "{3..-3}.js")
)))
(dolist (args cases-t)
- (message "-> t: %S"
- `(editorconfig-fnmatch-p ,@args))
+ (message "-> t: %S" `(editorconfig-fnmatch-p ,@args))
(message " Elapsed: %S"
(car (benchmark-run 3 (should (apply 'editorconfig-fnmatch-p
args))))))
@@ -115,3 +139,5 @@
(car (benchmark-run 3 (should-not (apply 'editorconfig-fnmatch-p
args)))))))
)
+
+;;; editorconfig-fnmatch.el ends here
diff --git a/ert-tests/editorconfig.el b/ert-tests/editorconfig.el
index 065485923f..16561430fd 100644
--- a/ert-tests/editorconfig.el
+++ b/ert-tests/editorconfig.el
@@ -1,3 +1,28 @@
+;;; editorconfig.el --- Tests editorconfig -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2022 EditorConfig Team
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin 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.
+
+;; EditorConfig Emacs Plugin 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
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests editorconfig
+
+;;; Code:
+
(require 'editorconfig)
(set-variable 'vc-handled-backends nil)
@@ -16,8 +41,7 @@
(declare (indent 1) (debug t))
`(let ((buf (find-file-noselect ,path)))
(unwind-protect
- (with-current-buffer buf
- ,@body)
+ (with-current-buffer buf ,@body)
(kill-buffer buf))))
;;; interactive
@@ -34,24 +58,20 @@
(should (featurep 'editorconfig)))
(defvar editorconfig-ert-dir
- (concat default-directory
- "ert-tests/plugin-tests/test_files/"))
+ (concat default-directory "ert-tests/plugin-tests/test_files/"))
(defvar editorconfig-secondary-ert-dir
- (concat default-directory
- "ert-tests/test_files_secondary/"))
+ (concat default-directory "ert-tests/test_files_secondary/"))
(ert-deftest test-editorconfig nil
"Check if properties are applied."
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-ert-dir
- "3_space.txt")
+ (with-visit-file (concat editorconfig-ert-dir "3_space.txt")
(should (eq tab-width 3))
(should (eq indent-tabs-mode nil)))
- (with-visit-file (concat editorconfig-ert-dir
- "4_space.py")
+ (with-visit-file (concat editorconfig-ert-dir "4_space.py")
(should (eq python-indent-offset 4))
(should (eq tab-width 8))
(should (eq indent-tabs-mode nil)))
@@ -60,34 +80,28 @@
(ert-deftest test-lisp-use-default-indent nil
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
(should (eq lisp-indent-offset 2)))
(let ((editorconfig-lisp-use-default-indent t))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
(should (eq lisp-indent-offset nil))))
(let ((editorconfig-lisp-use-default-indent 2))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
(should (eq lisp-indent-offset nil))))
(let ((editorconfig-lisp-use-default-indent 4))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "2_space.el")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "2_space.el")
(should (eq lisp-indent-offset 2))))
(editorconfig-mode -1))
(ert-deftest test-trim-trailing-ws nil
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-ert-dir
- "trim.txt")
+ (with-visit-file (concat editorconfig-ert-dir "trim.txt")
(should (memq 'delete-trailing-whitespace
write-file-functions)))
- (with-visit-file (concat editorconfig-ert-dir
- "trim.txt")
+ (with-visit-file (concat editorconfig-ert-dir "trim.txt")
(read-only-mode 1)
(should (not (memq 'delete-trailing-whitespace
write-file-functions))))
@@ -96,20 +110,17 @@
(ert-deftest test-file-type-emacs nil
:expected-result t ;; Ignore failure
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "c.txt")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "c.txt")
(should (eq major-mode 'conf-unix-mode)))
(editorconfig-mode -1))
(ert-deftest test-file-type-ext nil
:expected-result t ;; Ignore failure
(editorconfig-mode 1)
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "a.txt")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "a.txt")
(should (eq major-mode 'conf-unix-mode)))
- (with-visit-file (concat editorconfig-secondary-ert-dir
- "bin/perlscript")
+ (with-visit-file (concat editorconfig-secondary-ert-dir "bin/perlscript")
(should (eq major-mode 'perl-mode))
(should (eq perl-indent-level 5)))
(editorconfig-mode -1))
@@ -119,8 +130,9 @@
(add-hook 'editorconfig-hack-properties-functions
(lambda (props)
(puthash 'indent_size "5" props)))
- (with-visit-file (concat editorconfig-ert-dir
- "4_space.py")
+ (with-visit-file (concat editorconfig-ert-dir "4_space.py")
(should (eq python-indent-offset 5)))
(setq editorconfig-hack-properties-functions nil)
(editorconfig-mode -1))
+
+;;; editorconfig.el ends here
diff --git a/ert-tests/metadata.el b/ert-tests/metadata.el
index 0108579b1b..d1b0a9403c 100644
--- a/ert-tests/metadata.el
+++ b/ert-tests/metadata.el
@@ -1,3 +1,28 @@
+;;; metadata.el --- Metadata before ert-tests -*- lexical-binding: t -*-
+
+;; Copyright (C) 2011-2022 EditorConfig Team
+
+;; This file is part of EditorConfig Emacs Plugin.
+
+;; EditorConfig Emacs Plugin 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.
+
+;; EditorConfig Emacs Plugin 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
+;; EditorConfig Emacs Plugin. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Metadata before ert-tests
+
+;;; Code:
+
(require 'package)
(set-variable 'vc-handled-backends nil)
@@ -6,9 +31,9 @@
(ert-deftest test-metadata ()
(dolist (el metadata-el-files)
- (message "Loading info: %s"
- el)
+ (message "Loading info: %s" el)
(with-temp-buffer
(insert-file-contents el)
- (message "%S"
- (package-buffer-info)))))
+ (message "%S" (package-buffer-info)))))
+
+;;; metadata.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/editorconfig 5a80a5a11e: Drop Emacs 24.x and 25.x (#286),
ELPA Syncer <=