unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26187: Bug in indent-sexp
@ 2017-03-20  1:18 Gdobbins
  2017-03-20 13:20 ` npostavs
  2017-03-22  0:49 ` npostavs
  0 siblings, 2 replies; 6+ messages in thread
From: Gdobbins @ 2017-03-20  1:18 UTC (permalink / raw)
  To: 26187


[-- Attachment #1.1: Type: text/plain, Size: 318 bytes --]

The refactor of indent-sexp in commit 3ee3995d105ff02f0fac540757431d36cb45c6c7 broke the assumption

;; If ENDPOS is nil, it is safe not to scan before point
;; since every line we indent is more deeply nested than point is.

thereby breaking functionality in paredit. The attached patch fixes this.

-- Graham Dobbins

[-- Attachment #1.2: Type: text/html, Size: 719 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-emacs-lisp-lisp-mode.el-indent-sexp-Fix-null-en.patch --]
[-- Type: text/x-patch; name="0001-lisp-emacs-lisp-lisp-mode.el-indent-sexp-Fix-null-en.patch", Size: 1284 bytes --]

From aac47fbcdc6175ead9caf9f903f24100a2805ccc Mon Sep 17 00:00:00 2001
From: Graham Dobbins <gdobbins@protonmail.com>
Date: Sun, 19 Mar 2017 21:06:18 -0400
Subject: [PATCH] * lisp/emacs-lisp/lisp-mode.el (indent-sexp): Fix null endpos
 case

---
 lisp/emacs-lisp/lisp-mode.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index eb07c18b03..d6293c0304 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1083,7 +1083,8 @@ indent-sexp
          (init-depth (car state))
          (next-depth init-depth)
          (last-depth init-depth)
-         (last-syntax-point (point)))
+         (last-syntax-point (point))
+         (real-endpos endpos))
     (unless endpos
       ;; Get error now if we don't have a complete sexp after point.
       (save-excursion (forward-sexp 1)
@@ -1116,6 +1117,8 @@ indent-sexp
                 last-depth (- last-depth next-depth)
                 next-depth init-depth))
         (forward-line 1)
+        (when (and (not real-endpos) (<= next-depth init-depth))
+          (goto-char endpos))
         (when (< (point) endpos)
           (let ((depth-delta (- next-depth last-depth)))
             (cond ((< depth-delta 0)
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#26187: Bug in indent-sexp
  2017-03-20  1:18 bug#26187: Bug in indent-sexp Gdobbins
@ 2017-03-20 13:20 ` npostavs
  2017-03-20 20:00   ` Gdobbins
  2017-03-22  0:49 ` npostavs
  1 sibling, 1 reply; 6+ messages in thread
From: npostavs @ 2017-03-20 13:20 UTC (permalink / raw)
  To: Gdobbins; +Cc: 26187

Gdobbins <gdobbins@protonmail.com> writes:

> The refactor of indent-sexp in commit 3ee3995d105ff02f0fac540757431d36cb45c6c7 broke the assumption
>
> ;; If ENDPOS is nil, it is safe not to scan before point
> ;; since every line we indent is more deeply nested than point is.
>
> thereby breaking functionality in paredit. The attached patch fixes
> this.

Could you post the scenario which is broken?  I have a another pending
change to indent-sexp for Bug#25122 [1] which actually removes the
rescanning completely, but I'm not sure if that would rebreak this
scenario or fix it...

[1]: https://debbugs.gnu.org/cgi/bugreport.cgi?att=1;bug=25122;msg=74;filename=v2-0001-Don-t-reparse-the-sexp-in-indent-sexp-Bug-25122.patch





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26187: Bug in indent-sexp
  2017-03-20 13:20 ` npostavs
@ 2017-03-20 20:00   ` Gdobbins
  2017-03-21  3:22     ` npostavs
  0 siblings, 1 reply; 6+ messages in thread
From: Gdobbins @ 2017-03-20 20:00 UTC (permalink / raw)
  To: npostavs; +Cc: 26187

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

Sure. In the form:

(defun lisp-indent-defform (state _indent-point)
(goto-char (car (cdr state)))
(forward-line 1)
(if (> (point) (car (cdr (cdr state))))|
(progn
(goto-char (car (cdr state)))

(+ lisp-body-indent (current-column)))))

where | is point, call indent-sexp and the result will be

(defun lisp-indent-defform (state _indent-point)
(goto-char (car (cdr state)))
(forward-line 1)
(if (> (point) (car (cdr (cdr state))))|
(progn
(goto-char (car (cdr state)))

(+ lisp-body-indent (current-column)))))

which is incorrect.

-- Graham Dobbins

[-- Attachment #2: Type: text/html, Size: 1646 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26187: Bug in indent-sexp
  2017-03-20 20:00   ` Gdobbins
@ 2017-03-21  3:22     ` npostavs
  2017-03-21  4:24       ` Gdobbins
  0 siblings, 1 reply; 6+ messages in thread
From: npostavs @ 2017-03-21  3:22 UTC (permalink / raw)
  To: Gdobbins; +Cc: 26187

tags 26187 patch
quit

Gdobbins <gdobbins@protonmail.com> writes:

> Sure. In the form:
> 
> (defun lisp-indent-defform (state _indent-point)
>   (goto-char (car (cdr state)))
>   (forward-line 1)
>   (if (> (point) (car (cdr (cdr state))))|
>       (progn
>         (goto-char (car (cdr state)))
>         (+ lisp-body-indent (current-column)))))
> 
> where | is point, call indent-sexp and the result will be
> 
> (defun lisp-indent-defform (state _indent-point)
>   (goto-char (car (cdr state)))
>   (forward-line 1)
>   (if (> (point) (car (cdr (cdr state))))|
> (progn
>   (goto-char (car (cdr state)))
>   (+ lisp-body-indent (current-column)))))
> 
> which is incorrect.

Hmm, the original behaviour is that no indentation happens at all which
seems kind of odd to me.  But that's better than breaking things I
guess.  Have you done copyright assignment for Emacs, or should I mark
your patch as a tiny change?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26187: Bug in indent-sexp
  2017-03-21  3:22     ` npostavs
@ 2017-03-21  4:24       ` Gdobbins
  0 siblings, 0 replies; 6+ messages in thread
From: Gdobbins @ 2017-03-21  4:24 UTC (permalink / raw)
  To: npostavs; +Cc: 26187

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]

I have not yet done a copyright assignment.

-- Graham Dobbins

-------- Original Message --------
Subject: Re: bug#26187: Bug in indent-sexp
Local Time: March 20, 2017 11:20 PM
UTC Time: March 21, 2017 3:20 AM
From: npostavs@users.sourceforge.net
To: Gdobbins <gdobbins@protonmail.com>
26187@debbugs.gnu.org

tags 26187 patch
quit

Gdobbins <gdobbins@protonmail.com> writes:

> Sure. In the form:
>
> (defun lisp-indent-defform (state _indent-point)
> (goto-char (car (cdr state)))
> (forward-line 1)
> (if (> (point) (car (cdr (cdr state))))|
> (progn
> (goto-char (car (cdr state)))
> (+ lisp-body-indent (current-column)))))
>
> where | is point, call indent-sexp and the result will be
>
> (defun lisp-indent-defform (state _indent-point)
> (goto-char (car (cdr state)))
> (forward-line 1)
> (if (> (point) (car (cdr (cdr state))))|
> (progn
> (goto-char (car (cdr state)))
> (+ lisp-body-indent (current-column)))))
>
> which is incorrect.

Hmm, the original behaviour is that no indentation happens at all which
seems kind of odd to me. But that's better than breaking things I
guess. Have you done copyright assignment for Emacs, or should I mark
your patch as a tiny change?

[-- Attachment #2: Type: text/html, Size: 2166 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#26187: Bug in indent-sexp
  2017-03-20  1:18 bug#26187: Bug in indent-sexp Gdobbins
  2017-03-20 13:20 ` npostavs
@ 2017-03-22  0:49 ` npostavs
  1 sibling, 0 replies; 6+ messages in thread
From: npostavs @ 2017-03-22  0:49 UTC (permalink / raw)
  To: Gdobbins; +Cc: 26187

tags 26187 fixed
close 26187 
quit

Gdobbins <gdobbins@protonmail.com> writes:

> The refactor of indent-sexp in commit 3ee3995d105ff02f0fac540757431d36cb45c6c7 broke the assumption
>
> ;; If ENDPOS is nil, it is safe not to scan before point
> ;; since every line we indent is more deeply nested than point is.
>
> thereby breaking functionality in paredit. The attached patch fixes this.
>

Pushed to master [1: bcb6c7b7cd], added test in [2: 0b60d7657a].

1: 2017-03-21 20:45:31 -0400 bcb6c7b7cd954fc653fe54c20aa4a5d8dd97d76d
  * lisp/emacs-lisp/lisp-mode.el (indent-sexp): Fix null endpos case

2: 2017-03-21 20:45:32 -0400 0b60d7657a2d9e5f9a233032643b0f3ce55420ee
  * test/lisp/emacs-lisp/lisp-mode-tests.el (indent-subsexp): Test for Bug#26187





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-03-22  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-20  1:18 bug#26187: Bug in indent-sexp Gdobbins
2017-03-20 13:20 ` npostavs
2017-03-20 20:00   ` Gdobbins
2017-03-21  3:22     ` npostavs
2017-03-21  4:24       ` Gdobbins
2017-03-22  0:49 ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).