From: Chetan <Chetan.xspam@xspam.sbcglobal.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Gnuserv vs Emacsserver
Date: Mon, 01 Dec 2008 19:32:21 -0800 [thread overview]
Message-ID: <ufxl7ntfe.fsf@myhost.sbcglobal.net> (raw)
In-Reply-To: uvdu7ebcb.fsf@myhost.sbcglobal.net
[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Extension to server-start in `server' --]
[-- Type: text/emacs-lisp, Size: 3721 bytes --]
;; 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
next prev parent reply other threads:[~2008-12-02 3:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1447.1227901272.26697.help-gnu-emacs@gnu.org>
2008-11-28 22:26 ` Gnuserv vs Emacsserver Chetan
2008-11-29 10:04 ` Eli Zaretskii
[not found] ` <mailman.1476.1227953070.26697.help-gnu-emacs@gnu.org>
2008-11-29 13:10 ` Will Parsons
2008-12-02 3:32 ` Chetan [this message]
2008-11-30 18:46 Magnus Berg
-- strict thread matches above, loose matches on Subject: below --
2008-11-28 19:41 Magnus Berg
2008-11-28 19:46 ` Lennart Borgman
2008-11-27 13:03 Magnus Berg
2008-11-27 14:16 ` Lennart Borgman
2008-11-26 13:14 Magnus Berg
2008-11-26 15:13 ` Lennart Borgman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ufxl7ntfe.fsf@myhost.sbcglobal.net \
--to=chetan.xspam@xspam.sbcglobal.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).