all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: <emacs-devel@gnu.org>
Subject: RE: TAB when the region is active
Date: Tue, 18 Sep 2007 22:11:18 -0700	[thread overview]
Message-ID: <BNELLINCGFJLDJIKDGACIENICCAA.drew.adams@oracle.com> (raw)
In-Reply-To: <200709190342.l8J3gpHQ020774@oogie-boogie.ics.uci.edu>

1. `indent-region' only indents lines that start within the region. There's
probably a good reason for that, but I'm not sure that's the behavior we
want here. I wonder if it wouldn't be better here to apply `indent-line'
(e.g. `lisp-indent-line') to each line, in turn, that has at least one
character (not necessarily its first character) in the region.

A typical use case for me is wanting to see what really changes when I do
`C-M-q' on a large defun (> one screen). I want, for instance, to see if
only some comment positions change or if some sexps move because I might
have an extra or a missing paren. I'll hit TAB for each of several
successive lines to see if/how they move. (You might have an alternative
that you prefer, but I often do this.)

If TAB, as proposed, will now affect the region, then I'll just select some
lines and hit TAB - great.

But, IIUC, the first line selected would need to have its beginning selected
also, or else `indent-region' won't apply to it. It would be handier, I
think, to have `lisp-indent-line' applied to each selected line, in turn.

That way, the region would show all of the lines that would be affected by
the operation. You could quickly zap the mouse over some lines to select
them, without regard to the exact beginning or end of the region, and TAB
would indent them all appropriately (in turn).

(No, I didn't try the patch; I just scanned it.)

2. BTW, does `lisp-indent-region' really do the right thing? E.g., if you
select all lines after the first one here, and then do (lisp-indent-region
(region-beginning) (region-end)), the last three lines are not indented
correctly. Is that THT?

(cond (foobar
         (fibrillate) ; select this and subsequent lines
             (frobnicate)
           (message "Fabulous!"))
         (t
               (barn-owl)
             (bobolink)
       (message "Bar none.")))

`lisp-indent-region' gives this (is it a bug or intended?):

(cond (foobar
       (fibrillate)
       (frobnicate)
       (message "Fabulous!"))
      (t
      (barn-owl) ; incorrectly indented
      (bobolink)
      (message "Bar none.")))

The problem I was referring to in #1 is the difference between this and what
happens if you don't start the selection at the beginning of the second
line, but in some other part of the second line (e.g. at its opening paren).
The result is then this:

(cond (foobar
         (fibrillate) ; incorrect indentation (not moved)
         (frobnicate) ; correctly indented relative to previous
         (message "Fabulous!"))
      (t
      (barn-owl)
      (bobolink)
      (message "Bar none."))))

(Yes, you can, remembering this gotcha, always start selecting one line
ahead of what you want to indent, but I think it's clearer if the region
clearly indicates the lines to be affected.)

3. Wrt my use case mentioned in #1, yes, it might be nice to have a visual
indication of the first significant (i.e. non-comment) change in
indentation, starting at point, when you do `C-M-q'. Or perhaps even an
indication of all indentation changes. That might be done by highlighting
any added whitespace and indicating any removed whitespace in some other
way - perhaps by highlighting (differently) the chars that were moved
leftward to replace previous whitespace.

E.g., moving from the first sexp above to the second would show something
like this, where `x' indicates removed whitespace (but highlighting would be
used, not `x').

(cond (foobar
       xxibrillate)
       xxxxxxicate)
       xxxxsage "Fabulous!"))
      xxx
      xxxxxxxxl)
      xxxxxxink)
      (message "Bar none.")))

Apologies for adding topics. Only #1 is relevant to this thread. (And
perhaps #2.)

  reply	other threads:[~2007-09-19  5:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14 21:59 TAB when the region is active Dan Nicolaescu
2007-09-16  5:35 ` Richard Stallman
2007-09-17  4:09   ` Dan Nicolaescu
2007-09-17 22:24     ` Richard Stallman
2007-09-17 22:40       ` Lennart Borgman (gmail)
2007-09-17 22:47         ` Drew Adams
2007-09-17 23:28         ` Dan Nicolaescu
2007-09-19  3:42           ` Dan Nicolaescu
2007-09-19  5:11             ` Drew Adams [this message]
2007-09-19 13:45               ` Stefan Monnier
2007-09-19 14:34                 ` Drew Adams
2007-09-19 13:45             ` Stefan Monnier
2007-09-20  1:54               ` Dan Nicolaescu
2007-09-20 13:52                 ` Stefan Monnier
2007-09-22  1:00                   ` Dan Nicolaescu
2007-09-24  0:07                     ` Juri Linkov
2007-09-24  1:09                       ` Drew Adams
2007-09-24  1:15                         ` Juri Linkov
2007-09-24  3:50                           ` Stefan Monnier
2007-09-29 23:18                             ` M-q when the region is active (Re: TAB when the region is active) Juri Linkov
2007-09-30 12:54                               ` Richard Stallman
2007-10-06 22:43                                 ` M-$ when the region is active (Re: M-q " Juri Linkov
2007-09-24 18:20                           ` TAB when the region is active Richard Stallman
2007-09-24  2:37                       ` Dan Nicolaescu
2007-09-24 18:20                       ` Richard Stallman
2007-09-17 23:13       ` Dan Nicolaescu
2007-09-16 18:48 ` Lennart Borgman
2007-09-16 19:17   ` Paul Pogonyshev
2007-09-16 20:32   ` Drew Adams
2007-09-17  3:59   ` Richard Stallman

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=BNELLINCGFJLDJIKDGACIENICCAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /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.