unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Want next-error to move current "hit" to the top of the window -- why doesn't this next-error-hook work?
@ 2011-09-15 22:18 Vincent Montressor
  2011-09-27  4:31 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Vincent Montressor @ 2011-09-15 22:18 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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?




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Want next-error to move current "hit" to the top of the window -- why doesn't this next-error-hook work?
  2011-09-15 22:18 Want next-error to move current "hit" to the top of the window -- why doesn't this next-error-hook work? Vincent Montressor
@ 2011-09-27  4:31 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2011-09-27  4:31 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-27  4:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 22:18 Want next-error to move current "hit" to the top of the window -- why doesn't this next-error-hook work? Vincent Montressor
2011-09-27  4:31 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).