Juri Linkov wrote: > What causes trouble here is the fact that Emacs changes the current > buffer behind the scenes (somewhere in the main loop), so at the end > of the function it is not known what the buffer will be current after > the function finishes. But sometimes it is desirable to perform some > actions on that buffer (e.g. run hooks).
But you also changed the selected window. That is the cause of the trouble. > Maybe with-current-buffer should keep track of switching buffers > inside with-current-buffer, so it could anticipate what a buffer will > be set as current and don't restore the old buffer. > > Or maybe `pop-to-buffer inside with-current-buffer' is not a suitable > programming construct (I mean mostly for the `next-error' command > where this problem occurred) and it's better to replace it with more > explicit buffer switching that will restore the old buffer only when > there were no `pop-to-buffer' calls. In the old days we'd use save-window-excursion; now there is save-selected-window. Should there be a with-selected-window macro, analogous to with-current-buffer? -- Kevin Rodgers _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel