[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog 4299c39d62 070/166: ENHANCED: indentation edge
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog 4299c39d62 070/166: ENHANCED: indentation edge cases handling |
Date: |
Fri, 30 Sep 2022 04:59:27 -0400 (EDT) |
branch: elpa/sweeprolog
commit 4299c39d62f4191ed85f46b15f800f768397d430
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
ENHANCED: indentation edge cases handling
---
sweep.el | 53 +++++++++++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/sweep.el b/sweep.el
index 0f61dd70a1..69fdac0eb2 100644
--- a/sweep.el
+++ b/sweep.el
@@ -877,20 +877,18 @@ Interactively, a prefix arg means to prompt for BUFFER."
(defun sweep-indent-line ()
(interactive)
- (when-let ((ppss (syntax-ppss))
- (pos (- (point-max) (point)))
- (indent (sweep-indent-line-indentation ppss)))
+ (when-let ((pos (- (point-max) (point)))
+ (indent (sweep-indent-line-indentation (point))))
(back-to-indentation)
- (if (= indent (current-column))
- 'noindent
- (beginning-of-line)
- (combine-after-change-calls
- (delete-horizontal-space)
- (insert (make-string indent ? )))
- (if (> (- (point-max) pos) (point))
- (goto-char (- (point-max) pos))))))
-
-(defun sweep-indent-line-indentation (ppss)
+ (beginning-of-line)
+ (combine-after-change-calls
+ (delete-horizontal-space)
+ (insert (make-string indent ? )))
+ (when (> (- (point-max) pos) (point))
+ (goto-char (- (point-max) pos)))
+ t))
+
+(defun sweep-indent-line-indentation (point)
(save-match-data
(save-excursion
(beginning-of-line)
@@ -899,14 +897,16 @@ Interactively, a prefix arg means to prompt for BUFFER."
((sweep-indent-line-ends-with-comment-or-string-p) 0)
((sweep-indent-line-ends-with-fullstop-p) 0)
((sweep-indent-line-ends-with-if))
- ((sweep-indent-line-ends-with-then ppss))
- ((sweep-indent-line-ends-with-else ppss))
- ((sweep-indent-line-ends-with-arg ppss))
+ ((sweep-indent-line-ends-with-then point))
+ ((sweep-indent-line-ends-with-else point))
+ ((sweep-indent-line-ends-with-arg point))
((sweep-indent-line-ends-with-neck-p) 4)
(t (sweep-indent-line-fallback))))))
(defun sweep-indent-line-fallback ()
(save-excursion
+ (when-let ((open (nth 1 (syntax-ppss))))
+ (goto-char open))
(back-to-indentation)
(current-column)))
@@ -920,9 +920,12 @@ Interactively, a prefix arg means to prompt for BUFFER."
(when (looking-at-p (rx "( "))
col))))))
-(defun sweep-indent-line-ends-with-then (ppss)
+(defun sweep-indent-line-ends-with-then (point)
(save-excursion
- (when-let ((orig (nth 1 ppss))
+ (when-let ((orig (save-mark-and-excursion
+ (goto-char point)
+ (back-to-indentation)
+ (nth 1 (syntax-ppss))))
(start-of-ite (nth 1 (syntax-ppss))))
(when (= start-of-ite orig)
(back-to-indentation)
@@ -930,9 +933,12 @@ Interactively, a prefix arg means to prompt for BUFFER."
(when (looking-at-p (rx "-> "))
col))))))
-(defun sweep-indent-line-ends-with-else (ppss)
+(defun sweep-indent-line-ends-with-else (point)
(save-excursion
- (when-let ((orig (nth 1 ppss))
+ (when-let ((orig (save-mark-and-excursion
+ (goto-char point)
+ (back-to-indentation)
+ (nth 1 (syntax-ppss))))
(start-of-ite (nth 1 (syntax-ppss))))
(when (= start-of-ite orig)
(back-to-indentation)
@@ -940,10 +946,13 @@ Interactively, a prefix arg means to prompt for BUFFER."
(when (looking-at-p (rx "; "))
col))))))
-(defun sweep-indent-line-ends-with-arg (ppss)
+(defun sweep-indent-line-ends-with-arg (point)
(save-excursion
(end-of-line)
- (when-let ((orig (nth 1 ppss))
+ (when-let ((orig (save-mark-and-excursion
+ (goto-char point)
+ (back-to-indentation)
+ (nth 1 (syntax-ppss))))
(start-of-ite (nth 1 (syntax-ppss))))
(when (= start-of-ite orig)
(goto-char start-of-ite)
- [nongnu] elpa/sweeprolog 6dd6433920 165/166: ENHANCED: fontify quasi-quotation content according to its type, (continued)
- [nongnu] elpa/sweeprolog 6dd6433920 165/166: ENHANCED: fontify quasi-quotation content according to its type, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 48e8fb7c65 155/166: ENHANCED: (sweep--colour-term-to-face): return multiple regions, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1c87ca72e3 163/166: DOC: document new variable highlighting in the manual, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a8d186092f 157/166: ENHANCED: More indicative error on failure to locate sweep-module, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 97856b5c85 159/166: DOC: add installation instructions from NonGNU ELPA, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 348294a57f 002/166: Add swipl-devel submodule, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b2838d5477 004/166: Cleanup, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4f96499382 011/166: DOC: expand README.org, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5c4aef50f2 041/166: Run `ninja install` as root in CI, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a6e37f306b 069/166: ENHANCED: fontify mutlifile predicate calls in a dedicated face, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4299c39d62 070/166: ENHANCED: indentation edge cases handling,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog 1a19f7b3be 074/166: DOC: document font-lock and xref integration for sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1c6d2e96a8 078/166: ENHANCED: allow user to specify location of swipl binary, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5a8f70149f 099/166: FIXED: (sweep-load-buffer): error after prompting for a buffer, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7327016d15 095/166: FIXED: sweep_predicates_collection/2: include preds defined in user, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a70a730f48 087/166: PORT: don't use the 2nd arg to looking-at, added only in Emacs 29, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog d1a2913f75 115/166: ENHANCED: Update semantic highlighting on idle timer in sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b168465391 098/166: FIXED: sweep_load_buffer/3: load files in the context of "user", ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog db7ef44a61 083/166: DOC: add manual section about setting Prolog flags, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 521a4bfde5 132/166: BUILD: replaced Makefile with CMakeLists.txt, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog ecf601dd54 133/166: FIXED: indentation error when typing at end of buffer, ELPA Syncer, 2022/09/30