From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: wempwer@gmail.com Newsgroups: gmane.emacs.help Subject: Re: disable save hook temporarily Date: Thu, 22 Aug 2013 23:32:16 +0200 Message-ID: <20130822213216.GA7138@a.lan> References: <20130820174528.GA3337@a.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1377207121 32383 80.91.229.3 (22 Aug 2013 21:32:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Aug 2013 21:32:01 +0000 (UTC) Cc: emacs To: Tim Visher Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 22 23:32:03 2013 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 1VCcU4-0004kC-EU for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Aug 2013 23:32:00 +0200 Original-Received: from localhost ([::1]:33926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCcU4-00065P-2b for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Aug 2013 17:32:00 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCcTm-00062o-5d for help-gnu-emacs@gnu.org; Thu, 22 Aug 2013 17:31:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCcTd-0008DX-Av for help-gnu-emacs@gnu.org; Thu, 22 Aug 2013 17:31:41 -0400 Original-Received: from mail-bk0-x235.google.com ([2a00:1450:4008:c01::235]:48106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCcTd-0008D8-4a for help-gnu-emacs@gnu.org; Thu, 22 Aug 2013 17:31:33 -0400 Original-Received: by mail-bk0-f53.google.com with SMTP id d7so917578bkh.12 for ; Thu, 22 Aug 2013 14:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=5yREj5JhTCnmb3jAsngqHj1OHQayj8FEMXQwMTXMNgc=; b=Qno1B7nlunxvEPa+f+CVdwaOr4zy+S6lp1LCF2F55YGZl71ekf1lMW4LuoTyWdwMTS kl22zMwoYO6rXK/5xAO2ZjJ3nrfba/ov1bLSKIhuhUGdEjrqtcj7Ad6Das5O75W0XIaT rH+ZE5XKwVZ0N6q8+ZIPWYEaAzDe1aglkuUJk2+PI2JaWGORfEtrT3QhVnnveYDCoMrD v5LmHo3b//8L8R/Nu02AI3kKLCkQz8MzvyJdXK1r17iM+9ojMyUsv2hVVHoCjoe8UrTM zsHGmpD3IiOb3Lu8RRzs6vHOz8lhBzx3HBN9mI1w/rKbMlddscbLwlZjWitmNdIr3sk3 EiZg== X-Received: by 10.204.103.199 with SMTP id l7mr12153131bko.11.1377207091804; Thu, 22 Aug 2013 14:31:31 -0700 (PDT) Original-Received: from localhost (89-70-245-0.dynamic.chello.pl. [89.70.245.0]) by mx.google.com with ESMTPSA id qe6sm3498488bkb.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 22 Aug 2013 14:31:31 -0700 (PDT) Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4008:c01::235 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:93059 Archived-At: On Wed, Aug 21, 2013 at 10:22:23AM -0400, Tim Visher wrote: > On Tue, Aug 20, 2013 at 1:45 PM, wrote: > > I have plenty of stuff put in my C-mode save hook such as untabify, > > remove trailing whitespaces, add a new line at the end etc. It's good > > but sometimes I receive code from someone, need to do some changes in > > it and send it back or just contribute to a larger project that > > already has their own set of rules I don't want to break. The other > > thing is that sometimes, especially in very big files it can take a > > substantial amount of time to parse the whole buffer and execute save > > hook. So my question is, what is the fastest and the most convenient > > way to disable c save hook temporarily or how do you handle these > > things? One idea that came to mind is to store all my code in a > > specified directory such as ~/c and execute my save hook only for > > files in this directory and don't call the hook for files in other > > directories. > > This is untested, but maybe putting > > ((c-mode . ((before-save-hook . nil)))) > > in the `.dir-locals.el` file of the project would do the trick? This concept is quite similar to my idea but instead of putting all .c files I want to be processed by save hook into one directory and running a hook that checks if a particular file actually is in a given directory you suggest to put `.dir-locals.el' file in every single directory with .c files. Seems quite error-prone and tiring. > One potential direction is to try and use something similar to > highlight-changes, not to highlight the changes, but to keep track > of them and then only apply those "normalization functions" on the > parts of the buffer you've actually modified. I don't think this is what I am looking for. The problem is I don't to run *any* save hooks on most files but only on selected ones, these ones that belong to me or ones that I am sure about coding rules. ATM I start to think that save hooks should be disabled by default and activated manually. Otherwise there is no benefit from them - why would I need to, let's say, change all tabs to spaces in a project I touched for the first time or was given by e-mail and need to send back? --