[PATCH] make (kill-emacs) from emacsclient work with emacs 23.(1|2)

Subject: [PATCH] make (kill-emacs) from emacsclient work with emacs 23.(1|2)

Date: Wed, 11 Jan 2012 16:49:38 +0200

To: notmuch@notmuchmail.org

Cc: Tomi Ollila

From: Tomi Ollila


emacsclient --eval '(kill-emacs)' doesn't work without interactive
user input. By removing the hook which asks user input makes things
work well enough in our test cases.
---
 test/test-lib.el |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 3b817c3..c52854e 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -26,6 +26,19 @@
 ;; `read' call.
 (setq read-file-name-function (lambda (&rest _) (read)))
 
+;; Work around a bug in emacs 23.1 and emacs 23.2 which prevents
+;; noninteractive (kill-emacs) from emacsclient.
+(when (and (= emacs-major-version 23) (< emacs-minor-version 3))
+  (require 'server)
+  (fset 'server-start-real (symbol-function 'server-start))
+  (defun server-start (&optional leave-dead)
+    (interactive "P")
+    (let ((hc (length kill-emacs-hook)))
+      (unwind-protect
+	  (server-start-real leave-dead)
+	(if (> (length kill-emacs-hook) hc)
+	    (setq kill-emacs-hook (cdr kill-emacs-hook)))))))
+
 (defun notmuch-test-wait ()
   "Wait for process completion."
   (while (get-buffer-process (current-buffer))
-- 
1.7.7.3


Thread: