From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthias Meulien Newsgroups: gmane.emacs.devel Subject: Tabify and untabify apply to the entire buffer (with patch) Date: Thu, 21 Mar 2013 02:02:54 +0100 Message-ID: <1363827774.819.48.camel@localhost.localdomain> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-bNd5MPY4sJoqoNSQwCDN" X-Trace: ger.gmane.org 1363827771 22950 80.91.229.3 (21 Mar 2013 01:02:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2013 01:02:51 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 21 02:03:18 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UITuW-0005Ok-OI for ged-emacs-devel@m.gmane.org; Thu, 21 Mar 2013 02:03:16 +0100 Original-Received: from localhost ([::1]:50590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UITu9-0001jW-FH for ged-emacs-devel@m.gmane.org; Wed, 20 Mar 2013 21:02:53 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UITu4-0001ih-Db for emacs-devel@gnu.org; Wed, 20 Mar 2013 21:02:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UITu1-00025K-KZ for emacs-devel@gnu.org; Wed, 20 Mar 2013 21:02:48 -0400 Original-Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:35386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UITu1-00024W-Eo for emacs-devel@gnu.org; Wed, 20 Mar 2013 21:02:45 -0400 Original-Received: by mail-we0-f182.google.com with SMTP id t57so1947557wey.13 for ; Wed, 20 Mar 2013 18:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:subject:from:to:content-type:date :mime-version:x-mailer; bh=gX40BImN1mBCQ8pfLNTasT1PGW3wNd7s+i+YbVihFIs=; b=Ji8cIqz1Z1H+JatqQQJjwNe/2Aes+BaVHrP44d03veURPGFSmza21Q9GHV8B1jwsPD 29c9VsNnaEq2qARzLl5zeKW1HOlK1Ykca8K3eNFPd9Kg1Icyh26+1jXOJztpoE9xnUn7 mQSjuVBXSPkbF0TtnvqF86WIZANvqCTzorxTi1kM7Tz5Sk2CPxhe52SrpgnGBWQV7Zb/ C21Dg0D6fQeOK4yuANpPdM0tNsOHTHF4fpIoScHL0/iLaF4DKQzh4vl3k5zxsQLIvJeL RdL1CmFqN43ujaVn06aGtk593qA6CoTADgd/M8OuN5hzArxB484JfK2eUeiUfSUIKGjA p1Cw== X-Received: by 10.180.14.202 with SMTP id r10mr1553308wic.8.1363827763843; Wed, 20 Mar 2013 18:02:43 -0700 (PDT) Original-Received: from [192.168.1.38] (jau31-3-82-239-20-84.fbx.proxad.net. [82.239.20.84]) by mx.google.com with ESMTPS id bs6sm2123290wib.4.2013.03.20.18.02.42 (version=SSLv3 cipher=RC4-SHA bits=128/128); Wed, 20 Mar 2013 18:02:42 -0700 (PDT) X-Mailer: Evolution 3.6.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:158011 Archived-At: --=-bNd5MPY4sJoqoNSQwCDN Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit With emacs 24.3, `C-u M-=' now counts lines/words/characters in the entire buffer. I suggest that the functions `untabify' and `tabify' from lisp/tabify.el may accept such an optional argument to apply to the entire buffer. A patch is attached to this message. Thanks for reading, -- Matthias Meulien --=-bNd5MPY4sJoqoNSQwCDN Content-Disposition: attachment; filename="0001-Tabify-and-untabify-apply-to-the-entire-buffer.patch" Content-Type: text/x-patch; name="0001-Tabify-and-untabify-apply-to-the-entire-buffer.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit >From 64a03c29af49f38a6c2f31fb619a8c342b6316f8 Mon Sep 17 00:00:00 2001 From: Matthias Meulien Date: Thu, 21 Mar 2013 01:51:06 +0100 Subject: [PATCH] Tabify and untabify apply to the entire buffer --- lisp/tabify.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/tabify.el b/lisp/tabify.el index 6bf45b3..a90bf80 100644 --- a/lisp/tabify.el +++ b/lisp/tabify.el @@ -28,12 +28,17 @@ ;;; Code: ;;;###autoload -(defun untabify (start end) +(defun untabify (start end &optional arg) "Convert all tabs in region to multiple spaces, preserving columns. +If called interactively with prefix ARG, convert for the entire +buffer. + Called non-interactively, the region is specified by arguments START and END, rather than by the position of point and mark. The variable `tab-width' controls the spacing of tab stops." - (interactive "r") + (interactive (if current-prefix-arg + (list (point-min) (point-max) current-prefix-arg) + (list (region-beginning) (region-end) nil))) (let ((c (current-column))) (save-excursion (save-restriction @@ -56,14 +61,19 @@ Usually this will be \" [ \\t]+\" to match a space followed by whitespace. \"^\\t* [ \\t]+\" is also useful, for tabifying only initial whitespace.") ;;;###autoload -(defun tabify (start end) +(defun tabify (start end &optional arg) "Convert multiple spaces in region to tabs when possible. A group of spaces is partially replaced by tabs when this can be done without changing the column they end at. +If called interactively with prefix ARG, convert for the entire +buffer. + Called non-interactively, the region is specified by arguments START and END, rather than by the position of point and mark. The variable `tab-width' controls the spacing of tab stops." - (interactive "r") + (interactive (if current-prefix-arg + (list (point-min) (point-max) current-prefix-arg) + (list (region-beginning) (region-end) nil))) (save-excursion (save-restriction ;; Include the beginning of the line in the narrowing -- 1.8.2 --=-bNd5MPY4sJoqoNSQwCDN--