From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Steinar Bang Newsgroups: gmane.emacs.help Subject: Tip: ide-fix: an IDE formatting fixup function Date: Tue, 23 Jun 2015 16:28:21 +0200 Message-ID: <86616e5wje.fsf@dod.no> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1435069771 18145 80.91.229.3 (23 Jun 2015 14:29:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Jun 2015 14:29:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 23 16:29:30 2015 Return-path: Envelope-to: geh-help-gnu-emacs@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 1Z7PBt-0002JC-Eu for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Jun 2015 16:28:45 +0200 Original-Received: from localhost ([::1]:45619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7PBs-0005oj-QF for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Jun 2015 10:28:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7PBh-0005oe-VE for help-gnu-emacs@gnu.org; Tue, 23 Jun 2015 10:28:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7PBe-00074T-Pi for help-gnu-emacs@gnu.org; Tue, 23 Jun 2015 10:28:33 -0400 Original-Received: from rainey.bang.priv.no ([212.110.185.190]:51951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7PBe-00073M-K0 for help-gnu-emacs@gnu.org; Tue, 23 Jun 2015 10:28:30 -0400 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (windows-nt) X-SA-Exim-Connect-IP: 84.208.248.210 X-SA-Exim-Rcpt-To: too long (recipient list exceeded maximum allowed size of 8 bytes) X-SA-Exim-Mail-From: sb@dod.no X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:57:07 +0000) X-SA-Exim-Scanned: Yes (on rainey.bang.priv.no) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 212.110.185.190 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105099 Archived-At: IDEs are nice in that they can easily navigate code, generate code and move, copy and reorganize code on a structural basis. However, they typically suck at formatting. Formatting is inconsistent across IDEs, different versions of the same IDE and different modules inside a particular IDE. So I've written this small function that I use before committing files to version control systems. My workflow, is: - Code, refactor and test in an IDE - Before committing go to the magit status buffer of the project (I mostly just use git these days) and visit all files with changes, and: - Do `M-x ide-fix RET' - If the files get modified, save them Here's the definition of ide-fix: (defun ide-fix () "Remove trailing spaces and fix indentation" (interactive) (save-excursion (goto-char (point-min)) (replace-regexp "[ \t]+$" "") (indent-region (point-min) (point-max))))