荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: georgehill (New Century New Dream), 信区: Linux
标  题: [part 1] emacsport.el(转寄)
发信站: BBS 荔园晨风站 (Sat Jan  6 15:20:01 2001), 站内信件

【 以下文字转载自 georgehill 的信箱 】
【 原文由 georgehill.bbs@smth.org 所发表 】
发信人: 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 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.1.115]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店