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

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

RE: Cannot flash line in other window


From: Drew Adams
Subject: RE: Cannot flash line in other window
Date: Wed, 8 Dec 2010 20:10:12 -0800

> I have written a module to temporary (with a timer) highlight a
> region. I find highly usable as it temporarily flashes the region when
> we perform operations that change the position and window of the
> cursor. It tries to be unification of all other such highlighting
> modules I have seen. One thing doesn't work though: I cannot get it to
> highlight things in a window other than the selected one. So I'm
> asking you for help with this. I need this to highlight the
> compilation message line in the compilation buffer (see the advice for
> previous-error and next-error).
> (defun hictx-generic (&optional start end window face duration keep-
> last async-flag)
>   "..."
>   (with-selected-window (or window (selected-window))
>     (let ((ov (make-overlay (or start (line-beginning-position))
>                             (or end (line-end-position)))))
>       (when (and (not keep-last) hictx-last-overlay)
>         (delete-overlay hictx-last-overlay)) ;remove old
>       (setq hictx-last-overlay
> ov)                                  ;set new
>       (overlay-put ov 'window (selected-window))
>       (overlay-put ov 'face (or face 'hictx-face))
>       (if async-flag
>           (run-with-timer (or duration hictx-timeout) nil #'delete-
> overlay ov) ;delete overlay later kind of "asynchronously"
>         (with-timeout ((or duration hictx-timeout))
>           (hictx-wait-key))            ;wait for key
>         (delete-overlay ov)             ;and delete
>         )
>       nil)))

Hi Per,

First, next time please either post a URL to your code or send it in an
attachment.  For anyone to look at your code the way you sent it, it was
necessary to stitch it together piece by piece because of mailer mangling.

Your problem is that the overlay you use has a `window' property that points to
the correct window, but the overlay itself is in the wrong buffer.  An overlay
is associated with a buffer.

Just wrap your code with (with-current-buffer...):

(defun hictx-generic (&optional start end window face
                      duration keep-last async-flag)
  "..."
  (let ((win  (or window (selected-window))))
    (with-selected-window win
      (with-current-buffer (window-buffer win)
        ...)





reply via email to

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