[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 944de63e9d 298/427: Add functions to fix vector in
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 944de63e9d 298/427: Add functions to fix vector indentation. |
Date: |
Tue, 13 Dec 2022 02:59:53 -0500 (EST) |
branch: elpa/emacsql
commit 944de63e9d34654f1f3485c57ed523394d9b00c5
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Add functions to fix vector indentation.
---
README.md | 22 ++++++++++++++++++++++
emacsql.el | 26 ++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/README.md b/README.md
index 8a1758ac67..0714831c59 100644
--- a/README.md
+++ b/README.md
@@ -322,6 +322,28 @@ from the command line and allows for storage of Emacs
richer data
types. This is an efficient, ACID-compliant database specifically for
Emacs.
+## Emacs Lisp Indentation Annoyance
+
+By default, `emacs-lisp-mode` indents vectors as if they were regular
+function calls.
+
+```el
+;; Ugly indentation!
+(emacsql db [:select *
+ :from people
+ :where (> age 60)])
+```
+
+Calling the function `emacsql-fix-vector-indentation` (interactive)
+advises the major mode to fix this annoyance.
+
+```el
+;; Such indent!
+(emacsql db [:select *
+ :from people
+ :where (> age 60)])
+```
+
## Contributing and Extending
You'll need to install [Cask][cask], which is required for compilation
diff --git a/emacsql.el b/emacsql.el
index 0840c3b09d..cff35da308 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -380,4 +380,30 @@ A prefix argument causes the SQL to be printed into the
current buffer."
(emacsql-show-sql sql)))
(user-error "Invalid SQL: %S" sexp))))
+;; Fix Emacs' broken vector indentation:
+
+(defun emacsql--inside-vector-p ()
+ "Return non-nil if point is inside a vector expression."
+ (let ((start (point)))
+ (save-excursion
+ (backward-paragraph)
+ (let ((containing-sexp (elt (parse-partial-sexp (point) start) 1)))
+ (when containing-sexp
+ (setf (point) containing-sexp)
+ (looking-at "\\["))))))
+
+(defadvice calculate-lisp-indent (around emacsql-vector-indent disable)
+ "Don't indent vectors in `emacs-lisp-mode' like lists."
+ (if (emacsql--inside-vector-p)
+ (let ((lisp-indent-offset 1))
+ ad-do-it)
+ ad-do-it))
+
+(defun emacsql-fix-vector-indentation ()
+ "When called, advise `calculate-lisp-indent' to stop indenting vectors.
+Once activate, vector contents no longer indent like lists."
+ (interactive)
+ (ad-enable-advice 'calculate-lisp-indent 'around 'emacsql-vector-indent)
+ (ad-activate 'calculate-lisp-indent))
+
;;; emacsql.el ends here
- [nongnu] elpa/emacsql d3d76ea72a 409/427: make: Use essentially same Makefile as for other packages I maintain, (continued)
- [nongnu] elpa/emacsql d3d76ea72a 409/427: make: Use essentially same Makefile as for other packages I maintain, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b4d5ef41fe 410/427: make: Don't require pg.el to be available to build and test, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5818000c7d 412/427: make: Update pg repository url, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0da3f06e89 416/427: Fix docstring typo, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 20cdad6fe6 417/427: Include sqlite error code in error data, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1becb00945 419/427: Define a few constants as such, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 40c41d0d97 421/427: Release version 3.1.0, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql bfbd0c3a73 422/427: Resume development, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 5c4aa1030b 415/427: Do not warn about missing pg functions, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql be95788334 214/427: Use global timeout in tests., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 944de63e9d 298/427: Add functions to fix vector indentation.,
ELPA Syncer <=
- [nongnu] elpa/emacsql e061847083 302/427: Improve emacsql-fix-vector-indentation., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3f3c36a403 341/427: Expand identifier vectors when passed as parameters (#7)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 1de10e8ad4 357/427: Fix warning in emacsql-sqlite initialize-instance (#38), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 488e7ebbb5 380/427: Change defvar to defconst for emacsql-version (fix #53), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e80281487b 399/427: Bump back-ends' dependency on emacsql, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ec4f3d091b 424/427: Resume development, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c1a44076c0 423/427: Release version 3.1.1, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6b2e65bdf7 427/427: Use new version string format for unreleased revisions, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 08eb5aed26 406/427: Update to SQLite 3.39.3, ELPA Syncer, 2022/12/13