[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gnuserv vs Emacsserver
From: |
Chetan |
Subject: |
Re: Gnuserv vs Emacsserver |
Date: |
Mon, 01 Dec 2008 19:32:21 -0800 |
User-agent: |
Emacs Gnus |
Chetan <Chetan.xspam@xspam.sbcglobal.net> 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
;; server-x.el -- provide functions for starting emacsserver differently
;; Copyright 2008 by Chetan Pandya <pandyacus@yahoo.com>
;;
;; 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Gnuserv vs Emacsserver,
Chetan <=