BBS水木清华站∶精华区

发信人: althea (稻草人), 信区: Linux        
标  题: [part 1] emacsport.el 
发信站: BBS 水木清华站 (Fri Dec 29 23:40:40 2000) 
 
;;; emacsport.el --- run emacsport server to wait incoming requests 
 
;; Copyright (C) 2000 Free Software Foundation, Inc. 
 
;; Author:  <pact@pact3.cs.pku.edu.cn> 
;; Keywords: convenience, frames, processes 
 
;; This file 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 2, or (at your option) 
;; any later version. 
 
;; This file 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 GNU Emacs; see the file COPYING.  If not, write to 
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
;; Boston, MA 02111-1307, USA. 
 
;;; Commentary: 
 
;;  
 
;;; Code: 
 
(defcustom ep-server-program "/usr/local/bin/epserver" 
  "*The program to use as the emacsport server. 
Put these lines into your ~/.emacs.el: 
  (require 'emacsport) 
  (ep-server-start)" 
  :group 'server 
  :type 'string) 
 
(defvar ep-server-process nil 
  "the current emacsport server process") 
 
(defvar ep-server-previous-string "") 
 
(defun ep-server-start () 
  "" 
  (interactive) 
  ;; Kill it first 
  (if ep-server-process 
      (progn 
        (condition-case () 
            (delete-process ep-server-process) 
          (error nil)))) 
   
  (let ((euid (user-uid))) 
    (condition-case () 
        (delete-file (format "/tmp/ep-%d" euid)) 
      (error nil))) 
 
  (let ((process-connection-type nil)) 
    (setq ep-server-process 
          (start-process "epserver" nil ep-server-program))) 
  (set-process-filter ep-server-process 'ep-server-process-filter) 
  (set-process-coding-system ep-server-process 'raw-text 'raw-text)) 
 
(defun ep-server-process-filter (proc string) 
  (setq string (concat ep-server-previous-string string)) 
  (while (string-match "\n" string) 
    (let ((request (substring string 0 (match-beginning 0)))) 
      (setq string (substring string (match-end 0))) 
      (condition-case () 
          (make-frame-on-display request) 
        (error nil)))) 
  ;; Save for later any partial line that remains. 
  (setq ep-server-previous-string string)) 
 
(provide 'emacsport) 
 
;;; emacsport.el ends here 
 
-- 
Look Ma, this man can twist his fingers as if they were made of rubber, 
isn't that amazing? -- Not really, he's been using emacs for years...! 
 
 
※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.203.100] 

BBS水木清华站∶精华区