help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Want next-error to move current "hit" to the top of the window -- wh


From: Kevin Rodgers
Subject: Re: Want next-error to move current "hit" to the top of the window -- why doesn't this next-error-hook work?
Date: Mon, 26 Sep 2011 22:31:03 -0600
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.20) Gecko/20110804 Thunderbird/3.1.12

On 9/15/11 4:18 PM, Vincent Montressor wrote:
> I'd like it if next-error moved the current "hit" to the top of the
> next-error (compilation, grep, etc.) window.  So I tried making this
> hook function, which I thought would do that:
>
>    (add-hook 'next-error-hook
>              '(lambda ()
>                 (when next-error-last-buffer
>                   (save-excursion
>                     (switch-to-buffer-other-window next-error-last-buffer)
>                     (recenter 0))
>                   (other-window))))
>
> This sort of works, but point is in the next-error (compilation, grep,
> etc.) window after it's done, whether or not I do the (other-window)
> at the end, and I'd like point to be in the source window instead (as
> it is when I don't execute this hook function).  I'm puzzled by the
> failure of (other-window) to solve this problem for me.  Is there a
> better way to do it?

Perhaps switch-to-buffer-other-window is changing the window-buffer
correspondence in a way that violates the assumptions of the next-error
command.

Maybe try:

(when (and next-error-last-buffer
           (get-buffer-window next-error-last-buffer))
  (with-selected-window (get-buffer-window next-error-last-buffer)
    (recenter 0)))

--
Kevin Rodgers
Denver, Colorado, USA




reply via email to

[Prev in Thread] Current Thread [Next in Thread]