From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chetan Newsgroups: gmane.emacs.help Subject: Re: Gnuserv vs Emacsserver Date: Mon, 01 Dec 2008 19:32:21 -0800 Organization: Noname Inc. Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1228189252 14550 80.91.229.12 (2 Dec 2008 03:40:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Dec 2008 03:40:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 02 04:41:55 2008 Return-path: Envelope-to: geh-help-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 1L7M92-0001fj-NN for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Dec 2008 04:41:53 +0100 Original-Received: from localhost ([127.0.0.1]:42594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7M7s-0003B8-Ke for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Dec 2008 22:40:40 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!flpi143.ffdc.sbc.com.POSTED!8e1d8614!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Emacs Gnus Cancel-Lock: sha1:3agi5l7QdCb51z7ZnmmwDU4Xigc= Original-Lines: 158 Original-NNTP-Posting-Host: 76.199.139.176 Original-X-Complaints-To: abuse@prodigy.net Original-X-Trace: flpi143.ffdc.sbc.com 1228188611 ST000 76.199.139.176 (Mon, 01 Dec 2008 22:30:11 EST) Original-NNTP-Posting-Date: Mon, 01 Dec 2008 22:30:11 EST X-UserInfo1: TSUGGVCE[BWASVDY[ZOD]_\@VR]^@B@MCPWZKB]MPXHDUWYAKVUOPCW[ML\JXUCKVFDYZKBMSFX^OMSAFNTINTDDMVW[X\THOPXZRVOCJTUTPC\_JSBVX\KAOTBAJBVMZTYAKMNLDI_MFDSSOLXINH__FS^\WQGHGI^C@E[A_CF\AQLDQ\BTMPLDFNVUQ_VM Original-Xref: news.stanford.edu gnu.emacs.help:164976 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60301 Archived-At: --=-=-= Chetan writes: ... > I have wondered about swithing to emacsserver for some time. I have > been using gnuclient for a long time (on W32). Changing over to > emacsserver became a possibility with emacs 22, but I haven't yet done > it. > > For my style of working, I find there are irritations in switching > over. I wonder if anybody has any solution. > > 1. My version of gnuclient starts emacs (if it can find it) if it > cannot connect to a running instance. I could, of course, make sure it > is running before I use it. > > 2. Irrespective of whether I am running emacs 21 or 22, it can still > connect. > > 3. The biggest irritant is that if I start another instance of emacs, > either by mistake or because I want to do something in a console > window, it clobbers my previous instance. With gnuserve, it fails with > a dialog box, which is also irritating, but it works the way I want > it. Ideally I would not like to keep changing the commandline, but I > don't see how I would do it even with that. > > 4. I need to change too many places in the system registry where it > invokes gnuclient. I can perhaps do that if I can handle the others. > > Chetan After looking at the suggestions, I have tried to work on my most irritant point 3. Here is a package that does what I want. Now the next is to try item 4. Looks like creating an executable that handles the same arguments but uses emacsserver is the simplest. I will try to do that for me. Chetan --=-=-= Content-Type: text/emacs-lisp Content-Disposition: inline; filename=server-x.el Content-Description: Extension to server-start in `server' ;; server-x.el -- provide functions for starting emacsserver differently ;; Copyright 2008 by Chetan Pandya ;; ;; This file is NOT (yet) part of GNU Emacs. ;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, you can either send email to this ;; program's maintainer or write to: The Free Software Foundation, ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. ;; ;;; Commentary: ;; ;; This emacs script provides functions starting emacsserver with ;; additional information than server-start. ;; ;; Installation: ;; ;; Simplest way is to `load' or `require' the file. ;; Customize the startup action, if desired. ;; ;;; Code: ;; User configurable variables: (if (< emacs-major-version 22) (error "Not supported on emacs version before 22.0")) (defcustom server-startup 'check "Deal with existing files at startup" :type '(choice (const :tag "Ignore - delete file. Default in absence of server-x" nil) (const :tag "Search - set server name" search) (const :tag "Abort" check)) :group 'server) (defvar server-file-name nil "Name of the server file") (defvar server-name-base nil "Internal: name of the server to use as base") (defvar server-name-prev "" "Internal: name of the server started earlier") (require 'server) (defadvice server-start (around sstart-around protect) (let ((kill-only (ad-get-arg 0)) ret bypass (i 0) (sname server-name) s-dir s-file) (when (not kill-only) ; killing the server (setq s-dir (if server-use-tcp server-auth-dir server-socket-dir)) (setq s-file (expand-file-name sname s-dir)) (cond ((eq server-startup 'check) (when (file-exists-p s-file) (message "File %s exists.\nPlease delete file if another emacs is not using it or change the value of server-name and try again." s-file) (setq bypass t))) ((eq server-startup 'search) (if (or (null server-name-base) (not (string= server-name server-name-prev))) (setq server-name-base server-name)) (while (file-exists-p s-file) (setq i (1+ i)) (setq sname (format "%s%d" server-name-base i)) (setq s-file (expand-file-name sname s-dir)))))) (let ((server-name sname)) (setq ret (if bypass nil ;; ad-do-it ;; ))) (cond (kill-only (if server-file-name (ignore-errors (delete-file server-file-name))) (setq server-process nil server-file-name nil) (remove-hook 'kill-emacs-hook 'server-kill-on-exit)) (t (cond (server-process (setq server-name sname server-name-prev sname ; if user changes it server-file-name s-file) (add-hook 'kill-emacs-hook 'server-kill-on-exit)) (t (setq server-file-name nil) (remove-hook 'kill-emacs-hook 'server-kill-on-exit))))) ret)) (defun server-kill-on-exit () (when (and server-file-name server-process) ;; killing the server tries to close connections, which could hang. ;; (server-start t) ; kill the server ;; Disable new connections (ignore-errors (delete-file server-file-name)))) (unless (featurep 'gnuserv) (ad-activate 'server-start)) ;;(provide 'server-x) ;; server-x.el ends here --=-=-=--