I'm trying to run my own elisp code that worked happily 20 years ago (at that time I was using Linux). I'm running my .el (or .elc) file on Mac OSX emacs (version 22.1) on Terminal now.
The elisp program is essentially using the TCP/IP with the server that is written in perl.
I see the elisp code runnning fine but after the TCP/IP communication happens, the terminal inserts "Process net deleted" text on the emacs terminal screen.
I'm pretty sure the name "net" is coming from those elisp code:
(setq pipe (open-network-stream "net" network_buffer Host 10000))
(process-send-string pipe send)
(accept-process-output pipe)
(delete-process pipe)
The problem is I don't know why the emacs shows "Process net deleted" everytime the codes above are executed.
Can any of elisp gurus shed any insight why this message shows up?
I'm aware of the documentation of "network-stream.el" http://repo.or.cz/w/emacs.git/blob/HEAD:/lisp/net/network-stream.el but I have no clue so far.
It's just the default behavior of Emacs when a "process" (network or otherwise) terminates. You can override it with something like
(set-process-sentinel pipe #'ignore)
Related
Some time ago I opened a file via tramp. That is, effectively via ssh/scp. It still is not finished and I would like to stop the reading. Yet C-g does not work. Apart from killing emacs (which seems quite unethical to me, it also destroys my M-x shell s), do I have any other option to stop the loading?
Note that the server does not hang. And I do not want any timeouts like in this question.
If you can find the corresponding ssh / scp process ID, you can kill just that.
If neither C-g nor C-cC-c are interrupting, but Emacs is still responding to M-x commands, you can kill the connection or the whole buffer.
The TRAMP manual suggests that the following M-x commands may be of interest:
M-x tramp-cleanup-this-connection
M-x tramp-cleanup-all-buffers
I am trying to debug an Emacs program performance wise. In particular, I suffer an extremely long startup time (~5' compared to ~1' for a bare Emacs) on a remote connection via WLAN, cellphone etc. In this context, any message written is no help, for the display is not refreshed at all.
What I would like to do is to write onto the "standard output" of the Linux process. I am aware of the --batch mode but this is no help to me because I want to use Emacs interactively.
So how can I write messages out to the Linux-standard output (as opposed to the Emacs standard output)?
You can output to standard error like this:
(print "hello world" #'external-debugging-output)
or
(princ "hello world" #'external-debugging-output)
This can buffer, so be careful.It's not possible to output to standard out at the moment. I'm going to add that, I think!
Start emacs as a daemon (emacs --daemon) and any messages during the start-up sequence will be sent to stdout or stderr, as described by lunaryorn.
Connect to the server with emacsclient
The simplest way to kill the server is M-x kill-emacs RET
For details see C-hig (emacs) Emacs Server RET
Works for me in centos 6.8 (GNU Emacs 23.1.1):
(append-to-file "here I come to save the day\n" nil "/dev/stdout")
Try also using "/dev/tty" in place of "/dev/stdout":
Unclear from question if you intend to redirect "emacs -nw" stdout to a file and monitor that file externally (then use "/dev/stdout"); or are ok with writing to "/dev/tty" thus polluting the self-same tty of the main "emacs -nw" display.
If starting a GUI version of emacs, in such a way it may lose attachment to originating tty, can abuse environment variables to communicate an originating shell's tty to elisp.
This works for me using Aquamacs in Mac OS X. Launching from a bash shell:
$ MY_TTY=$(tty) open /Applications/Aquamacs\ Emacs.app &
then in emacs:
(append-to-file "here I come to save the day\n" nil (getenv "MY_TTY"))
I'm trying, for the first time, to access remote files via tramp from Emacs on Windows. I'm trying to open a remote directory via C-x C-f /plink:user#host:/. However, when Emacs gets to "Tramp: found remote shell prompt" in the minibuffer, it hangs. And not only does the minibuffer hang, but all of Emacs hangs, so that I have to kill it via task manager. This unfortunately means that I can't see any debug information for tramp, because it outputs to an Emacs buffer. How can I go about debugging this?
I'm running Windows 8.1, Emacs 24.3, and plink 0.63.
I ran into a very similar situation with tramp ssh, and I can't guess at what your particular problem is, but only that you can get a complete trace by doing:
(setq tramp-verbose 10)
Then try the connection again, and after it hangs, C-g and check for a buffer:
*debug tramp/plink USER#IP*
The level 10 verbosity might be too overwhelming - you can experiment with lesser levels (smaller numbers) to see if it reveals what the problem might be. Check the docstring for tramp-verbose.
Good Luck!
I just started with common-lisp, having come from C++ and Python. I'm trying to run a simple SDL program that does nothing other than show an image on-screen. I can get it working from within SLIME. The problem is, it won't work when run from the shell as a script.
My program looks like this:
#!/usr/bin/sbcl --script
(asdf:operate 'asdf:load-op :lispbuilder-sdl)
(defun main ()
(sdl:with-init ()
(sdl:window 320 240)
(sdl:draw-surface (sdl:load-image "image.png"))
(sdl:update-display)
(sdl:with-events ()
(:quit-event () t)
(:video-expose-event () (sdl:update-display)))))
(main)
When I run this as a script, I get the following error:
mkg#chisel:~/projects/common-lisp/sandbox$ ./hello-world.lisp
unhandled ASDF:MISSING-COMPONENT in thread #<SB-THREAD:THREAD "initial thread" RUNNING {AA5E849}>:
component "lispbuilder-sdl" not found
0: (SB-DEBUG::MAP-BACKTRACE #<CLOSURE (LAMBDA #) {AAF1EF5}>)[:EXTERNAL]
(... long backtrace omitted)
Oddly, this program works fine if I do the following. I open the program in Emacs, start SLIME in another window, and in the SLIME window, I enter the first line of the program:
(asdf:operate 'asdf:load-op :lispbuilder-sdl)
Then, in the editor window, I hit C-c C-k (compile/load file). This pops up a window showing image.png, as expected.
Why does this not work when run as a shebang script? How can I fix it?
As the man page for sbcl says, --script implies --no-sysinit --no-userinit --disable-debugger --end-toplevel-options, which means that initialization files are not read, and so if you set up ASDF registry there it is not set up, and so it cannot find the lispbuilder-sdl system. You need to either set up the registry in the script itself, or save an executable core with the registry already set up and call that instead of the default sbcl. Usually you can also save libraries in the core instead of loading them in the script, but I am not quite sure how that interacts with non-Lisp libraries and resources.
The usual way when developing in lisp is to use ASDF to describe project and its dependencies. Then, you can easily (asdf:oos 'asdf:load-op :yourapp).
For most implementations there is a way to generate executable form asdf definition.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
On login to Ubuntu, I start an Emacs (version 23) daemon using Ubuntu's Startup programs. I then start Emacs clients whenever I need to edit something. When I logoff from Ubuntu, it says Emacs is still running, of course. I need to attach a script somewhere to tell Gnome to shutdown emacs when I logoff/shutdown.
1) What should the script look like? "kill-emacs" doesn't seem to work.
2) Where should I put this script? There's nothing in the startup programs (System->Sessions menu) panel that looks useful. I'd prefer something that works in the user's account, rather than hacking the PostSession script or something else with root access.
ShreevatsaR is right, the answer is kill-emacs or save-buffers-kill-emacs, both of which are interactive, and so can be run from within Emacs with M-x save-buffers-kill-emacs. This is probably the best way to do it, since you will get to save modified files.
Another alternative is to make a shell file like this:
#!/bin/bash
emacsclient -e "(kill-emacs)"
Which you can run from wherever you like (menu icon, panel, etc).
This linuxquestions.org page has a Python script that can be run during login that listens for the 'save yourself' event that Gnome emits during shutdown. You could modify that to do the:
emacsclient -e '(save-buffers-kill-emacs)'
Official docs: https://www.emacswiki.org/emacs/EmacsAsDaemon#toc8
Another addendum to ShreevatsaR: the python script works like a charm, but I'd suggest using
emacsclient -e '(let ((last-nonmenu-event nil))(save-buffers-kill-emacs))'
as command. Setting last-nonmenu-event to nil forces emacs into mouse-mode, so you get "nice" dialog boxes instead of prompts in the minibuffer.
Or even more fancy (somewhere in your emacs config):
(defun shutdown-emacs-server () (interactive)
(when (not (eq window-system 'x))
(message "Initializing x windows system.")
(x-initialize-window-system)
(when (not x-display-name) (setq x-display-name (getenv "DISPLAY")))
(select-frame (make-frame-on-display display '((window-system . x))))
)
(let ((last-nonmenu-event nil)(window-system "x"))(save-buffers-kill-emacs)))
and then:
emacsclient -e '(shutdown-emacs-server)'
If you use systemd you may be interested in this unit file that lets you manage an Emacs server gracefully from within your console/remote system:
[Unit]
Description=Emacs: the extensible, self-documenting text editor
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Restart=always
# Remove the limit in startup timeout, since emacs
# cloning and building all packages can take time
TimeoutStartSec=0
[Install]
WantedBy=default.target
(it kills the daemon in the same way folks already suggested above.)
You could put and name the unit file like ~/.config/systemd/user/emacs.service so it's bind to your user instead running it as root; to manage it:
$ systemctl --user {enable,disable,start,restart,stop} emacs.service
Please note: I took this note from somewhere else, can't remember where though.
I think that using a script in /etc/init.d is a cleaner solution.
Check here for more details
http://www.emacswiki.org/emacs/EmacsAsDaemon
the answer from willert contains a small bug. it must look like
(defun shutdown-emacs-server () (interactive)
(when (not (eq window-system 'x))
(message "Initializing x windows system.")
(x-initialize-window-system)
(when (not x-display-name) (setq x-display-name (getenv "DISPLAY")))
(select-frame (make-frame-on-display x-display-name '((window-system . x))))
)
(let ((last-nonmenu-event nil)(window-system "x"))(save-buffers-kill-emacs)))
you can put emacsclient -e "(kill-emacs)" in GDM's PostSession directory or directly in the Default script:
/etc/gdm/PostSession/Default
see also GDM documentation.
Perhaps the most general solution would be to put a script in the system PostSession directory that runs every executable script in ~/.logout-d, or something similar. Then you can put whatever scripts you like in ~/.logout-d, and they will be run on logout.
The script might be as simple as run-parts ~/.logout.d.
Note: Untested, though I do use a startup script that does run-parts ~/.autostart.d, and that's been working fine forever.
Edit: Of course, it would be just as easy to modify the above python script to execute that same command, but I personally don't like the idea of loading a script for my entire session just to run commands on logout.
Just open some terminal and pkill -TERM emacs