all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly'
@ 2014-11-06 18:36 Drew Adams
  2022-05-12  1:11 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2014-11-06 18:36 UTC (permalink / raw)
  To: 18977

1. Please consider adding this binding, so you can simply do `C-x TAB
TAB...': (define-key indent-rigidly-map "\t" 'indent-rigidly-right).
And update the doc string and prompt, of course.


2. You cannot currently provide a numeric prefix arg to `indent-rigidly'
for incremental use.  The incremental indentation you get is either 1 
column (for <right>) or to the next tab stop (for <S-right>).

It would be good to be able to use a numeric prefix arg interactively to
indent not only once, but each time you hit <right>.

Ironically, this was possible before the Emacs 24.4 change to
`indent-rigidly' which provided for incremental indenting, by just doing
something like this:

(defun repeat-command (command)
  "Repeat COMMAND."
  (let ((repeat-message-function  'ignore))
    (setq last-repeatable-command  command)
    (repeat nil)))

(defun indent-rigidly-repeat (start end arg &optional interactive)
  "Indent all lines that start in the region.
You can repeat this by hitting the last key (e.g., `TAB') again...
A numeric prefix arg you provide to the command is used as the
indentation increment."
  (interactive "r\nP\np")
  (require 'repeat nil t)
  (repeat-command 'indent-rigidly))

(global-set-key [remap indent-rigidly] 'indent-rigidly-repeat)

Then `C-3 C-x TAB TAB...' indents 3 columns each time you hit `TAB';
`C-x TAB TAB...' indents 1 column for each `TAB'; and `C- 2 C-x TAB
TAB...' outdents 2 columns for each `TAB'.  Very handy.

This design is simple, and it lets you use the same key, `TAB', to
indent or outdent incrementally (outdent by using a negative prefix
arg).

As written above, this does not, however, provide the useful feature of
a single undo for all repeated indenting, as does the current
implementation of `indent-rigidly'.  And it does not provide for
indentation to tab stops.  I am not proposing such a simple
implementation as a replacement for the current one.

This is the request: Could you please adapt `indent-rigidly' to provide
similar behavior to that shown above: Instead of using a numeric prefix
arg *only* for a single indentation, let users repeat indenting (or
outdenting) in prefix-arg steps.


3. A related improvement would be to provide also the other advantage of
the above code: Indenting/outdenting is *immediate* for `C-x TAB'.

Currently, no indentation is done until you hit <right> (or you use a
prefix arg, which turns off incremental indenting).  This means that
currently you must hit at least 3 keys, `C-x TAB <right>' or `C-1 C-x
TAB', to indent.  You cannot hit just `C-x TAB', as you could prior to
Emacs 24.4.  (This is thus a minor regression in behavior.)

The best behavior is for `C-x TAB' to indent by the numerical prefix
number of columns, and to continue to do so as long as you continue to
hit <right> or `TAB'.  <left> should similarly outdent by the prefix
arg.  A negative prefix arg, and Bidi, should of course flip the
direction.

(Yes, if `C-x TAB' itself indents immediately then you will need to hit
<left> twice to outdent once.  Not a big deal, IMO - outweighed by the
convenience of not needing to hit 3 keys for the common case of
indenting.)

I started to take a stab at this myself, but I found no good way to
propagate the prefix arg using the current implementation, which does
(set-transient-map indent-rigidly-map t).



In GNU Emacs 25.0.50.1 (i686-pc-mingw32)
 of 2014-10-20 on LEG570
Bzr revision: 118168 rgm@gnu.org-20141020195941-icp42t8ttcnud09g
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking=yes,glyphs CPPFLAGS=-DGLYPH_DEBUG=1'





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly'
  2014-11-06 18:36 bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly' Drew Adams
@ 2022-05-12  1:11 ` Lars Ingebrigtsen
  2022-05-12 15:58   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-12  1:11 UTC (permalink / raw)
  To: Drew Adams; +Cc: 18977

Drew Adams <drew.adams@oracle.com> writes:

> 1. Please consider adding this binding, so you can simply do `C-x TAB
> TAB...': (define-key indent-rigidly-map "\t" 'indent-rigidly-right).
> And update the doc string and prompt, of course.

Makes sense; I've now added this to Emacs 29.  (But not changed the
prompt.)

> 2. You cannot currently provide a numeric prefix arg to `indent-rigidly'
> for incremental use.  The incremental indentation you get is either 1 
> column (for <right>) or to the next tab stop (for <S-right>).
>
> It would be good to be able to use a numeric prefix arg interactively to
> indent not only once, but each time you hit <right>.

I don't think that makes much sense -- if you've decided to indent X
columns (by using the prefix), then you don't want to enter the
transient map thing.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly'
  2022-05-12  1:11 ` Lars Ingebrigtsen
@ 2022-05-12 15:58   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2022-05-12 15:58 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 18977@debbugs.gnu.org

> > 2. You cannot currently provide a numeric prefix arg to `indent-
> rigidly'
> > for incremental use.  The incremental indentation you get is either 1
> > column (for <right>) or to the next tab stop (for <S-right>).
> >
> > It would be good to be able to use a numeric prefix arg interactively
> to
> > indent not only once, but each time you hit <right>.
> 
> I don't think that makes much sense -- if you've decided to indent X
> columns (by using the prefix), then you don't want to enter the
> transient map thing.

So...another "wont-fix".

I hope you're simply misunderstanding.

This would let each incremental key press move by
that increment, instead of an increment of just 1.

It boosts the incrementation.

An increment is exactly that: a given amount to
increase (likewise, decrement/decrease).

Think incf and decf, if that helps you understand.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-12 15:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 18:36 bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly' Drew Adams
2022-05-12  1:11 ` Lars Ingebrigtsen
2022-05-12 15:58   ` Drew Adams

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.