From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: mopi <52hands@gmail.com> Newsgroups: gmane.emacs.help Subject: Re: Use tab key to indent both region AND line? Date: 20 Apr 2007 10:54:06 -0700 Organization: http://groups.google.com Message-ID: <1177091646.936347.179410@p77g2000hsh.googlegroups.com> References: <1177071040.638066.76140@n76g2000hsh.googlegroups.com> <6dbd4d000704200545s1290bfcaw755d4df752ee976f@mail.gmail.com> <1177084896.286288.184040@e65g2000hsc.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1177094128 9561 80.91.229.12 (20 Apr 2007 18:35:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 20 Apr 2007 18:35:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 20 20:35:22 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hexx0-0007KO-Id for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Apr 2007 20:35:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hey25-00038V-Pa for geh-help-gnu-emacs@m.gmane.org; Fri, 20 Apr 2007 14:40:33 -0400 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!p77g2000hsh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: 81.230.102.61 Original-X-Trace: posting.google.com 1177091647 23354 127.0.0.1 (20 Apr 2007 17:54:07 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 20 Apr 2007 17:54:07 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p77g2000hsh.googlegroups.com; posting-host=81.230.102.61; posting-account=2hN_GQ0AAACPrJKt-6-vp_n8wTh4w5Ay Original-Xref: shelby.stanford.edu gnu.emacs.help:147313 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42916 Archived-At: On Apr 20, 7:16 pm, "Lennart Borgman (gmail)" wrote: > And here is something that can be used: > > ;; From an idea by weber > (defun indent-line-or-region () > "indent line or region" > (interactive) > (if mark-active ;; there is a region selected > (indent-region (region-beginning) (region-end)) > (indent-according-to-mode))) ;; indent line > > (define-minor-mode indent-line-mode > "Use TAB to indent line and region." > :global t > :keymap '(([tab] . indent-line-or-region))) > (when indent-line-mode (indent-line-mode 1)) Thank you very much! I changed it slightly to use indent-rigidly: (defun indent-line-or-region () "indent line or region" (interactive) (if mark-active ;; there is a region selected (indent-rigidly (region-beginning) (region-end) 4) (indent-according-to-mode))) ;; indent line Is there a way to make it keep the region? Now after I press tab the region is lost so I can't repeat the indentation without reselecting the region.