From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#51892: 29.0.50; [PATCH] Don't ignore restriction in indent-region-line-by-line Date: Tue, 16 Nov 2021 13:57:59 +0100 Message-ID: <87wnl8p8a0.fsf@miha-pc> Reply-To: miha@kamnitnik.top Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1211"; mail-complaints-to="usenet@ciao.gmane.io" To: 51892@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 16 13:54:13 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmxyW-000051-5j for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 13:54:12 +0100 Original-Received: from localhost ([::1]:52316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmxyU-0005WY-Ay for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 07:54:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmxyM-0005WC-Fz for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 07:54:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmxyM-0004NA-7N for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 07:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mmxyM-0004F8-2Y for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 07:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: miha@kamnitnik.top Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Nov 2021 12:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51892 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163706721516230 (code B ref -1); Tue, 16 Nov 2021 12:54:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Nov 2021 12:53:35 +0000 Original-Received: from localhost ([127.0.0.1]:57432 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmxxv-0004Dg-47 for submit@debbugs.gnu.org; Tue, 16 Nov 2021 07:53:35 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:53972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mmxxt-0004DX-KQ for submit@debbugs.gnu.org; Tue, 16 Nov 2021 07:53:33 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmxxt-0005Uh-D5 for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 07:53:33 -0500 Original-Received: from kamnitnik.top ([209.250.245.214]:50116) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmxxr-0004JV-4M for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 07:53:32 -0500 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id D46FD9CFA8 for ; Tue, 16 Nov 2021 12:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1637067208; bh=mXYw+Jg0K7yuhzof6op1YN983rt7nzJpzZ1IndAVgFY=; h=From:To:Subject:Date:From; b=suJuRD0EfwoBmXOxnzI/s8Ttnm7EN5WBi30NxYn9u8xCI+Bq9YIe5PHjnVBO49v6l 6qaVGhWCRpZdyqjGjdJUik1rSmvR6v9mZXZbuABsjIAA4rpjBXLEuYh9eAF6a4h1LC N+XGFpz5U7XV46Vk01K17hie0D2+DcgHkl3v6mXcbLeweCUPCcty8CZtZfbogn2WrA Y6vcB0INxtLVI5GbMM3Fx5xzul2OwuudBTcUkV1IR7KjgHZQNT9jLfNKv55ppXPy9R CfOyxDA/OV+oe8aXeMI+NjcW87IH+YWBbMCO0fOVlGrzpogib+KiCyln84wJG07rVu pDyqtMn+WZ+SQ== Received-SPF: pass client-ip=209.250.245.214; envelope-from=miha@kamnitnik.top; helo=kamnitnik.top X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.001, FROM_SUSPICIOUS_NTLD_FP=1.997, PDS_OTHER_BAD_TLD=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:220110 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Emacs convention is that low-level functions should respect restriction so that their callers can set restriction according to their needs. For example, 'c-indent-region' is a lower-level function which respects the current restriction and 'indent-region' is a higher-level user command which sets the restriction for lower-level functions, it calls "(widen)". 'indent-region-line-by-line' is a low-level function on a similar level as 'c-indent-region'. This patch makes it respect the current restriction instead of having it call "(widen)". --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-ignore-restriction-in-indent-region-line-by-li.patch Content-Transfer-Encoding: quoted-printable From=20bb388580fa7fa15be8aeabb9b80526fefbfac3aa Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Mon, 15 Nov 2021 17:57:36 +0100 Subject: [PATCH 1/6] Don't ignore restriction in indent-region-line-by-line * lisp/indent.el (indent-according-to-mode): Don't widen if the new optional argument is non-nil. (indent-region): Explicitly widen before calling indent-region-line-by-line. (indent-region-line-by-line): Don't widen. =2D-- lisp/indent.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lisp/indent.el b/lisp/indent.el index aa6b8d17c4..0a906fb526 100644 =2D-- a/lisp/indent.el +++ b/lisp/indent.el @@ -88,16 +88,20 @@ indent-line-ignored-functions indent-relative-first-indent-point) "Values that are ignored by `indent-according-to-mode'.") =20 =2D(defun indent-according-to-mode () +(defun indent-according-to-mode (&optional dont-widen) "Indent line in proper way for current major mode. Normally, this is done by calling the function specified by the variable `indent-line-function'. However, if the value of that variable is present in the `indent-line-ignored-functions' variable, handle it specially (since those functions are used for tabbing); =2Din that case, indent by aligning to the previous non-blank line." +in that case, indent by aligning to the previous non-blank line. + +Ignore restriction, unless the optional argument DONT-WIDEN is +non-nil." (interactive) (save-restriction =2D (widen) + (unless dont-widen + (widen)) (syntax-propertize (line-end-position)) (if (memq indent-line-function indent-line-ignored-functions) ;; These functions are used for tabbing, but can't be used for @@ -601,7 +605,10 @@ indent-region (funcall indent-region-function start end))) ;; Else, use a default implementation that calls indent-line-function on ;; each line. =2D (t (indent-region-line-by-line start end))) + (t + (save-restriction + (widen) + (indent-region-line-by-line start end)))) ;; In most cases, reindenting modifies the buffer, but it may also ;; leave it unmodified, in which case we have to deactivate the mark ;; by hand. @@ -615,7 +622,7 @@ indent-region-line-by-line (make-progress-reporter "Indenting region..." (point) end)= ))) (while (< (point) end) (or (and (bolp) (eolp)) =2D (indent-according-to-mode)) + (indent-according-to-mode t)) (forward-line 1) (and pr (progress-reporter-update pr (point)))) (and pr (progress-reporter-done pr)) =2D-=20 2.33.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmGTqtcTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP66BEACpMLFv2VJXgFUCPNDNwYKZbLTzLmIU uhg9/sWlzcXM55sr5TyFUwg4RhjyUqvTIbJKULqUjiOtYIkKROwDPqGQZ8kBFF/S 8DKy+4O0UvVSevrVOahM5XB9+r6kRN+FqkKnqeAmIIQXWNXQwfugL8ARMnfhQfbe cajhbIBciYqVhfRGgUOs/yoCztlFENWs7Rk2obA3EjD53mwJMFL5qrRhZ4+aXFEN BvFnliUrgzIllQHv3CgipFT3WxYhj2NZYSQLFfYZt5SEdCFr+4vAU3yzW/uzKnda m7MyT3khcx5xMWKf+vsPIprA7D8bIw7yyxGDRdT5DN1wdPsAUapkcJQDbNzSrGHK ds12HqBURNNCGI7WhEoUjEwxUzBM35mQpuoar6Qds+jDw96vXHHDln6beBvkEa3y jkHfDJxItmvn+Nw/tnKzpCZohIMqSflJoptyh/EzNSi6IcANJzm/YZ1ZMV4lsY3z 9IwTROx/gPSv49qbtRMpUzqi2/+1fuTFOmOq6MIQE+8NFd6yrwBKCqpsUFdjEAy5 fc8mjmykd2B13WsnXHZosI9RUiHljtwzslKA2uls/jtP1K94bVwNjVareKMaPZwU svvA0mi3UgNXhFewS9KcTpOKBJ6UgxgI/iWsgcGxSQshQLB3GKLVdlaJRR9Yk1Y/ Oe8w6q1HTwZyPw== =XnZ9 -----END PGP SIGNATURE----- --==-=-=--