Subject: bug#6910: 23: hl-line-mode fails to work with emacsclient

From: David Reitter <[email-masked]>
Date: Wed, 25 Aug 2010 10:02:20 -0400

X-debbugs-cc: [email-masked]

The report below points out, in essence, that when we jump to a line with an emacsclient command such as

emacsclient --no-wait +55 "~/foo.tex"

then the line highlighting is not updated in hl-line-mode.

This turns out to be due to server-execute running the post-command-hooks without the right buffers being current, and hl-line-mode defines buffer-local hooks.   The patch below addresses that and I'm going to commit it unless somebody objects.

diff --git a/lisp/server.el b/lisp/server.el
index aadaeae..1905f70 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1083,8 +1083,7 @@ The following commands are accepted by the client:
         (let* ((buffers
                 (when files
                   (run-hooks 'pre-command-hook)
-                  (prog1 (server-visit-files files proc nowait)
-                    (run-hooks 'post-command-hook)))))
+                  (server-visit-files files proc nowait))))
 
           (mapc 'funcall (nreverse commands))
 
@@ -1169,7 +1168,8 @@ so don't mark these buffers specially, just visit them normally."
             (unless server-buffer-clients
               (setq server-existing-buffer t)))
           (server-goto-line-column (cdr file))
-          (run-hooks 'server-visit-hook))
+          (run-hooks 'server-visit-hook)
+	  (run-hooks 'post-command-hook)) ;; hooks may be specific to current buffer
 	(unless nowait
 	  ;; When the buffer is killed, inform the clients.
 	  (add-hook 'kill-buffer-hook 'server-kill-buffer nil t)

Begin forwarded message:

> From: Konrad Podczeck <[email-masked]>
> Date: August 23, 2010 4:22:54 PM EDT
> To: [email-masked]
> Cc: Reitter David <[email-masked]>
> Subject: Syncing from Skim to Aquamacs and HL-line mode don't work together
> 
> Hi David,
> 
> I observe the following with the actual Aquamacs (in contrast to the 2.0 distribution):
> 
> Turn HL-line mode on. Syncing from Skim (or Xdvi) to Aquamacs makes the cursor going to the appropriate line, however the line does not get highlighted. 
> 
> Konrad