all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Teemu Likonen <tlikonen@iki.fi>
To: Dani Moncayo <dmoncayo@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Indenting paragraphs manually
Date: Sun, 06 Mar 2011 23:44:01 +0200	[thread overview]
Message-ID: <87k4gbncv2.fsf@mithlond.arda> (raw)
In-Reply-To: <AANLkTimb=xV3tFgNyMP8+rhWUh64nLUyvVkqUtqX2WJH@mail.gmail.com> (Dani Moncayo's message of "Sun, 6 Mar 2011 20:42:57 +0100")

* 2011-03-06 20:42 (+0100), Dani Moncayo wrote:

> Indeed, that is another solution, but IMO has it's own drawbacks:
>  - As shown, the indentation is made by steps of 1 space.
>  - If you use a prefix argument (to avoid the above problem), it
> becomes cumbersome.
>
> The complexity of this method is also higher than having a simple,
> easy to type command that indents the region to the next tab stop and
> can be repeated several times in a row.

Do you mean the the next tab stop according to tab-stop-list variable?
If the indentation of lines in the current region differs between lines,
which line should be indented to the next tab stop position? Maybe the
one with the smallest amount of indentation (excluding blank lines)?
Here's a quick example:


    (defun my-region-indentation (beg end)
      (let (indent)
        (save-excursion
          (goto-char beg)
          (while (re-search-forward "^\\s-*[[:print:]]" end t)
            (setq indent (min (or indent (current-indentation))
                              (current-indentation)))))
        indent))


    (defun my-indent-region-next-tab-stop (beg end)
      "Indent region forward to the next tab stop."
      (interactive "r")
      (let* ((current (my-region-indentation beg end))
             (next (catch 'answer
                     (dolist (i tab-stop-list 0)
                       (when (> i current)
                         (throw 'answer i))))))
        (indent-rigidly beg end (- next current))))


    (defun my-indent-region-previous-tab-stop (beg end)
      "Indent region backward to the previous tab stop."
      (interactive "r")
      (let* ((current (my-region-indentation beg end))
             (prev (catch 'answer
                     (dolist (i (reverse (append (list 0) tab-stop-list)) 0)
                       (when (< i current)
                         (throw 'answer i))))))
        (indent-rigidly beg end (- prev current))))


    (global-set-key [f5] #'my-indent-region-previous-tab-stop)
    (global-set-key [f6] #'my-indent-region-next-tab-stop)



  parent reply	other threads:[~2011-03-06 21:44 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04 23:17 Indenting paragraphs manually Dani Moncayo
2011-03-05 20:26 ` Andrea Crotti
2011-03-05 22:23   ` Harry Putnam
2011-03-06 11:47   ` Dani Moncayo
2011-03-06 13:50     ` Peter Dyballa
2011-03-06 14:12       ` Dani Moncayo
     [not found]     ` <mailman.1.1299419427.17199.help-gnu-emacs@gnu.org>
2011-03-06 14:18       ` Pascal J. Bourguignon
2011-03-07  5:04     ` Le Wang
2011-03-07  7:32       ` Dani Moncayo
2011-03-05 22:01 ` Peter Dyballa
2011-03-06 11:50   ` Dani Moncayo
2011-03-05 23:28 ` PJ Weisberg
2011-03-06  2:29   ` Le Wang
2011-03-06  3:08     ` PJ Weisberg
2011-03-06  8:37       ` Le Wang
     [not found] ` <mailman.4.1299367745.22865.help-gnu-emacs@gnu.org>
2011-03-06  8:18   ` rusi
2011-03-06  9:10     ` Le Wang
2011-03-06 16:30 ` I filed two bug reports (was: Re: Indenting paragraphs manually) Gregor Zattler
2011-03-06 16:50   ` Dani Moncayo
     [not found] ` <mailman.16.1299356823.24947.help-gnu-emacs@gnu.org>
2011-03-06 17:58   ` Indenting paragraphs manually Uday Reddy
2011-03-06 19:17     ` Dani Moncayo
2011-03-06 19:27       ` Teemu Likonen
2011-03-06 19:42         ` Dani Moncayo
2011-03-06 20:26           ` Drew Adams
2011-03-06 20:57             ` Dani Moncayo
2011-03-06 21:42               ` Drew Adams
2011-03-07 21:58                 ` Perry Smith
2011-03-07 22:14                   ` Drew Adams
2011-03-06 21:44           ` Teemu Likonen [this message]
2011-03-07  8:18             ` Teemu Likonen
2011-03-07 13:42               ` Le Wang
2011-03-07 14:38                 ` Le Wang
2011-03-07 14:52                   ` Teemu Likonen
2011-03-07 15:13                   ` Drew Adams
2011-03-07 15:04                 ` Drew Adams
     [not found]             ` <mailman.14.1299485912.29721.help-gnu-emacs@gnu.org>
2011-03-07 16:09               ` Stefan Monnier
2011-03-07 17:02                 ` Teemu Likonen
2011-03-06 19:44       ` 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

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

  git send-email \
    --in-reply-to=87k4gbncv2.fsf@mithlond.arda \
    --to=tlikonen@iki.fi \
    --cc=dmoncayo@gmail.com \
    --cc=help-gnu-emacs@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.