[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sml-mode 0c8e382 20/45: * sml-mode.el (sml--rightalign-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/sml-mode 0c8e382 20/45: * sml-mode.el (sml--rightalign-and-p): New function. |
Date: |
Tue, 1 Dec 2020 10:01:39 -0500 (EST) |
branch: externals/sml-mode
commit 0c8e382025beb500bc6f4877804ea6155bfe2ea9
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* sml-mode.el (sml--rightalign-and-p): New function.
---
sml-mode.el | 26 +++++++++++++++++++++++++-
testcases.sml | 1 +
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/sml-mode.el b/sml-mode.el
index e9c2477..a46d9ff 100644
--- a/sml-mode.el
+++ b/sml-mode.el
@@ -487,6 +487,30 @@ Regexp match data 0 points to the chars."
(defvar sml-indent-separator-outdent 2)
+(defun sml--rightalign-and-p ()
+ (when sml-rightalign-and
+ ;; Only right-align the "and" if the intervening code is more deeply
+ ;; indented, to avoid things like:
+ ;; datatype foo
+ ;; = Foo of int
+ ;; and bar = Bar of string
+ (save-excursion
+ (let ((max (line-end-position 0))
+ (data (smie-backward-sexp "and"))
+ (startcol (save-excursion
+ (forward-comment (- (point)))
+ (current-column)))
+ (mincol (current-column)))
+ (save-excursion
+ (search-forward "=" max t)
+ (forward-line 1)
+ (if (< (point) max) (setq max (point))))
+ (while (and (<= (point) max) (not (eobp)))
+ (skip-chars-forward " \t")
+ (setq mincol (current-column))
+ (forward-line 1))
+ (>= mincol startcol)))))
+
(defun sml-smie-rules (kind token)
;; I much preferred the pcase version of the code, especially while
;; edebugging the code. But that will have to wait until we get rid of
@@ -528,7 +552,7 @@ Regexp match data 0 points to the chars."
((equal token "and")
;; FIXME: maybe "and" (c|sh)ould be handled as an smie-separator.
(cond
- ((smie-rule-parent-p "datatype") (if sml-rightalign-and 5 0))
+ ((smie-rule-parent-p "datatype") (if (sml--rightalign-and-p) 5 0))
((smie-rule-parent-p "fun" "val") 0)))
((equal token "d=")
(cond
diff --git a/testcases.sml b/testcases.sml
index 0e98ed6..14b73d3 100644
--- a/testcases.sml
+++ b/testcases.sml
@@ -142,6 +142,7 @@ val x =
datatype foobar
= FooB of int
| FooA of bool * int
+and baz = QUX of foo
datatype foo = FOO | BAR of baz
and baz = BAZ | QUUX of foo
- [elpa] externals/sml-mode 8cf8d27 30/45: * sml-mode/sml-mode.el: Bump version to make a new release, (continued)
- [elpa] externals/sml-mode 8cf8d27 30/45: * sml-mode/sml-mode.el: Bump version to make a new release, Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 020dff3 05/45: * packages/sml-mode/sml-mode.el (sml-mode-map): Add back C-c C-s binding., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 4e8f05e 02/45: Add SML-mode., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 52c5896 04/45: * sml-mode.el: Integrate BUGS&NEWS; re-add run-sml., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 4ba89ca 08/45: * sml-mode.el (inferior-sml-mode): Fix comint-completion-addsuffix., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 6f9f11e 09/45: * sml-mode.el (sml-mode-variables): Set sml-prog-proc-descriptor here..., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 29c8a36 11/45: * sml-mode: Release 6.3, bugfixes, Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 04e69e0 13/45: * packages/sml-mode/sml-mode.el (sml-imenu-regexp): Make it a const., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 8dbbf1b 12/45: * sml-mode: Release 6.3, bugfixes, Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode d7e20dc 14/45: * packages/sml-mode/sml-mode.el (sml-imenu-regexp): Make it a const., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 0c8e382 20/45: * sml-mode.el (sml--rightalign-and-p): New function.,
Stefan Monnier <=
- [elpa] externals/sml-mode e027ddf 25/45: * sml-mode.el: Add prettify-symbols-mode and Poly/ML support, Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 870c8fc 29/45: * sml-mode/sml-mode.el: Bump version to make a new release, Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 9b98622 16/45: * sml-mode.el (sml-smie-rules): Adjust for new :close-all rule., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 43cf0b2 28/45: * sml-mode/sml-mode.el (sml-smie-rules): Work around Emacs-24.3 bug., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode a13e847 24/45: * packages/sml-mode/sml-mode.el (sml-smie-grammar): Add "withtype"., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode c161959 38/45: * packages/sml-mode/sml-mode.el (sml-smie-rules): Remove incoherent rule., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 20d8e4a 44/45: * packages/sml-mode/sml-mode.el: Parse "local" correctly, Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 9f8cf83 18/45: * sml-mode/sml-mode.el (sml-smie-grammar): Add include&sharing., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode 13c27de 22/45: * sml-mode/sml-mode.el: Release new version., Stefan Monnier, 2020/12/01
- [elpa] externals/sml-mode cdc5caf 35/45: * packages/sml-mode/sml-mode.el (sml-tyvarseq-re): Backtrack less (bug#24205), Stefan Monnier, 2020/12/01