all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Alex Branham <alex.branham@gmail.com>
Cc: 34858@debbugs.gnu.org
Subject: bug#34858: indent-relative called with prefix calls tab-to-tab-stop
Date: Tue, 02 Apr 2019 01:11:57 +0100	[thread overview]
Message-ID: <87v9zx6zaq.fsf@tcd.ie> (raw)
In-Reply-To: <87wol1l9bn.fsf@gmail.com> (Alex Branham's message of "Thu, 14 Mar 2019 11:17:16 -0500")

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

Alex Branham <alex.branham@gmail.com> writes:

> On Thu 14 Mar 2019 at 11:00, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> I think this is a documentation bug, as it doesn't describe the
>> special case of "no previous nonblank line".
>
> OK, patch attached. While looking over this I noticed the lisp reference
> manual also needed to be updated a bit so I did that as well.

I think some code needs updating in addition to the Elisp manual:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-using-obsolete-indent-relative-maybe.patch --]
[-- Type: text/x-diff, Size: 3441 bytes --]

From d8c74ae527c52cffcb23d9704a899dd304188276 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Tue, 2 Apr 2019 00:56:04 +0100
Subject: [PATCH] Avoid using obsolete indent-relative-maybe

* lisp/electric.el (electric-indent-functions-without-reindent):
* lisp/indent.el (indent-according-to-mode): Check for
indent-relative-first-indent-point in addition to its obsolete alias
indent-relative-maybe.
* lisp/obsolete/vi.el (vi-com-map): Use
indent-relative-first-indent-point in place of its obsolete alias
indent-relative-maybe.
---
 lisp/electric.el    |  6 +++---
 lisp/indent.el      | 10 ++++++----
 lisp/obsolete/vi.el |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/electric.el b/lisp/electric.el
index 657913a396..07da2f1d9e 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -223,9 +223,9 @@ electric-indent-inhibit
 
 (defvar electric-indent-functions-without-reindent
   '(indent-relative indent-to-left-margin indent-relative-maybe
-    py-indent-line coffee-indent-line org-indent-line yaml-indent-line
-    haskell-indentation-indent-line haskell-indent-cycle haskell-simple-indent
-    yaml-indent-line)
+    indent-relative-first-indent-point py-indent-line coffee-indent-line
+    org-indent-line yaml-indent-line haskell-indentation-indent-line
+    haskell-indent-cycle haskell-simple-indent yaml-indent-line)
   "List of indent functions that can't reindent.
 If `indent-line-function' is one of those, then `electric-indent-mode' will
 not try to reindent lines.  It is normally better to make the major
diff --git a/lisp/indent.el b/lisp/indent.el
index 34757a43d7..f3d3158faa 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -65,15 +65,17 @@ indent-according-to-mode
   "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 `indent-relative' or `indent-relative-maybe', handle
-it specially (since those functions are used for tabbing); in
-that case, indent by aligning to the previous non-blank line."
+variable is `indent-relative' or `indent-relative-first-indent-point',
+handle it specially (since those functions are used for tabbing);
+in that case, indent by aligning to the previous non-blank line."
   (interactive)
   (save-restriction
     (widen)
   (syntax-propertize (line-end-position))
   (if (memq indent-line-function
-	    '(indent-relative indent-relative-maybe))
+            '(indent-relative
+              indent-relative-maybe
+              indent-relative-first-indent-point))
       ;; These functions are used for tabbing, but can't be used for
       ;; indenting.  Replace with something ad-hoc.
       (let ((column (save-excursion
diff --git a/lisp/obsolete/vi.el b/lisp/obsolete/vi.el
index 7d44f561d4..df5ddfdbcf 100644
--- a/lisp/obsolete/vi.el
+++ b/lisp/obsolete/vi.el
@@ -132,7 +132,7 @@ vi-com-map
   (define-key vi-com-map "\C-e" 'vi-expose-line-below)
   (define-key vi-com-map "\C-f" 'vi-forward-windowful)
   (define-key vi-com-map "\C-g" 'keyboard-quit)
-  (define-key vi-com-map "\C-i" 'indent-relative-maybe) ; TAB
+  (define-key vi-com-map "\C-i" 'indent-relative-first-indent-point) ; TAB
   (define-key vi-com-map "\C-j" 'vi-next-line) ; LFD
   (define-key vi-com-map "\C-k" 'vi-kill-line) ; extension
   (define-key vi-com-map "\C-l" 'recenter)
-- 
2.20.1


[-- Attachment #3: Type: text/plain, Size: 2510 bytes --]


I think the changes pertaining to the move from indent-relative-maybe to
indent-relative-first-indent-point should be pushed independently of any
changes to the behaviour of indent-relative at BOB or its documentation.

Can they be pushed to master, and only backported to emacs-26 as
needed/applicable?

> From cefe6581558e45558907996ea39ac44e512f7944 Mon Sep 17 00:00:00 2001
> From: Alex Branham <alex.branham@gmail.com>
> Date: Thu, 14 Mar 2019 11:14:18 -0500
> Subject: [PATCH] Update documentation for indent-relative functions
>
> * lisp/indent.el (indent-relative): Document what happens when there
>   is no previous nonblank line.
> * doc/lispref/text.texi (Relative Indent): Document
>   indent-relative-first-indent-point instead of obsolete
>   indent-relative-maybe. Fix documentation of which argument from
                         ^^^
Missing double space.

> diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
> index 21c5a73f88..abcea17010 100644
> --- a/doc/lispref/text.texi
> +++ b/doc/lispref/text.texi
> @@ -2571,11 +2571,11 @@ The quick brown fox jum  @point{}ped.
>  @end example
>  @end deffn
>  
> -@deffn Command indent-relative-maybe
> +@deffn Command indent-relative-first-indent-point
>  @comment !!SourceFile indent.el
>  This command indents the current line like the previous nonblank line,
>  by calling @code{indent-relative} with @code{t} as the
> -@var{unindented-ok} argument.  The return value is unpredictable.
> +@var{first-only} argument.  The return value is unpredictable.

Just curious: is there any preference between "unpredictable" and
"undefined" for documenting return values?  If so, why?

>  If the previous nonblank line has no indent points beyond the current
>  column, this command does nothing.
> diff --git a/lisp/indent.el b/lisp/indent.el
> index 34757a43d7..25615f4113 100644
> --- a/lisp/indent.el
> +++ b/lisp/indent.el
> @@ -598,8 +598,8 @@ considered.
>  
>  If the previous nonblank line has no indent points beyond the
>  column point starts at, then `tab-to-tab-stop' is done, if both
> -FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done
> -in this case.
> +FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done.
> +If there isn't a previous nonblank line, call `tab-to-tab-stop'.

I'm not against spelling this final sentence out, but in my reading it's
already covered by the first sentence, as a non-existent line vacuously
"has no indent points beyond the column point starts at". ;)

Thanks,

-- 
Basil

  parent reply	other threads:[~2019-04-02  0:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 15:35 bug#34858: indent-relative called with prefix calls tab-to-tab-stop Alex Branham
2019-03-14 16:00 ` Eli Zaretskii
2019-03-14 16:17   ` Alex Branham
2019-03-20 20:23     ` Filipp Gunbin
2019-03-25 23:06       ` Alex Branham
2019-03-26 15:39         ` Eli Zaretskii
2019-03-26 15:42           ` Alex Branham
2019-03-26 16:47             ` Eli Zaretskii
2019-04-02  0:11     ` Basil L. Contovounesios [this message]
2019-04-02 14:40       ` Eli Zaretskii
2019-04-03 17:12         ` Basil L. Contovounesios
2019-04-06  0:52           ` Alex Branham
2019-03-14 16:45   ` Alex
2019-03-14 18:02     ` Eli Zaretskii
2019-03-14 18:57       ` Alex
2019-03-14 20:18         ` Eli Zaretskii
2019-03-14 21:27           ` Alex
2019-03-15  4:52             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v9zx6zaq.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=34858@debbugs.gnu.org \
    --cc=alex.branham@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.