From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Newsgroups: gmane.emacs.bugs Subject: bug#24766: 26.0.50: [PATCH] Confusing behaviour for indent-relative-maybe Date: Mon, 07 Nov 2016 19:53:22 -0600 Message-ID: <878tsuivot.fsf@gmail.com> References: <8760ok8ays.fsf@gmail.com> <83lgxgp4ts.fsf@gnu.org> <871sz8894m.fsf@gmail.com> <83h984p3lb.fsf@gnu.org> <87shro6ol6.fsf@gmail.com> <83a8dvpor2.fsf@gnu.org> <87twc2iynm.fsf@gmail.com> <837f8y5f5x.fsf@gnu.org> <87insh4keo.fsf@gmail.com> <83insh34g8.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1478570079 16256 195.159.176.226 (8 Nov 2016 01:54:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 8 Nov 2016 01:54:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: 24766@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 08 02:54:34 2016 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 1c3vc4-0001dK-2W for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Nov 2016 02:54:12 +0100 Original-Received: from localhost ([::1]:57700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3vc7-00017N-2w for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Nov 2016 20:54:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3vbx-000169-Fq for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2016 20:54:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3vbu-0004OD-Be for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2016 20:54:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c3vbu-0004O7-7v for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2016 20:54:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c3vbu-0006p3-1G for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2016 20:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alex Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Nov 2016 01:54:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24766 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24766-submit@debbugs.gnu.org id=B24766.147857003226209 (code B ref 24766); Tue, 08 Nov 2016 01:54:01 +0000 Original-Received: (at 24766) by debbugs.gnu.org; 8 Nov 2016 01:53:52 +0000 Original-Received: from localhost ([127.0.0.1]:48860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3vbk-0006of-HP for submit@debbugs.gnu.org; Mon, 07 Nov 2016 20:53:52 -0500 Original-Received: from mail-it0-f54.google.com ([209.85.214.54]:37888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3vbi-0006oQ-98 for 24766@debbugs.gnu.org; Mon, 07 Nov 2016 20:53:50 -0500 Original-Received: by mail-it0-f54.google.com with SMTP id q124so171030004itd.1 for <24766@debbugs.gnu.org>; Mon, 07 Nov 2016 17:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=PXJeV7Dny0fzYJIzPMkqboyFtFn+r7feTx8WptvcPGM=; b=lp8kvwjbmfkqA7LTz4aHTThx6R+Rax2CU7J7Xwmd+4V0SsEfeSxYvzUQfmxgtn+YOk YOa/gVBOzfg5WSH75KMUolnhCU0D3Z4N41hshLw0sXnZeNI6kRuhWO8enUm7kLcJK7qa uu+oM74j16lMsIlySa4qvfPK3nuY06fcVzQbq4NHh/Wux9PYff1P/MP8uW0AaebyHe9R 0Ry7gOyT4Cq0WCBK539qJNRTsv4w02EOaQgbcBbVHdA8WJOGsunRq9n3qzmMJ9+HJQ6S WOeuWo9oEiBzZfXlDns6FrC1wx0akm+m/r7s7t/DqpK7UP9B9xaKZtt7nIsTYpdXm1Rz iTtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=PXJeV7Dny0fzYJIzPMkqboyFtFn+r7feTx8WptvcPGM=; b=hU/vcH44UKGuMfnP9If726JxnkwLmhOmxo6JrTzDgrhiIKObRrw3p+rlLKnaiCuAf3 rhHN33IJ9r/VfkRM+e/cHyJqiaQjjE5eItV+EExbwQyZrHco37dF6ZGhdGijhnHmi0Ns CPJZ7E0ip2CrLeNyg4mU9QvRZBUvgCvkv2vZ1H2uY6w/LH4z1cOLdfItOppsUoibbjqB Bv2KdgPKkn7FDEqfCL/a1jR5xzfWdYnirCMuz+yUDKFTHMjk5U4lr+L+69fvROXsbex3 /VcWT9HoKsni6Wo3J2eMp7FYWy1t+D9FKcczNPA5Ej8F3OA/rKKEpntFL9jgrhQR1/Hh Q6ww== X-Gm-Message-State: ABUngveXVqmhLYCJxE6EKTzaNaqrvo0/IYZJ6N4ObrgTf+dXDpTxeDaR3H1lGyR4eTOwPw== X-Received: by 10.107.170.230 with SMTP id g99mr12054598ioj.111.1478570024634; Mon, 07 Nov 2016 17:53:44 -0800 (PST) Original-Received: from lylat (S01061859339e9903.ss.shawcable.net. [174.2.107.88]) by smtp.gmail.com with ESMTPSA id i75sm3366229itf.10.2016.11.07.17.53.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Nov 2016 17:53:44 -0800 (PST) In-Reply-To: <83insh34g8.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 24 Oct 2016 22:57:43 +0300") 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:125451 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Alex >> Cc: 24766@debbugs.gnu.org >> Date: Mon, 24 Oct 2016 13:27:43 -0600 >> >> > I'd prefer a backward-compatible change, i.e. make the new argument be >> > the 2nd one, and keep the current behavior when the 1st arg is non-nil >> > and the 2nd is nil or omitted. >> >> That's what I did, but I used a new name for the old argument and the >> old name for the new argument. I did so as the old name fits the new >> behaviour more. >> >> This is a backward-compatible change for indent-relative, but it does >> use the new behaviour for indent-relative-maybe. Is that alright with >> you? > > Yes, thanks. Sorry for the delay. After thinking about it some more, and after properly searching on Github for `indent-relative-maybe', I'm not sure if my previous solution is the best one now. I found that due to some blog posts and starter kit configurations, a surprising amount of people use indent-relative-maybe despite docstring claiming different functionality. I now think the following should happen: 1) indent-relative-maybe's should be obsoleted in favour of a name suiting the purpose (e.g. indent-relative-whitespace) with a better docstring. 2) The docstring and second optional argument should be added as discussed before. 3) Perhaps in the future a new function can be introduced that automatically calls (indent-relative nil t), but I'm not sure if that should be done now. To be honest, I lost my original reason that made me interested in this function. Anyway, I've attached a diff that addresses this new proposal. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=indent3-2.diff Content-Description: 3rd time diff --git a/lisp/indent.el b/lisp/indent.el index 0f6c68d..6c907f4 100644 --- a/lisp/indent.el +++ b/lisp/indent.el @@ -559,24 +559,29 @@ indent-region ;; by hand. (setq deactivate-mark t)) -(defun indent-relative-maybe () - "Indent a new line like previous nonblank line. -If the previous nonblank line has no indent points beyond the -column point starts at, this command does nothing. +(define-obsolete-function-alias 'indent-relative-maybe + 'indent-relative-whitespace "26.1") + +(defun indent-relative-whitespace () + "Indent the current line like the previous nonblank line. +Indent to the first indentation position in the previous nonblank +line. See also `indent-relative'." (interactive) (indent-relative t)) -(defun indent-relative (&optional unindented-ok) +(defun indent-relative (&optional first-only unindented-ok) "Space out to under next indent point in previous nonblank line. An indent point is a non-whitespace character following whitespace. The following line shows the indentation points in this line. ^ ^ ^ ^ ^ ^ ^ ^ ^ +If FIRST-ONLY is non-nil, then only the first indent point is +considered. + If the previous nonblank line has no indent points beyond the -column point starts at, `tab-to-tab-stop' is done instead, unless -this command is invoked with a numeric argument, in which case it -does nothing. +column point starts at, then `tab-to-tab-stop' is done if +UNINDENTED-OK is nil, otherwise nothing is done in this case. See also `indent-relative-maybe'." (interactive "P") @@ -594,17 +599,18 @@ indent-relative (if (> (current-column) start-column) (backward-char 1)) (or (looking-at "[ \t]") - unindented-ok + first-only (skip-chars-forward "^ \t" end)) (skip-chars-forward " \t" end) (or (= (point) end) (setq indent (current-column)))))) - (if indent - (let ((opoint (point-marker))) - (indent-to indent 0) - (if (> opoint (point)) - (goto-char opoint)) - (move-marker opoint nil)) - (tab-to-tab-stop)))) + (cond (indent + (let ((opoint (point-marker))) + (indent-to indent 0) + (if (> opoint (point)) + (goto-char opoint)) + (move-marker opoint nil))) + (unindented-ok nil) + (t (tab-to-tab-stop))))) (defcustom tab-stop-list nil "List of tab stop positions used by `tab-to-tab-stop'. --=-=-=--