From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.bugs Subject: bug#8196: 23.1; Feature request with code: "C-x TAB" to understand tab-stop-list Date: Mon, 07 Mar 2011 20:19:13 +0200 Message-ID: <87d3m2equ6.fsf@imladris.arda> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1299523033 14623 80.91.229.12 (7 Mar 2011 18:37:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 7 Mar 2011 18:37:13 +0000 (UTC) To: 8196@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 07 19:37:08 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PwfIo-0007jv-Ka for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Mar 2011 19:37:07 +0100 Original-Received: from localhost ([127.0.0.1]:49439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwfIn-0005hx-Ur for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Mar 2011 13:37:06 -0500 Original-Received: from [140.186.70.92] (port=44375 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwfIc-0005fK-JT for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 13:36:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwfIb-00023K-C2 for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 13:36:54 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwfIb-00023G-AM for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 13:36:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Pwf2J-0002Go-1E; Mon, 07 Mar 2011 13:20:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Teemu Likonen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Mar 2011 18:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8196 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.12995219858698 (code B ref -1); Mon, 07 Mar 2011 18:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Mar 2011 18:19:45 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pwf21-0002GE-BM for submit@debbugs.gnu.org; Mon, 07 Mar 2011 13:19:45 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Pwf1y-0002G1-WF for submit@debbugs.gnu.org; Mon, 07 Mar 2011 13:19:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pwf1r-0006jB-KV for submit@debbugs.gnu.org; Mon, 07 Mar 2011 13:19:37 -0500 Original-Received: from lists.gnu.org ([199.232.76.165]:40598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pwf1r-0006j5-I6 for submit@debbugs.gnu.org; Mon, 07 Mar 2011 13:19:35 -0500 Original-Received: from [140.186.70.92] (port=57829 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pwf1p-0007Hk-Lq for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 13:19:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pwf1o-0006iF-7t for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 13:19:33 -0500 Original-Received: from mta-out.inet.fi ([195.156.147.13]:53638 helo=jenni2.inet.fi) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pwf1n-0006hl-VC for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 13:19:32 -0500 Original-Received: from imladris.arda (84.251.132.215) by jenni2.inet.fi (8.5.133) id 4D061FFC03D13B28 for bug-gnu-emacs@gnu.org; Mon, 7 Mar 2011 20:19:30 +0200 Original-Received: from dtw by imladris.arda with local (Exim 4.69) (envelope-from ) id 1Pwf1W-0002ZB-EO for bug-gnu-emacs@gnu.org; Mon, 07 Mar 2011 20:19:14 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 07 Mar 2011 13:20:03 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:44754 Archived-At: I think it would be better if "C-x TAB" (bound to indent-rigidly) advanced the indentation to the next tab stop (as in tab-stop-list) by default, instead of by 1. Similarly, if negative prefix argument were given (with "C-u -") it would change the indentation to the previous tab stop. Only when the prefix argument is actual number, positive or negative integer, it would move the indentation to the left or right by the given count. To demonstrate this I have written the following functions. Function tl-indent-region is a kind of replacement for indent-rigidly, so it can be bound to "C-x TAB". --8<---------------cut here---------------start------------->8--- (global-set-key (kbd "C-x TAB") #'tl-indent-region) (defun tl-region-indentation (beg end) "Return the smallest indentation in range from BEG to END. Blank lines are ignored." (save-excursion (let ((beg (progn (goto-char beg) (line-beginning-position))) indent) (goto-char beg) (while (re-search-forward "^\\s-*[[:print:]]" end t) (setq indent (min (or indent (current-indentation)) (current-indentation)))) indent))) (defun tl-indent-region-engine (beg end arg) "Back-end function for `tl-indent-region'." (interactive "r\nP") (let* ((beg (save-excursion (goto-char beg) (line-beginning-position))) (current (tl-region-indentation beg end)) (indent (cond ((not arg) (- (catch 'answer (dolist (col tab-stop-list (1+ current)) (when (> col current) (throw 'answer col)))) current)) ((eq arg '-) (- (catch 'answer (dolist (col (reverse tab-stop-list) 0) (when (< col current) (throw 'answer col)))) current)) (t (prefix-numeric-value arg))))) (indent-rigidly beg end indent))) (defun tl-indent-region (beg end arg) "Indent region to a tab stop column or to a specified column. Indent the region from BEG to END according to the command's prefix argument ARG. If ARG is nil (i.e., there is no prefix argument) indent the region to the next tab stop column in `tab-stop-list'. With negative prefix ARG (C-u -) indent the region to the previous tab stop column. If ARG is an integer indent the region by ARG columns (just like `indent-rigidly' command). If this command is invoked by a multi-character key sequence, it can be repeated by repeating the final character of the sequence." (interactive "r\nP") (require 'repeat) (let ((repeat-message-function #'ignore)) (setq last-repeatable-command #'tl-indent-region-engine) (repeat nil))) --8<---------------cut here---------------end--------------->8---