1295Re: [jasspa] open, save hooks?
- Dec 22, 2004Kimmo,
It is dangerous to do something like this too low down as it can break other
things, for example the CVS interface loads the CVS/Entries file and if your
extension made the file load and go to line 20 the cvs directory list would
not be correct, there are plenty of other examples.
I think the best way to do this would be to write a wrapper around the
find-file command and bind the new macro to C-x C-f, i.e.
!if '$buffer-fname in list' and 'file just loaded'
global-bind-key my-find-file "C-x C-f"
You may find that you have to replace a couple of commands but the side effect
are far easier to control. The difficulty with this is to actually store the
final cursor position of each file as it is deleted and this will require a
little hacking in the macro release.
The best mechanism to use would be the very little used $buffer-dhook variable which
can be set to the name of a macro which will be called when the buffer is
deleted. The only difficulty is setting this variable and the only solution I
can think of that's near reasonable is to modify the buffer-init function in
buffinit.emf (look for the setting of $buffer-fhook) to simply set this
variable to your macro. You will also need to create an fhook-default to
handle general files without a hook.
I have been thinking for some time that if a 'my-fhook-always' macro exists
then it is called for all files loaded, perhaps this can be addressed for the
next release so you would be able to remove your changes from buffinit.
> Subject: [jasspa] open, save hooks?
> From: Kimmo Pietarinen <kipi@...>
> Date: Wednesday, December 22, 2004, 9:52:43 PM
> To: "jasspa group" <firstname.lastname@example.org>
> I miss the functionality that is found for example in vim that the cursor
> position is saved for visited files and restored when the file is re-opened.
> I know that it is possible to get a somewhat similar functionality by using
> the -c flag to 'me', but I do not want 'me' to restore my entire previous
> session including open files etc.
> Ok, so I though I would have this as a small Chrismas project and
> implement a macro that does this. I am new to macro programming and have
> only done some small macros previously. I have searched the help pages but
> not really figured out how to intercept the file open and save commands. Is
> it possible to do and what hooks or callbacks should I use? I have tried to
> do something with $buffer-fhook, $buffer-bhook and $buffer-dhook, but they
> do not seem really appropriate...
> Online Virus Test: Scanna din computer GRATIS online-scanna
> This is an unmoderated list. JASSPA is not responsible for the content of
> any material posted to this list.
> To unsubscribe, send a mail message to
> or visit http://groups.yahoo.com/group/jasspa and
> modify your account settings manually.
> Yahoo! Groups SponsorGet unlimited calls to
> Yahoo! Groups Links
> To visit your group on the web, go to:
> To unsubscribe from this group, send an email to:
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
- << Previous post in topic Next post in topic >>