Skip to content

Commit

Permalink
Update for Emacs 29
Browse files Browse the repository at this point in the history
- Update CI.
- Update indentations.
- Replace `lsh' to `ash'.
- Replace `inhibit-changing-match-data' to `save-match-data'.
  • Loading branch information
taku0 committed Aug 19, 2023
1 parent f764a00 commit 9fff40e
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 103 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
strategy:
matrix:
version:
- '29.1'
- '28.2'
- '28.1'
- '27.2'
- '27.1'
Expand Down Expand Up @@ -42,9 +44,8 @@ jobs:
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
# WORKAROUND: disable for 24 to mitigate "Argument `_length' should appear
# (as _LENGTH) in the doc string".
if: ${{ !startsWith(matrix.version, '24.') }}
# Indentation rules changed since 29.
if: ${{ startsWith(matrix.version, '29.') }}
run: find ./*.el test/*.el '!' -name '*autoloads.el' -exec ${ELDEV} lint doc re elisp '{}' '+'
- name: Run tests
run: ./scripts/run_test.sh
8 changes: 4 additions & 4 deletions json-par-ancestor-overlay.el
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ If PREFIX-CHAR is non-nil, it is shown before the ancestor"
(define-key map [down-mouse-2] (lambda () (interactive)))
(define-key map [down-mouse-1] (lambda () (interactive)))
(define-key map [mouse-2]
(lambda ()
(interactive)
(push-mark)
(goto-char (json-par-token-start key-token))))
(lambda ()
(interactive)
(push-mark)
(goto-char (json-par-token-start key-token))))
(define-key map [follow-link] 'mouse-face)
map)
'mouse-face
Expand Down
24 changes: 12 additions & 12 deletions json-par-clone.el
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ interactively, mark the contents of the key."
(dolist (prefix '("" "C-" "M-" "C-M-"))
(dolist (key '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
(define-key
map
(kbd (concat prefix key))
#'json-par-prefix-digit-argument))
map
(kbd (concat prefix key))
#'json-par-prefix-digit-argument))
(define-key
map
(kbd (concat prefix "-"))
#'json-par-prefix-negative-argument))
map
(kbd (concat prefix "-"))
#'json-par-prefix-negative-argument))
(define-key map "\C-u" #'json-par-prefix-universal-argument)
(define-key map [t] #'json-par-prefix-default)
map)
Expand All @@ -402,13 +402,13 @@ interactively, mark the contents of the key."
(dolist (prefix '("" "C-" "M-" "C-M-"))
(dolist (key '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
(define-key
map
(kbd (concat prefix key))
#'json-par-prefix-digit-argument))
map
(kbd (concat prefix key))
#'json-par-prefix-digit-argument))
(define-key
map
(kbd (concat prefix "-"))
#'json-par-prefix-negative-argument))
map
(kbd (concat prefix "-"))
#'json-par-prefix-negative-argument))
(define-key map "\C-u" #'json-par-prefix-universal-argument)
(define-key map [t] #'json-par-prefix-default)
map)
Expand Down
4 changes: 2 additions & 2 deletions json-par-delete.el
Original file line number Diff line number Diff line change
Expand Up @@ -3520,9 +3520,9 @@ around the point."
(dolist (prefix '("" "C-" "M-" "C-M-"))
(dolist (key '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
(define-key map (kbd (concat prefix key))
#'json-par-prefix-digit-argument))
#'json-par-prefix-digit-argument))
(define-key map (kbd (concat prefix "-"))
#'json-par-prefix-negative-argument))
#'json-par-prefix-negative-argument))
(define-key map "\C-u" #'json-par-prefix-universal-argument)
(define-key map [t] #'json-par-prefix-default)
map)
Expand Down
4 changes: 3 additions & 1 deletion json-par-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ parent member."
(if (json-par--goto-end-of-previous-member)
(json-par--current-indentation)
(if (json-par-token-open-bracket-p (json-par-backward-token))
(+ (json-par--current-indentation) offset)
(+ (or parent-indentation
(json-par--current-indentation))
offset)
0))))))))))

(defun json-par--current-indentation ()
Expand Down
2 changes: 1 addition & 1 deletion json-par-insert.el
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ Return the end position of the region."
(setq replacement
(string (logior
#x10000
(lsh (- high-surrogate #xD800) 10)
(ash (- high-surrogate #xD800) 10)
(- low-surrogate #xDC00))))
;; Not a surrogate pair; go back to the first sequence
(setq match-end (- match-end 6))
Expand Down
2 changes: 1 addition & 1 deletion json-par-keymap.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Those functions are invoked by commands defined by
COMMAND is wrapped with `json-par-define-special-key-command' with SPECIAL-P."
(define-key keymap key
(json-par-define-special-key-command command special-p)))
(json-par-define-special-key-command command special-p)))

(defun json-par-define-special-key-command (command &optional special-p)
"Define a command that invokes COMMAND when SPECIAL-P return non-nil.
Expand Down
130 changes: 65 additions & 65 deletions json-par-oneline-multiline.el
Original file line number Diff line number Diff line change
Expand Up @@ -556,71 +556,71 @@ partially."
(json-par--huge-edit (point-min) (point-max)
(save-excursion
(goto-char (point-min))
(let ((inhibit-changing-match-data t)
(inhibit-modification-hooks t)
(level 0)
(offset (if (boundp 'js-indent-level)
(symbol-value 'js-indent-level)
2))
char
match-start
match-end
empty)
(while (search-forward-regexp "[][\"{}:,/]" nil t)
(setq char (char-before))
(cond
((or (eq char ?\[)
(eq char ?{))
(setq match-end (point))
(skip-chars-forward "\s\t")
(setq empty (or (eq (char-after) ?\])
(eq (char-after) ?\})))
(unless empty
(setq level (1+ level)))
(unless (eolp)
(delete-region match-end (point))
(insert ?\n)
(indent-to (* level offset)))
(when empty
(forward-char)))

((or (eq char ?\])
(eq char ?}))
(setq level (1- level))
(backward-char)
(setq match-start (point))
(skip-chars-backward "\s\t")
(unless (bolp)
(delete-region (point) match-start)
(insert ?\n)
(indent-to (* level offset)))
(forward-char))

((eq char ?,)
(setq match-end (point))
(skip-chars-forward "\s\t")
(unless (eolp)
(delete-region match-end (point))
(insert ?\n)
(indent-to (* level offset))))

((eq char ?:)
(unless (or (eq (char-after) ?\n)
(eq (char-after) ?\s)
(eq (char-after) ?\t))
(insert ?\s)))

((eq char ?\")
(json-par--skip-string))

((and (eq char ?/)
(eq (char-after) ?/))
(end-of-line))

((and (eq char ?/)
(eq (char-after) ?*))
(forward-char)
(json-par--skip-multiline-comment))))))))
(save-match-data
(let ((inhibit-modification-hooks t)
(level 0)
(offset (if (boundp 'js-indent-level)
(symbol-value 'js-indent-level)
2))
char
match-start
match-end
empty)
(while (search-forward-regexp "[][\"{}:,/]" nil t)
(setq char (char-before))
(cond
((or (eq char ?\[)
(eq char ?{))
(setq match-end (point))
(skip-chars-forward "\s\t")
(setq empty (or (eq (char-after) ?\])
(eq (char-after) ?\})))
(unless empty
(setq level (1+ level)))
(unless (eolp)
(delete-region match-end (point))
(insert ?\n)
(indent-to (* level offset)))
(when empty
(forward-char)))

((or (eq char ?\])
(eq char ?}))
(setq level (1- level))
(backward-char)
(setq match-start (point))
(skip-chars-backward "\s\t")
(unless (bolp)
(delete-region (point) match-start)
(insert ?\n)
(indent-to (* level offset)))
(forward-char))

((eq char ?,)
(setq match-end (point))
(skip-chars-forward "\s\t")
(unless (eolp)
(delete-region match-end (point))
(insert ?\n)
(indent-to (* level offset))))

((eq char ?:)
(unless (or (eq (char-after) ?\n)
(eq (char-after) ?\s)
(eq (char-after) ?\t))
(insert ?\s)))

((eq char ?\")
(json-par--skip-string))

((and (eq char ?/)
(eq (char-after) ?/))
(end-of-line))

((and (eq char ?/)
(eq (char-after) ?*))
(forward-char)
(json-par--skip-multiline-comment)))))))))

(defun json-par--check-long-line ()
"If the first line of the buffer is long, pretty print it.
Expand Down
24 changes: 12 additions & 12 deletions json-par.el
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,23 @@ Call `json-par--post-newline' after line break."
(json-par-define-special-key map "M" #'json-par-multiline)
(json-par-define-special-key map "O" #'json-par-oneline)
(define-key
map
[remap delete-backward-char]
#'json-par-delete-backward-char)
map
[remap delete-backward-char]
#'json-par-delete-backward-char)
(define-key
map
[remap delete-forward-char]
#'json-par-delete-forward-char)
map
[remap delete-forward-char]
#'json-par-delete-forward-char)
(define-key
map
[remap delete-char]
#'json-par-delete-forward-char)
map
[remap delete-char]
#'json-par-delete-forward-char)
(json-par-define-special-key map "m" #'json-par-mark-more)
(json-par-define-special-key map "N" #'json-par-narrow)
(define-key
map
[remap mark-sexp]
#'json-par-mark-more)
map
[remap mark-sexp]
#'json-par-mark-more)
(json-par-define-special-key map "S" #'json-par-split)
(json-par-define-special-key map "F" #'json-par-join)
(json-par-define-special-key map "c" #'json-par-clone-prefix-command)
Expand Down
3 changes: 2 additions & 1 deletion scripts/lint_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

# WORKAROUND: disable for 24 to mitigate "Argument `_length' should appear
# (as _LENGTH) in the doc string".
for version in 28 27 26 25 # 24
# Indentation rules changed since 29.
for version in 29 # 28 27 26 25 # 24
do
docker \
run \
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Run tests in Docker. Used in Makefile.

for version in 28 27 26 25 24
for version in 29 28 27 26 25 24
do
rm -f *.elc test/*.elc
rm -f *-autoloads.el
Expand Down

0 comments on commit 9fff40e

Please sign in to comment.