Adding C-code plug-ins to Emacs?

Adding C-code plug-ins to Emacs?

Post by Will Packar » Sat, 03 May 1997 04:00:00


> Of course, if you want, you can have a simple shell script that tests to
> see if there is an already running emacs, and either start a new one, or
> attach to an existing one:

>     #!/bin/csh -f
>     gnudoit "(make-frame)"
>     if ( ! ( $status == 0 ) ) then
>         xemacs &
>     endif

> The script for what would be $EDITOR would be a little more complex, but
> still doable.  Of course, just never shut down emacs.

This is similar to something that I did here. I found
gnuclient to be a little heavy and awkward, given that
I just wanted to open another xemacs frame. I wrote this
shell script a little while ago, and find it much more
convenient (although YMMV). I called the script "x" for
convenience, and include it (with a simple test) in my
.profile. (Note: this was written for ksh, but should be
easy to convert).

The script works like this:

   If you run "x" with no arguments, it will do one of
   the following:
      - If no server is currently running, it will start
        one iconified (perhaps not mapping the frame
        would be better).
      - If a server *is* running, a new frame will be
        created displaying the current buffer.

   If you provide arguments to "x", it will first
   start a server if one doesn't exist. It will then
   treat each of the arguments as a filespec and open
   them in reverse order, so that the first one presented
   is the first one specified on the command line, etc.

   You must explicitly kill buffers. Also, the C-x C-c
   sequence has been re-mapped to delete-frame, so that
   using "x" is similar to using a lightweight editor.
   The "vi" oriented people here appreciate this, since
   they aren't used to leaving an editor running.

The script contains a reference to "do-gnuserv", a simple
function that I placed in site-start.el:

;; Start Xemacs server
(defun do-gnuserv ()
  "Perform operations to establish Xemacs server"
  (progn (gnuserv-start)
                 (global-set-key '[(control x) (control c)]

I'm not the most proficient shell programmer, so my
apologies to those who are!

# x - shell script to use server functionality of Xemacs

gnuclient -q  2>/dev/null

ServerStarted=$?    # get rc of last command

# Start xemacs server if not done already
if [ ServerStarted -eq 0 ] ; then
  # server has already been started
  if [ Args -eq 0 ] ; then
        # no arguments, so open new frame
        echo "New Frame"
        gnudoit -q "(new-frame)"
        exit 0
  # start the server and wait for it to accept requests
  echo "Starting XEmacs server\c"
  xemacs -iconic -f "do-gnuserv" >/dev/null&
  until gnuclient -q  2>/dev/null; do
        sleep 1
        echo ".\c"
  sleep 1
  echo "XEmacs server started"

if [ Args -ne 0 ] ; then
  # invoke client application to edit file(s)
  echo "xemacs "$*" &"

  # Get file names in reverse order
  while [ $1 ]; do
        if [ "$2" = "" ]; then
          # Open the last file in another frame
          gnudoit "(find-file-other-frame \"$PWD/$1\")" >/dev/null
          reverse=$1" $reverse"

  # Find the rest of files
  for i in $reverse
        # Open all remaining files in reverse order
        gnudoit "(find-file \"$PWD/$i\")" >/dev/null


Will Packard


1. Adding C-code plug-ins to Emacs?


can I add new Emacs Primitives in C code to Emacs without recompiling
the whole Emacs program? - Probably not, because this would necessitate
dynamic linking and extension of the Emacs code, which is very easy in
Java, but difficult in C.

Maybe some time, Java will be fast enough so that we can reimplement
Emacs in Java. We would also have platform-independent threads then,
which would solve many of the problems of Emacs.  




2. Must be something simple..I hope :)

3. indenting C-Code

4. DeScribe Voyager...

5. how to indent a large C-code???

6. Speed Control Issues

7. browsing a c-code with xemacs

8. Hotmail and Pocket PC Inbox

9. C++ comments in C-code

10. No C-code Color Highlighting

11. EMACS/AUCTEX and dtx/ins file types

12. Beginner's error: dynamic menu lisp code and add-submenu/stringp error

13. dtx and ins in xemacs