From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#32014: 26.1; lisp-indent-line fails in first line of Ielm Date: Fri, 29 Jun 2018 20:23:13 -0400 Message-ID: <87sh55m8b2.fsf@gmail.com> References: <876021mb84.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1530318130 30770 195.159.176.226 (30 Jun 2018 00:22:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Jun 2018 00:22:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 32014@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 30 02:22:06 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZ3eP-0007sQ-Jp for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Jun 2018 02:22:05 +0200 Original-Received: from localhost ([::1]:44997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ3gU-0007Mi-HL for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Jun 2018 20:24:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ3gN-0007Ly-JO for bug-gnu-emacs@gnu.org; Fri, 29 Jun 2018 20:24:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZ3gI-0002a4-Ko for bug-gnu-emacs@gnu.org; Fri, 29 Jun 2018 20:24:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60548) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZ3gI-0002ZX-D5 for bug-gnu-emacs@gnu.org; Fri, 29 Jun 2018 20:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fZ3gI-0000Im-6u for bug-gnu-emacs@gnu.org; Fri, 29 Jun 2018 20:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Jun 2018 00:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32014 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 32014-submit@debbugs.gnu.org id=B32014.15303182031094 (code B ref 32014); Sat, 30 Jun 2018 00:24:02 +0000 Original-Received: (at 32014) by debbugs.gnu.org; 30 Jun 2018 00:23:23 +0000 Original-Received: from localhost ([127.0.0.1]:40212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZ3ff-0000HV-FA for submit@debbugs.gnu.org; Fri, 29 Jun 2018 20:23:23 -0400 Original-Received: from mail-it0-f48.google.com ([209.85.214.48]:52579) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fZ3fd-0000HA-QN; Fri, 29 Jun 2018 20:23:22 -0400 Original-Received: by mail-it0-f48.google.com with SMTP id p4-v6so5165522itf.2; Fri, 29 Jun 2018 17:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2S8g+sf1X3+nvtBaCYCVbdTeZiyUp/Zp0kARd8A/rX8=; b=cpx6GTugFTzKcEfUZ8m08SnOLx/W6cWPXubF3DbI44lWHOIo2Yc87f97ssPGZu5YB/ fWx4loUNi5HozWX/bFSkrU1syiMsL5vzJY2oSvmaMQAMvY9YR6NiwV5g8/9HwbAUQX/q yHgH1tDr8EODd92ywxU7zocDBGq+GByhbw/4c2xbjT3OlGlAh4ipkLtur9dlNOfY4N8Z uUnBYxGFivgJ5jejzoJrw+lBQYHBZVJt2iW5MrQsVAEeIBzTb/KODZ7rz8dmiqc+KRon sYYh2Rm1Hb2dS3zHwPtMOKg8kmbG8RIAZrOZNMaKP+B6Ki1VD5xeH1VNTXEB5CsJf101 +cFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=2S8g+sf1X3+nvtBaCYCVbdTeZiyUp/Zp0kARd8A/rX8=; b=TyX7xxByz92vwOt7SGI+pJLvZv2obX0TbG9DOIhXt3zqAtV8UphiH+S18dvXMHmyhC KuRmSfArrXJkP4Ult3G99iVqduHqwTwoWAgxSeCXbMSpAGkJAUNcbAA3SJx2nIQ0mXrZ KorbgjJKI9Po1tD1pUdMowce16USzwyc4mmq02+OK0deeOo1CWqCvrJjSZKs3huwz7r4 g0GIG+/2kg5HGuz5W8fjts/6EPD0YaIN4YZtDvx+8FiBvIVyrjF/82uijhMwatDGcVVp OtmCQgDv4iJCoPtM84ttJe7RJHGYiF9l4soC59g3TJBRo8Hass5Qk5A8nfg0m+BHPYFX 6KzQ== X-Gm-Message-State: APt69E34gjbxh5a7mRrLnBxIt6fU+/3Q60HUOyYPuRxfRvXn/O72ovjG clIPYujYnZyyhQl5TS0WIC6c9w== X-Google-Smtp-Source: AAOMgpceKQJn6olWmI/Ye2lCMgEt93VssEoFtYfWkNt2MJyjikpX15NvD2KTRRWLTTBib9Z8U+Rz2A== X-Received: by 2002:a24:d00b:: with SMTP id m11-v6mr3570938itg.97.1530318196119; Fri, 29 Jun 2018 17:23:16 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id p130-v6sm5027733ioe.81.2018.06.29.17.23.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 17:23:14 -0700 (PDT) In-Reply-To: <876021mb84.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sat, 30 Jun 2018 00:20:11 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147982 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 32014 + patch quit Jo=C3=A3o T=C3=A1vora writes: > The error's backtrace isn't shown even with debug-on-error set to t. If you (setq debug-ignored-errors nil) first, then the backtrace is Debugger entered--Lisp error: (text-read-only) indent-line-to(7) lisp-indent-line() funcall-interactively(lisp-indent-line) call-interactively(lisp-indent-line record nil) command-execute(lisp-indent-line record) execute-extended-command(nil "lisp-indent-line" "lisp-indent-line") funcall-interactively(execute-extended-command nil "lisp-indent-line" "li= sp-indent-line") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command) > Is this the intended behaviour? In 25.2 the string foo was correctly > indented back one character, so this seems like a regression. No, it's an accident. In lisp-indent-line, I simplified=20 (setq shift-amt (- indent (current-column))) (if (zerop shift-amt) nil (delete-region beg (point)) (indent-to indent))) into (indent-line-to indent) but it turns out not be equivalent in this case. indent-line-to doesn't respect the prompt's field property. I propose this for emacs-26: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Test-for-Bug-32014.patch Content-Description: patch >From 2524780c54bcd8faecdb8497c0e1c960752fc9ce Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 29 Jun 2018 20:15:10 -0400 Subject: [PATCH v1 1/2] ; Test for Bug#32014 * test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-indent-with-read-only-field): New test. --- test/lisp/emacs-lisp/lisp-mode-tests.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index 0b5b0a4019..2ac0e5ce1d 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el @@ -224,6 +224,17 @@ lisp-mode-tests--correctly-indented-sexp (comment-indent) (should (equal (buffer-string) correct))))) +(ert-deftest lisp-indent-with-read-only-field () + "Test indentation on line with read-only field (Bug#32014)." + :expected-result :failed + (with-temp-buffer + (insert (propertize "prompt> " 'field 'output 'read-only t + 'rear-nonsticky t 'front-sticky '(read-only))) + (insert " foo") + (lisp-indent-line) + (should (equal (buffer-string) "prompt> foo")))) + + (provide 'lisp-mode-tests) ;;; lisp-mode-tests.el ends here -- 2.11.0 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0002-Stop-using-indent-line-to-in-lisp-indent-line-Bug.patch Content-Description: patch >From 98e30ee9505f6e8cd21a36b88223e29ad9ee8281 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 29 Jun 2018 19:58:58 -0400 Subject: [PATCH v1 2/2] Stop using indent-line-to in lisp-indent-line (Bug#32014) This is partial revert of "Remove ignored argument from lisp-indent-line", because `indent-line-to' doesn't respect field boundaries. * lisp/emacs-lisp/lisp-mode.el (lisp-indent-line): Use delete-region and indent-to instead of `indent-line-to'. * test/lisp/emacs-lisp/lisp-mode-tests.el (lisp-indent-with-read-only-field): Expect to pass. Don't merge to master, we will fix indent-line-to there instead. --- lisp/emacs-lisp/lisp-mode.el | 10 ++++++++-- test/lisp/emacs-lisp/lisp-mode-tests.el | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 94be5acd6d..3a03b56313 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -867,7 +867,9 @@ lisp-indent-line (interactive) (let ((pos (- (point-max) (point))) (indent (progn (beginning-of-line) - (or indent (calculate-lisp-indent (lisp-ppss)))))) + (or indent (calculate-lisp-indent (lisp-ppss))))) + (shift-amt nil) + (beg (progn (beginning-of-line) (point)))) (skip-chars-forward " \t") (if (or (null indent) (looking-at "\\s<\\s<\\s<")) ;; Don't alter indentation of a ;;; comment line @@ -879,7 +881,11 @@ lisp-indent-line ;; as comment lines, not as code. (progn (indent-for-comment) (forward-char -1)) (if (listp indent) (setq indent (car indent))) - (indent-line-to indent)) + (setq shift-amt (- indent (current-column))) + (if (zerop shift-amt) + nil + (delete-region beg (point)) + (indent-to indent))) ;; If initial point was within line's indentation, ;; position after the indentation. Else stay at same point in text. (if (> (- (point-max) pos) (point)) diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el index 2ac0e5ce1d..8598d41978 100644 --- a/test/lisp/emacs-lisp/lisp-mode-tests.el +++ b/test/lisp/emacs-lisp/lisp-mode-tests.el @@ -226,7 +226,6 @@ lisp-mode-tests--correctly-indented-sexp (ert-deftest lisp-indent-with-read-only-field () "Test indentation on line with read-only field (Bug#32014)." - :expected-result :failed (with-temp-buffer (insert (propertize "prompt> " 'field 'output 'read-only t 'rear-nonsticky t 'front-sticky '(read-only))) -- 2.11.0 --=-=-= Content-Type: text/plain and this for master: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Respect-field-boundaries-in-to-indentation-functions.patch Content-Description: patch >From 2dccc6d64669078915a7eda75f40e75408b7794e Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 29 Jun 2018 20:01:53 -0400 Subject: [PATCH] Respect field boundaries in *-to-indentation functions (Bug#32014) * lisp/simple.el (forward-to-indentation) (backward-to-indentation): Use `beginning-of-line' which respects field boundaries rather than `forward-line' which doesn't. --- lisp/simple.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index f8c02c1dbf..3cece52657 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -872,13 +872,13 @@ quoted-insert (defun forward-to-indentation (&optional arg) "Move forward ARG lines and position at first nonblank character." (interactive "^p") - (forward-line (or arg 1)) + (beginning-of-line (+ 1 (or arg 1))) (skip-chars-forward " \t")) (defun backward-to-indentation (&optional arg) "Move backward ARG lines and position at first nonblank character." (interactive "^p") - (forward-line (- (or arg 1))) + (beginning-of-line (- 1 (or arg 1))) (skip-chars-forward " \t")) (defun back-to-indentation () -- 2.11.0 --=-=-=--