Add unix domain socket support for Wnn backend and use it by

default.  If $[CJKT]SERVER environment variable is defined, the
value is used as the server host name.  In JSERVER case, for
example, the server name is determined in the following way:

 $JSERVER --(if null)--> wnn-jserver --(if null)--> "unix"

If the server host name is null or matches "^unix$", unix
domain socket is used.  The path name of the socket can be
specified in wnn-[cjkt]udpath custom variable.
This commit is contained in:
Hiroki Sato 2008-11-08 05:43:16 +00:00
parent 6c903d6cc3
commit c95ad0290b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=222529
3 changed files with 177 additions and 13 deletions

View file

@ -6,6 +6,22 @@ You should get into the habit of checking this file for changes each
time you update your ports collection, before attempting any port
upgrades.
20081108:
AFFECTS: users of editors/tamago
AUTHOR: hrs@FreeBSD.org
The Wnn backend of editors/tamago port now uses unix domain socket
to communicate the server by default. If $[CJKT]SERVER environment
variable is defined, the value is used as the server host name. In
JSERVER case, for example, the server name is determined in the
following way:
$JSERVER --(if null)--> wnn-jserver --(if null)--> "unix"
If the server host name is null or matches "^unix$", unix domain
socket is used. The path name of the socket can be specified in
wnn-[cjkt]udpath custom variable.
20081105:
AFFECTS: users of french/pluxm-devel
AUTHOR: jadawin@FreeBSD.org

View file

@ -6,32 +6,33 @@
#
PORTNAME= tamago
PORTVERSION= ${EGG_DEBIAN_VER}
PORTREVISION= 3
PORTVERSION= 4.0.6.0.20041122.11
PORTREVISION= 4
CATEGORIES= editors elisp
MASTER_SITES= ${MASTER_SITE_DEBIAN}
MASTER_SITE_SUBDIR= pool/main/e/egg
PKGNAMESUFFIX= -${EMACS_PORT_NAME}
DISTFILES= egg_4.0.6+0.20041122cvs.orig.tar.gz
DISTNAME= egg_4.0.6+0.20041122cvs.orig
PATCH_SITES= ${MASTER_SITE_DEBIAN:S,%SUBDIR%,pool/main/e/egg,} \
${MASTER_SITE_LOCAL:S,%SUBDIR%,nork,}
PATCHFILES= egg_4.0.6+0.20041122cvs-11.diff.gz
PATCH_DIST_STRIP= -p1
MAINTAINER= ports@FreeBSD.org
MAINTAINER= hrs@FreeBSD.org
COMMENT= The Multilingual Input Method - Egg V4
EGG_DEBIAN_VER= 4.0.6.0.20041122.11
USE_GMAKE= yes
GNU_CONFIGURE= yes
USE_EMACS= yes
WRKSRC= ${WRKDIR}/egg-4.0.6+0.20041122cvs
ELISPDIR= ${PREFIX}/${EMACS_LIBDIR_WITH_VER}/site-lisp
PLIST_SUB= ELISPDIR="${EMACS_LIBDIR_WITH_VER}/site-lisp"
PORTDOCS= AUTHORS ChangeLog ChangeLog.1997-1998 \
ChangeLog.2000-2001 PROBLEMS README.ja.txt TODO \
README.Debian changelog.Debian
POSTPATCHES= ${FILESDIR}/post-patch-*
.include <bsd.port.pre.mk>
@ -45,17 +46,19 @@ pre-configure:
@${REINPLACE_CMD} -e 's|emacs/site-lisp|${EMACS_NAME}/${EMACS_VER}/site-lisp|g' \
${WRKSRC}/configure
post-patch:
cd ${PATCH_WRKSRC} && ${CAT} ${POSTPATCHES} | ${PATCH}
post-build:
(cd ${WRKSRC}/helper && ${MAKE} egg-helper)
cd ${WRKSRC}/helper && ${MAKE} egg-helper
${INSTALL_DATA} ${WRKSRC}/debian/changelog ${WRKSRC}/changelog.Debian
${INSTALL_DATA} ${WRKSRC}/debian/README.Debian ${WRKSRC}
post-install:
${INSTALL_PROGRAM} ${WRKSRC}/helper/egg-helper ${PREFIX}/bin/egg-helper
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
.for f in AUTHORS ChangeLog ChangeLog.1997-1998 ChangeLog.2000-2001 PROBLEMS README.ja.txt TODO debian/README.Debian
${INSTALL_DATA} ${WRKSRC}/${f} ${DOCSDIR}
.endfor
${INSTALL_DATA} ${WRKSRC}/debian/changelog ${DOCSDIR}/changelog.Debian
cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${DOCSDIR}
.endif
@${CAT} ${PKGMESSAGE}

View file

@ -0,0 +1,145 @@
--- egg/wnn.el.orig 2008-11-08 14:09:35.000000000 +0900
+++ egg/wnn.el 2008-11-08 14:23:22.000000000 +0900
@@ -82,6 +82,10 @@
(const wnn-uniq)
(const wnn-uniq-kanji)))
+(defcustom egg-wnn-helper-path "egg-helper"
+ "path of wnn unix domain connection helper program"
+ :group 'wnn :type 'file)
+
(defcustom wnn-jserver nil
"jserver hostname list. Use N-th port, if hostname is followed
by ':' and digit N."
@@ -99,11 +103,21 @@
by ':' and digit N."
:group 'wnn :type '(repeat string))
+(setq wnn-jserverenv "JSERVER")
+(setq wnn-cserverenv "CSERVER")
+(setq wnn-tserverenv "TSERVER")
+(setq wnn-kserverenv "KSERVER")
+
(defcustom wnn-jport 22273 "jserver port number" :group 'wnn :type 'integer)
(defcustom wnn-cport 22289 "cserver port number" :group 'wnn :type 'integer)
(defcustom wnn-tport 22321 "tserver port number" :group 'wnn :type 'integer)
(defcustom wnn-kport 22305 "kserver port number" :group 'wnn :type 'integer)
+(defcustom wnn-judpath "/tmp/jd_sockV4" "jserver unix domain socket name" :group 'wnn :type 'string)
+(defcustom wnn-cudpath "/tmp/cd_sockV4" "cserver unix domain socket name" :group 'wnn :type 'string)
+(defcustom wnn-tudpath "/tmp/td_sockV4" "tserver unix domain socket name" :group 'wnn :type 'string)
+(defcustom wnn-kudpath "/tmp/kd_sockV4" "kserver unix domain socket name" :group 'wnn :type 'string)
+
(defmacro wnn-backend-plist ()
''(egg-initialize-backend wnn-init
egg-start-conversion wnn-start-conversion
@@ -559,11 +573,11 @@
bunsetsu))
(defvar wnn-server-info-list
- ;; language server port hostname proc coding-system
- '((Japanese jserver wnn-jport wnn-jserver "Wnn" (fixed-euc-jp fixed-euc-jp))
- (Chinese-GB cserver wnn-cport wnn-cserver "cWnn" (fixed-euc-py-cn fixed-euc-zy-cn))
- (Chinese-CNS tserver wnn-tport wnn-tserver "tWnn" (fixed-euc-py-tw fixed-euc-zy-tw))
- (Korean kserver wnn-kport wnn-kserver "kWnn" (fixed-euc-kr fixed-euc-kr))))
+ ;; language server port hostname unixdomain serverenv proc coding-system
+ '((Japanese jserver wnn-jport wnn-jserver wnn-judpath wnn-jserverenv "Wnn" (fixed-euc-jp fixed-euc-jp))
+ (Chinese-GB cserver wnn-cport wnn-cserver wnn-cudpath wnn-cserverenv "cWnn" (fixed-euc-py-cn fixed-euc-zy-cn))
+ (Chinese-CNS tserver wnn-tport wnn-tserver wnn-tudpath wnn-tserverenv "tWnn" (fixed-euc-py-tw fixed-euc-zy-tw))
+ (Korean kserver wnn-kport wnn-kserver wnn-kudpath wnn-kserverenv "kWnn" (fixed-euc-kr fixed-euc-kr))))
(defsubst wnn-server-get-info (lang)
(or (assq lang wnn-server-info-list)
@@ -577,12 +591,16 @@
(symbol-value (nth 2 info)))
(defsubst wnn-server-hostname (info)
(symbol-value (nth 3 info)))
+(defsubst wnn-server-udpath-name (info)
+ (symbol-value (nth 4 info)))
+(defsubst wnn-server-env-name (info)
+ (symbol-value (nth 5 info)))
(defsubst wnn-server-proc-name (info)
- (nth 4 info))
+ (nth 6 info))
(defsubst wnn-server-buffer-name (info)
(concat " *" (wnn-server-proc-name info) "*"))
(defsubst wnn-server-coding-system (info)
- (nth 5 info))
+ (nth 7 info))
(defconst wnn-accept-charset-alist
'((Chinese-CNS ascii chinese-sisheng chinese-cns11643-1 chinese-cns11643-2)))
@@ -1209,9 +1227,11 @@
(port (wnn-server-port server-info))
(hostname-list (wnn-server-hostname server-info))
(proc-name (wnn-server-proc-name server-info))
+ (udpath (wnn-server-udpath-name server-info))
+ (serverenv (wnn-server-env-name server-info))
(msg-form "Wnn: connecting to %S at %s...")
(user-name (user-login-name))
- buf hostname myname port-off proc result msg)
+ buf hostname port-off proc result msg)
(unwind-protect
(progn
(setq buf (generate-new-buffer (wnn-server-buffer-name server-info)))
@@ -1225,13 +1245,24 @@
(setq hostname-list (list hostname-list)))
(while (and hostname-list (null proc))
(setq hostname (or (car hostname-list) "")
- hostname-list (cdr hostname-list)
- myname (if (equal hostname "") "unix" wnn-system-name))
- (if (null (string-match ":" hostname))
- (setq port-off 0)
- (setq port-off (string-to-int (substring hostname (match-end 0)))
- hostname (substring hostname 0 (match-beginning 0))))
- (and (equal hostname "") (setq hostname "localhost"))
+ hostname-list (cdr hostname-list))
+ (if (or (and (getenv serverenv)
+ (string-match "^unix$" (getenv serverenv)))
+ (and (null (getenv serverenv))
+ (or (equal hostname "")
+ (string-match "^unix$" hostname))))
+ (progn
+ (setq hostname "unix"
+ family 'local
+ port udpath))
+ (progn
+ (setq hostname (or (getenv serverenv) hostname "localhost"))
+ (if (null (string-match ":" hostname))
+ (setq port-off 0)
+ (setq port-off (string-to-number (substring hostname (match-end 0)))
+ hostname (substring hostname 0 (match-beginning 0))))
+ (setq family nil)))
+ (setq host hostname)
(let ((inhibit-quit save-inhibit-quit))
(if (and msg
(null (y-or-n-p (format "%s failed. Try to %s? "
@@ -1241,16 +1272,22 @@
server-type hostname))
(message "%s" msg)
(let ((inhibit-quit save-inhibit-quit))
- (condition-case nil
- (setq proc (open-network-stream proc-name buf hostname
- (+ port port-off)))
- ((error quit))))
- (when proc
+ (if (fboundp 'make-network-process)
+ (condition-case nil
+ (setq proc (make-network-process :name proc-name :buffer buf :host host :service port :family family))
+ ((error quit)))
+ (if (string-match "^unix$" hostname)
+ (let ((process-connection-type nil))
+ (setq proc (start-process proc-name buf egg-wnn-helper-path port)))
+ (condition-case nil
+ (setq proc (open-network-stream proc-name buf hostname port))
+ (error quit)))))
+ (when (processp proc)
(process-kill-without-query proc)
(set-process-coding-system proc 'binary 'binary)
(set-process-sentinel proc 'wnn-comm-sentinel)
(set-marker-insertion-type (process-mark proc) t)
- (setq result (wnnrpc-open proc myname user-name))
+ (setq result (wnnrpc-open proc host user-name))
(when (numberp result)
(delete-process proc)
(setq proc nil))))