emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TAB when the region is active


From: Dan Nicolaescu
Subject: Re: TAB when the region is active
Date: Sun, 23 Sep 2007 19:37:23 -0700

Juri Linkov <address@hidden> writes:

  > > I have committed the patch.
  > >
  > > cc-mode would need to be updated to do the same thing. I emailed the
  > > maintainer.
  > >
  > > Other major modes might need updates too. We can do them as soon as we
  > > find out they need changes.
  > 
  > Thanks!  It's a pity this very good feature doesn't work yet in c-mode.

It seems that binding TAB to c-indent-line-or-region might be
enough. I haven't tested this though...

  > I also tried it in some other modes (fundamental-mode, text-mode)
  > and it doesn't do something useful here.  It inserts a single TAB whereas
  > C-M-\ (`indent-region') tries to indent the region.  However, what C-M-\
  > does in text modes is not useful too because it shifts each consequent
  > line relative to the previous line in a staircase-like style.

This patch might allow TAB to run indent-region for those
modes too:

*** indent.el   21 Sep 2007 18:37:51 -0700      1.69
--- indent.el   23 Sep 2007 19:20:24 -0700
***************
*** 95,108 ****
             (or (> (current-column) (current-indentation))
                 (eq this-command last-command))))
      (insert-tab arg))
-    ;; Those functions are meant specifically for tabbing and not for
-    ;; indenting, so we can't pass them to indent-according-to-mode.
-    ((memq indent-line-function '(indent-relative indent-relative-maybe))
-     (funcall indent-line-function))
     ;; The region is active, indent it.
     ((and transient-mark-mode mark-active
         (not (eq (region-beginning) (region-end))))
      (indent-region (region-beginning) (region-end)))
     ;; Indent the line.
     (t
      (indent-according-to-mode))))
--- 95,108 ----
             (or (> (current-column) (current-indentation))
                 (eq this-command last-command))))
      (insert-tab arg))
     ;; The region is active, indent it.
     ((and transient-mark-mode mark-active
         (not (eq (region-beginning) (region-end))))
      (indent-region (region-beginning) (region-end)))
+    ;; Those functions are meant specifically for tabbing and not for
+    ;; indenting, so we can't pass them to indent-according-to-mode.
+    ((memq indent-line-function '(indent-relative indent-relative-maybe))
+     (funcall indent-line-function))
     ;; Indent the line.
     (t
      (indent-according-to-mode))))


  > What would be useful to do in text modes is to make a similar change for
  > M-q (`fill-paragraph').  When the region is active in transient-mark-mode,
  > then M-q would call `fill-region' instead of `fill-paragraph'.

Good idea!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]