[Top][All Lists]

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

Re: server-buffer-clients and find-file-hook

From: Lennart Borgman (gmail)
Subject: Re: server-buffer-clients and find-file-hook
Date: Fri, 21 Dec 2007 02:15:56 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Stefan Monnier wrote:
server-buffer-clients is nil (Emacs 22) when find-file-hook is run.
That makes it impossible to test if a buffer has clients at that time.

Seems difficult to solve this one directly: find-file creates the
buffer, so it first creates the buffer then calls find-file-hook then
returns the buffer to server.el (via find-file-noselect): server.el
doesn't get a chance to set server-buffer-clients early enough.

Did this used to work differently in earlier versions of Emacs?

I do not believe it worked differently.

I am using a not-so-very-beatiful work around currently ;-)

(defun as-external-is-from-emacsclient ()
  "Return non-nil if buffer has clients waiting, otherwise nil."
  (or server-buffer-clients
      ;; Fix-me: The above does not work because of what I think is a
      ;; bug in Emacs. Work around:
      (let ((bt (with-output-to-string (backtrace)))
            ;; Hide the regexp in the backtrace:
            (hidden-regexp (concat "server-" "visit-file")))
          (string-match hidden-regexp bt)))))

reply via email to

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