From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anonymous Sender Newsgroups: gmane.emacs.bugs Subject: bug#890: Problem using `etc/emacs.bash' with EmacsW32 Date: Thu, 4 Sep 2008 19:55:05 +0000 (UTC) Message-ID: <7a35a674aab1ec84bd2f5f9108195042@remailer.metacolo.com> Reply-To: Anonymous Sender , 890@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1220561438 18204 80.91.229.12 (4 Sep 2008 20:50:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Sep 2008 20:50:38 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 04 22:51:33 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KbLnS-0003kq-GI for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Sep 2008 22:51:18 +0200 Original-Received: from localhost ([127.0.0.1]:34228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KbLmT-0001ry-5N for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Sep 2008 16:50:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KbL7A-0006aY-0s for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 16:07:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KbL77-0006ZC-Ub for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 16:07:35 -0400 Original-Received: from [199.232.76.173] (port=50166 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KbL77-0006Z5-Nh for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 16:07:33 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:58738) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KbL77-0000sp-5j for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 16:07:33 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m84K7VCY005953; Thu, 4 Sep 2008 13:07:31 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m84K57i0004685; Thu, 4 Sep 2008 13:05:07 -0700 X-Loop: don@donarmstrong.com Resent-From: Anonymous Sender Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 04 Sep 2008 20:05:07 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 890 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12205581151304 (code B ref -1); Thu, 04 Sep 2008 20:05:07 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 4 Sep 2008 19:55:15 +0000 Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m84JtBwB001122 for ; Thu, 4 Sep 2008 12:55:12 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KbKv8-0003SG-Se for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 15:55:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KbKv8-0003S4-BY for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 15:55:10 -0400 Original-Received: from [199.232.76.173] (port=35721 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KbKv8-0003S1-59 for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 15:55:10 -0400 Original-Received: from remailer.metacolo.com ([193.111.87.9]:52598) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KbKv7-0007Gm-Il for bug-gnu-emacs@gnu.org; Thu, 04 Sep 2008 15:55:09 -0400 Original-Received: by remailer.metacolo.com (Postfix, from userid 1003) id 36FFEFD06D; Thu, 4 Sep 2008 19:55:05 +0000 (UTC) Comments: This message did not originate from the Sender address above. It was remailed automatically by anonymizing remailer software. Please report problems or inappropriate use to the remailer administrator at . X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Thu, 04 Sep 2008 16:07:35 -0400 X-Mailman-Approved-At: Thu, 04 Sep 2008 16:49:54 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:20163 Archived-At: In GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600) of 2008-03-26 on RELEASE Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4)' I am attempting to use the shell script `emacs.bash' that is provided in the `etc' directory of the GNU Emacs distribution. This script defines the shell function named 'edit' to provide a single, consistent command for starting Emacs and subsequently, for calling Emacs via `emacsclient', if `server-start' has been invoked via either the initialization file or M-x server-start. After sourcing the script, the command 'edit [filename]' starts Emacs as expected. However, subsequent calls to `edit' do not result in `emacsclient' being invoked. Instead, new instances of `emacs' are started. The reason for this is that the script contains the following test, which fails for EmacsW32: if [ -e "${HOME}/.emacs_server" -o -e "/tmp/emacs${UID}/server" ]; then Neither of these files is created by EmacsW32. Instead, the file ${HOME}/.emacs.d/server/server is created, by default, when `server-start' is invoked from EmacsW32. I would like to suggest that `etc/emacs.bash' be changed to include that server file in its test for starting `emacsclient', that is, change the test, above, to: if [ -e "${HOME}/.emacs.d/server/server" -o -e "${HOME}/.emacs_server" -o -e "/tmp/emacs${UID}/server" ]; then With this change, the shell function `edit' then appropriately calls `emacsclient' after Emacs has started its server. A second problem occurs after Emacs has been stopped ("killed"). The next time `edit' is called, the code in `etc/emacs.bash' calls `emacsclient' even though Emacs and its server are not running. The reason for this appears to be that the function `server-start' in `lisp/server.el' does not remove ${HOME}/.emacs.d/server/server when it is called when Emacs is killed via C-x C-c (that is, `save-buffers-kill-emacs'). Here is the sequence of calls: - When `(server-start)' is invoked, the following code in `lisp/server.el' adds an anonymous function to `kill-emacs-hook': (add-hook 'kill-emacs-hook (lambda () (server-mode -1))) ;Cleanup upon exit. - When emacs is exited via C-x C-c, the function `save-buffers-kill-emacs' is called. - The function `save-buffers-kill-emacs' calls the function `kill-emacs', which, in turn, calls the list of functions in `kill-emacs-hook'. - `server-mode' includes the form: (server-start (not server-mode)) - When the function `server-start' is called with its optional parameter `leave-dead' set to nil, the code in the following the condition in the form: (unless leave-dead ...) is not executed. This includes the code to remove the server file that was created when `server-start' was originally called, namely, (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir)) (server-file (expand-file-name server-name server-dir))) ;; Make sure there is a safe directory in which to place the socket. (server-ensure-safe-dir server-dir) ;; Remove any leftover socket or authentication file (ignore-errors (delete-file server-file)) ...)) ; `let' and `unless' A possible solution to this problem is to move the `(unless leave-dead)' form inside the `(let* ...)' form after the form: (ignore-errors (delete-file server-file)) I have made this change in my copy of `lisp/server.el' and confirmed that `edit' works correctly for EmacsW32, that is, it starts `emacs' if there is no instance of `emacs' running, and starts `emacsclient' if emacs's server is running. ; End of report