The proper way is to do it through Lisp. I wrote a function that tries to
accomplish this:

(defun comment-and-indent-region (beg end &optional arg)
  "Runs comment-region and then indent-region on a region"
  (interactive "r\nP")
  (if (null arg)
      (comment-region beg end)
    (comment-region beg end arg))
  (indent-region beg end nil))

Just put it in your .emacs file and bind it to \C-c\C-c.
The problem with it is that it works only one way. 
It doesn't work to uncomment the code because uncommenting will only work
if line starts with a comment, so I would have to remove whitespace on
every line in selection, and that's beyond my current knowledge of Lisp.
Perhaps somebody on this mailing list is good enough with lisp to solve
this problem?

Yaroslav

On Tue, 29 Aug 2000, Taber H. Smith wrote:

> Hi,
> 
> I'm wondering if there is a way to automatically
> indent a region that has just been commented out, i.e.
> 
> mark region
> C-c C-c
> 
> then automatically run
> C-x indent-region
> 
> Also, after you uncomment out a region, it would be
> nice if the jde automatically indented the uncommented region.
> 
> Any suggestions?
> 
> Thanks!
> Taber
> 
> 

Reply via email to