[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find-file-hook for a specific file?
From: |
Stefan Monnier |
Subject: |
Re: find-file-hook for a specific file? |
Date: |
Wed, 16 Feb 2011 20:34:39 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> I do this now:
> (add-hook 'find-file-hook 'myfile-hook-function)
> (find-file "myfile.txt")
> (remove-hook 'find-file-hook 'myfile-hook-function)
I don't think you can get something much cleaner, no.
But the above should use
(add-hook 'find-file-hook 'myfile-hook-function)
(unwind-protect (find-file "myfile.txt")
(remove-hook 'find-file-hook 'myfile-hook-function))
So that the remove-hook is also executed when find-file signals
an error.
Stefan