|
From: | Lennart Borgman (gmail) |
Subject: | Re: TAB when the region is active |
Date: | Tue, 18 Sep 2007 00:40:02 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 |
Richard Stallman wrote:
> The idea is logical, but we need to ask users if they find the change > annoying. Given that we are not close to a release, this would be a good time to experiment. Can you please OK such a change? I will ok trying it, if you agree to follow up in a few weeks by reminding people to try it and say if they don't like it.
The code below is what I currently use. There are some problems I know about:
- I do not remember what Drew wanted to add (in another message). - indent-according-to-mode is not supported everywhere.BTW, there is another problem with the indentation functions. I believe it would be useful (at least in mumamo.el) if the function that indents a line where split into one that gives the indentation amount and one that does the indentation (for every major mode).
(defun indent-line-or-region () "Indent line or region. Only do this if indentation seems bound to \\t. Call `indent-region' if region is active, otherwise `indent-according-to-mode'." (interactive) ;; Do a wild guess if we should indent or not ... (let* ((indent-region-mode) (t-bound (key-binding [?\t]))) (if (not (save-match-data (string-match "indent" (symbol-name t-bound)))) (call-interactively t-bound t) (if (and mark-active ;; there is a visible region selected transient-mark-mode) (indent-region (region-beginning) (region-end)) (indent-according-to-mode))))) ;; indent line
[Prev in Thread] | Current Thread | [Next in Thread] |