Re: emacs for everything?

From:

Floyd L. Davidson

Subject:

Re: emacs for everything?

Date:

Thu, 30 Dec 2004 06:11:02 -0900

User-agent:

gnus 5.10.6/XEmacs 21.4.15/Linux 2.6.5

Ravi Uday <address@hidden> wrote:
><snip>
>> The command is `emacsclient', one word with no dash.
>> I belive that was a misprint in the previous message, maybe
>> due to the
>> dash in the command that start the sever ;)
>>
>
>Yea right, it works, but how does one start the server to enable
>this client to connect to it. Do you have a procedure which
>could be easily followed ?
Everyone is telling you to put it into your ~/.emacs, and I'm
going to tell you *do not do that*! If you do, it means you
cannot execute Emacs without starting a server... a limitation
you do *not* want.
So... make either an alias or a shell function to invoke the
server in a different manner than a regular Emacs. For example,
"alias emacs-server=/usr/bin/emacs -f server-start" is just about
the simplest way to start it.
However there are other options and issues you might want to
think about too...
Since it is a server, you may want it to be invoked by the startup
for either your login shell or perhaps a window manager. In the
case of starting by a window manager, you don't need to ever see
the actual emacs window! So use the "-iconic" command line option
to get rid of it.
alias emacs-server=/usr/bin/emacs -iconic -f server-start"
Another possibility is that you'll want other changes to the
initialized environment for the server that are different from an
emacs invoked separately. That is easy to accomplish too,
alias emacs-server=/usr/bin/emacs -l ~/.emacs-server -iconic
Now it will, after reading the regular init files (i.e.,
~/.emacs), also read ~/.emacs-server. You can put whatever
changes you want into that file, and end it with "server-start"
in order to invoke the server.
What would you want different??? Well, ymmv, but I don't want to
kill the server everytime I type in C-x C-c (which is exactly what
happens if you do that with only one emacsclient process active).
Exiting with C-x C-c is a reflex that my fingers know very well,
so I want to continue using that, but don't want to ever kill
the server with it. So in my case I've redefined the exit code
that C-x C-c is bound to.
;; for GNU Emacs only
(unless (featurep 'xemacs)
(defvar current-frame nil)
(setq gnuserv-frame (current-frame)))
;;
;; disallow exiting from a command (menu option only)
;;
(defun do-exit ()
"Exits Emacs or an Emacs client"
(interactive)
(if (gnuserv-running-p)
(if (eq gnuserv-clients nil) (delete-frame) (gnuserv-edit))))
(define-key ctl-x-map "\C-c" 'do-exit)
Warning: I use XEmacs, not GNU's version. Hence none of the
above has been tested in a long time and is provided as an
example of where to start.
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) address@hidden