unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* disable save hook temporarily
@ 2013-08-20 17:45 wempwer
  2013-08-21 14:22 ` Tim Visher
  2013-08-21 15:44 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: wempwer @ 2013-08-20 17:45 UTC (permalink / raw)
  To: help-gnu-emacs

Hello Emacs users,


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.
-- 
wempwer@gmail.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: disable save hook temporarily
  2013-08-20 17:45 disable save hook temporarily wempwer
@ 2013-08-21 14:22 ` Tim Visher
  2013-08-22 21:32   ` wempwer
  2013-08-21 15:44 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Tim Visher @ 2013-08-21 14:22 UTC (permalink / raw)
  To: wempwer; +Cc: emacs

On Tue, Aug 20, 2013 at 1:45 PM,  <wempwer@gmail.com> 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?

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: disable save hook temporarily
  2013-08-20 17:45 disable save hook temporarily wempwer
  2013-08-21 14:22 ` Tim Visher
@ 2013-08-21 15:44 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2013-08-21 15:44 UTC (permalink / raw)
  To: help-gnu-emacs

> 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 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.


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: disable save hook temporarily
  2013-08-21 14:22 ` Tim Visher
@ 2013-08-22 21:32   ` wempwer
  2013-08-23 19:03     ` Tim Visher
  0 siblings, 1 reply; 5+ messages in thread
From: wempwer @ 2013-08-22 21:32 UTC (permalink / raw)
  To: Tim Visher; +Cc: emacs

On Wed, Aug 21, 2013 at 10:22:23AM -0400, Tim Visher wrote:
> On Tue, Aug 20, 2013 at 1:45 PM,  <wempwer@gmail.com> 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?

-- 
<wempwer@gmail.com>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: disable save hook temporarily
  2013-08-22 21:32   ` wempwer
@ 2013-08-23 19:03     ` Tim Visher
  0 siblings, 0 replies; 5+ messages in thread
From: Tim Visher @ 2013-08-23 19:03 UTC (permalink / raw)
  To: wempwer; +Cc: emacs

On Thu, Aug 22, 2013 at 5:32 PM,  <wempwer@gmail.com> wrote:
> On Wed, Aug 21, 2013 at 10:22:23AM -0400, Tim Visher wrote:
>> On Tue, Aug 20, 2013 at 1:45 PM,  <wempwer@gmail.com> 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.

It's not in every single directory with .c files. It's in the top
level of projects you're contributing to that you know you're defaults
don't line up with. You could probably save off a
`nullify-c-mode-save-hooks.el` file somewhere on your system and have
it be part of your cloning process to drop it into the directory when
you first clone it.

I certainly agree that it's slightly annoying but I wouldn't call it onerous.

But if you find out a more elegant way to do it, let us know!

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-23 19:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 17:45 disable save hook temporarily wempwer
2013-08-21 14:22 ` Tim Visher
2013-08-22 21:32   ` wempwer
2013-08-23 19:03     ` Tim Visher
2013-08-21 15:44 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).