Wilfred / helpful

A better Emacs *help* buffer
1.11k stars 62 forks source link

save mark and excursion before update helpful buffer #301

Closed lebensterben closed 2 years ago

lebensterben commented 2 years ago

This commit wraps helpful--update-and-switch-buffer inside a save-buffer-and-excursion form.

This make sure that the point and mark of the original buffer (where helpful-* commands are invoked) are saved, before updating and showing the helpful buffer.

Wilfred commented 2 years ago

I don't understand: nothing is moving the point or mark in the initial buffer as far as I can see. When does this happen?

lebensterben commented 2 years ago

@Wilfred

This happens when I was invoking helpful-function when the point is on a symbol within a defun-like macro. It happens consistently.

Say I have

(define-macro symbol-name ...)

And the point is on the symbol-name. M-x helpful-function correctly shows the desired helpful buffer with the function's information.

After closing the helpful buffer, it returns to the original buffer where helpful-function was first invoked. But the point is moved to the beginning of the line.

(If I had an active region selecting the symbol, it also disappear.)

lebensterben commented 2 years ago

@Wilfred

Update, I'm able to reproduce this on regular defcustom form:

Wilfred commented 2 years ago

Thanks for the repro! I think the problem here is actually in helpful--definition, so anyone doing M-x helpful-update would still point move. I've added a different fix plus a test.