Re: [jasspa] Wierd read-file behaviour in ME09 (revised)
- Gomes, Pedro (NSN - PT/Amadora) wrote:
> Hi All,
> I got some 'weird' behaviour in Micro Emacs 2009 (0909).
> If I define the macro above and press C-f12 to reread the current
> buffer, it re-read the current buffer, but it removes some other buffer
> from the buffer list. If I have 10 buffers besides the one I want to
> reread and I press the C-f12 combination 10 times I will be left with
> only the current buffer and nothing else (and the scratch buffer of course).
> Initially I thought it was due to 'delete-buffer' which I believe its
> irrelevant since the read-file rewrites the current buffer. The previous
> statement is not correct, if I remove the 'delete-buffer' line the macro
> works as it should and does not remove any buffers!!
> Can you explain what might be happening ?
It did not do what you expected because you deleted the old buffer BUT
read-file is not what you expected.
read-file - Find and load file *replacing current buffer*
It is that last bit of the description that has caught you out.
So when you deleted the old buffer then you are then in another buffer
(the next buffer), when you issued "read-file" from this "another"
buffer then it deleted the current buffer you were in (another) and
replaced it with the new one which has the same name as the old one.
So that explains it I hope.
Anyway you should not need this now, simply bind reread-file to C-F12
and it should do what you want; it does prompt if it needs to (i.e. the
file has been edited and you will loose some changes).
P.S. This release should be more stable than 2006 as all we have done is
mainly bug fixes.
> P.S. - By the way, congrats on the new release, looks quite stable!! :P
> define-macro reread-file-with-prompt
> set-variable #l1 $window-aline
> set-variable #l2 $buffer-fname
> 0x1 delete-buffer $buffer-bname ; force destroy (prompting user
> doesn't work in macro)
> ml-write &spr "[Rereading %s]" #l2
> read-file #l2
> #l1 goto-line
> !force global-bind-key reread-file-with-prompt "C-f12"