From: Drew Adams <drew.adams@oracle.com>
To: 18977@debbugs.gnu.org
Subject: bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly'
Date: Thu, 6 Nov 2014 10:36:27 -0800 (PST) [thread overview]
Message-ID: <3394deee-e886-4428-9491-2286fcbbcce2@default> (raw)
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'
next reply other threads:[~2014-11-06 18:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 18:36 Drew Adams [this message]
2022-05-12 1:11 ` bug#18977: 25.0.50; Enhance (fix) incremental `indent-rigidly' Lars Ingebrigtsen
2022-05-12 15:58 ` Drew Adams
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3394deee-e886-4428-9491-2286fcbbcce2@default \
--to=drew.adams@oracle.com \
--cc=18977@debbugs.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).