[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Indenting paragraphs manually
From: |
Teemu Likonen |
Subject: |
Re: Indenting paragraphs manually |
Date: |
Sun, 06 Mar 2011 23:44:01 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2.94 (gnu/linux) |
* 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)
- Re: Indenting paragraphs manually, (continued)
- Message not available
- Re: Indenting paragraphs manually, Uday Reddy, 2011/03/06
- Re: Indenting paragraphs manually, Dani Moncayo, 2011/03/06
- RE: Indenting paragraphs manually, Drew Adams, 2011/03/06
- Re: Indenting paragraphs manually, Teemu Likonen, 2011/03/06
- Re: Indenting paragraphs manually, Dani Moncayo, 2011/03/06
- RE: Indenting paragraphs manually, Drew Adams, 2011/03/06
- Re: Indenting paragraphs manually, Dani Moncayo, 2011/03/06
- RE: Indenting paragraphs manually, Drew Adams, 2011/03/06
- Re: Indenting paragraphs manually, Perry Smith, 2011/03/07
- RE: Indenting paragraphs manually, Drew Adams, 2011/03/07
- Re: Indenting paragraphs manually,
Teemu Likonen <=
- Re: Indenting paragraphs manually, Teemu Likonen, 2011/03/07
- Re: Indenting paragraphs manually, Le Wang, 2011/03/07
- Re: Indenting paragraphs manually, Le Wang, 2011/03/07
- Re: Indenting paragraphs manually, Teemu Likonen, 2011/03/07
- RE: Indenting paragraphs manually, Drew Adams, 2011/03/07
- RE: Indenting paragraphs manually, Drew Adams, 2011/03/07
- Message not available
- Re: Indenting paragraphs manually, Stefan Monnier, 2011/03/07
- Re: Indenting paragraphs manually, Teemu Likonen, 2011/03/07