[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [spr5234] killing emacs too easily

>> Kevin -- quick question, I asked about this last version of FI -- how can I
>> make emacs ask me before killing a emacs with a running inferior lisp?
>> Right now, just doing C-x C-c kills my emacs, not what I wanted --

This question comes up a lot (which is why I've cc'd
allegro-cl@Berkeley.EDU).   Here's how I do it:

(setq kill-emacs-hook '(lambda () (my-query-kill-processes)))

(defun my-query-kill-processes ()
  (let ((ps (process-list)))
    (while ps
      (if (or (member-equal (process-name (car ps))
			    '("server" "display-time" "*shell*" "mail-status"))
	      (not (eq 'run (process-status (car ps))))
	      (eq 'exit (process-status (car ps)))
		(condition-case ()
		      (switch-to-buffer (process-buffer (car ps)))
		  (error nil))
		 (format "Kill process %s? " (process-name (car ps))))))
	  (condition-case ()
	      (kill-process (car ps))
	    (error (kill-buffer (process-buffer (car ps))))))
      (setq ps (cdr ps))))
  (sleep-for 1))

(defun member-equal (item list)
  "same as common lisp (member item list :test #'equal)"
  (let ((ptr list)
        (done nil)
        (result '()))
    (while (not (or done (atom ptr)))
      (cond ((equal item (car ptr))
             (setq done t)
             (setq result ptr)))
      (setq ptr (cdr ptr)))

Kevin Layer, Franz Inc.         1995 University Avenue, Suite 275
layer@Franz.COM (internet)      Berkeley, CA  94704  USA
Phone: (510) 548-3600           FAX: (510) 548-8253