Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
taku0 committed Oct 23, 2021
0 parents commit c6c9a88
Show file tree
Hide file tree
Showing 64 changed files with 44,119 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
((emacs-lisp-mode . ((package-lint-main-file . "json-par.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))))
46 changes: 46 additions & 0 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
continue-on-error: ${{matrix.version == 'snapshot'}}

strategy:
matrix:
version:
- '27.2'
- '27.1'
- '26.3'
- '26.2'
- '26.1'
- '25.3'
- '25.2'
- '25.1'
- '24.5'
- '24.4'
- '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 doc re elisp '{}' '+'
- name: Run tests
run: ./scripts/run_test.sh
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*~
/.eldev/
*.elc
/dist/
json-par-autoloads.el
json-par-pkg.el
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions Eldev
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
;;; -*- mode: emacs-lisp; lexical-binding: t; no-byte-compile: t -*-

(eldev-use-package-archive 'gnu)
(eldev-use-package-archive 'melpa)

(eldev-add-extra-dependencies 'emacs 'json-mode)
(eldev-add-extra-dependencies 'eval 'json-mode)
(eldev-add-extra-dependencies 'test 'json-mode)

(setf eldev-standard-excludes
(append eldev-standard-excludes '("./documents/")))

(setq-default package-lint-main-file "json-par.el")
(setq-default indent-tabs-mode nil)
(setq-default fill-column 80)
(setq-default tab-width 8)
(setq-default checkdoc-arguments-in-order-flag nil)

(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
;; Exempt URLs for column length limit.
(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)))))
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
ELDEV_DIR ?= .eldev
ELDEV ?= eldev

INVOKE_ELDEV = ELDEV_DIR="${ELDEV_DIR}" ELDEV="${ELDEV}" ./scripts/invoke_eldev.sh

.PHONY: help all deps package install clean test test_in_docker lint lint_in_docker

help:
## Shows this message.
# Process this Makefile with following filters
#
# - Remove empty line.
# - Remove line starting with whitespace, dot, or uppercase letters.
# - Remove line containing ## no-doc.
# - Remove after colon if the line is not a comment line.
# - 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

all: package
## Builds the package.

deps:
## Installs the dependencies.
${INVOKE_ELDEV} prepare

package:
## Builds the package.
${INVOKE_ELDEV} package

install: package
## Installs the package.
${INVOKE_ELDEV} emacs --batch \
-l package \
-f package-initialize \
-f package-refresh-contents \
--eval '(package-install-file "'"$$( ls dist/*.tar | sort | tail -n 1 )"'")'

clean:
## Cleans the dist directory, *.elc, and .eldev.
${INVOKE_ELDEV} clean all

test:
## Tests the package.
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.
ELDEV_DIR="${ELDEV_DIR}" ELDEV="${ELDEV}" ./scripts/run_linter.sh

lint_in_docker:
## Run linter in Docker.
./scripts/lint_in_docker.sh
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
[![License GPL 3][badge-license]][copying]
[![Run Tests][badge-run-test]][action-run-test]
<!-- [![MELPA](https://melpa.org/packages/json-par-badge.svg)](https://melpa.org/#/json-par) -->
<!-- [![MELPA](https://stable.melpa.org/packages/json-par-badge.svg)](https://melpa.org/#/json-par) -->

# JSON Par mode

Emacs minor mode for structural editing of JSON, inspired by [`lispy`](https://github.com/abo-abo/lispy).


## Features

- [Ctrl-less, yet modeless](https://www.tatapa.org/~takuo/json-par/manual.html#ctrl-less-yet-modeless)

![](documents/images/modeless.svg)

- [Structural movement](https://www.tatapa.org/~takuo/json-par/manual.html#structural-movement)

![](documents/images/movements.svg)

- [`dabbrev`-like completion](https://www.tatapa.org/~takuo/json-par/manual.html#completion)

![](documents/images/guess.svg)

- [Converting single-line to/from multiline](https://www.tatapa.org/~takuo/json-par/manual.html#single-line-and-multiline)

![](documents/images/oneline_multiline.svg)

- [Cloning members](https://www.tatapa.org/~takuo/json-par/manual.html#cloning)

- [Marking/deleting various things](https://www.tatapa.org/~takuo/json-par/manual.html#mark-and-delete)

- And More!

See the [manual](https://www.tatapa.org/~takuo/json-par/manual.html) for details.


## Installation

Install `json-par` package from MELPA (coming soon).

To install without MELPA, download [latest release](https://github.com/taku0/json-par/releases) and execute `M-x package-install-file` for the .tar archive.

Then add the following line to your `.emacs`:

```elisp
(add-hook 'json-mode-hook (lambda () (json-par-mode 1)))
```

Enabling [`aggressive-indent-mode`](https://github.com/Malabarba/aggressive-indent-mode) is also recommended.

### Using only one or two functions

If you feel JSON Par mode officious, you can just pick a few functions and bind them to key sequences you like. Example:

```elisp
(require 'json-mode)
(require 'json-par-mode)
(define-key json-mode-map (kbd "M-/") 'json-par-insert-guessed)
(define-key json-mode-map (kbd "C-c a") 'json-par-beginning-of-member)
(define-key json-mode-map (kbd "C-c e") 'json-par-end-of-member)
(define-key json-mode-map (kbd "C-c c") 'json-par-clone-member-forward)
```


## Hacking

To build the package locally, run `make package`.

To install the built package, run `make install`.

To run tests, run `make test`.

Make sure to run `make lint` before submitting a pull request.

For other commands, run `make help`.

## About comments

Supporting comments with `jsonc-mode` is a hidden feature and intentionally undocumented. It may not work for some cases.


## Related projects

- [lispy](https://github.com/abo-abo/lispy): `json-par` is a `lispy` for JSON.
- [Paredit Mode](http://mumble.net/~campbell/emacs/paredit.el): “JSON Par mode” is named after Paredit Mode.
- [Puni](https://github.com/AmaiKinono/puni): Generic structured editing for many modees.
- [Symex mode](https://github.com/countvajhula/symex.el): Structural editing for Lisp.


## Acknowledgments

`json-par` is inspired from [`lispy`](https://github.com/abo-abo/lispy).

[Full list of contributors](https://github.com/taku0/json-par/graphs/contributors).


## License

GPLv3. See [COPYING][] for details. Copyright (C) 2021 taku0.

[badge-license]: https://img.shields.io/badge/license-GPL_3-green.svg
[badge-run-test]: https://github.com/taku0/json-par/workflows/Run%20Tests/badge.svg
[action-run-test]: https://github.com/taku0/json-par/actions?query=workflow%3A%22Run+Tests%22
[COPYING]: ./COPYING
Loading

0 comments on commit c6c9a88

Please sign in to comment.