[xyzzy]jscript-modeからjavascript-modeに乗り換えた
node.jsの開発でJavaScriptを書く機会が増えたので、補完機能があるmodeはないものかと調べたら、javascript-modeというのが既にあるらしい。
拡張lisp/javascript-mode - XyzzyWiki
sitelisp.lにload-libraryを書くと、Keywordに色が付かなくなるのでSourceを少し修正。
さらにtabを押したときの動きが他のmajor-modeと違うので修正。以下差分を貼りつけ。
# diff -u javascript-mode_old.l javascript-mode_new.l > diff.txt
--- javascript-mode_old.l 2005-03-02 18:48:08.000000000 +0800
+++ javascript-mode_new.l 2011-05-17 19:01:26.000000000 +0800
@@ -156,9 +156,9 @@
"The assoc-array literal for the function javascript-dot-notation.")
(defvar *javascript-keyword-hash-list* nil)
-(and *javascript-keyword-file* (null *javascript-keyword-hash-list*)
- (setq *javascript-keyword-hash-list*
- (load-keyword-file *javascript-keyword-file*)))
+;(and *javascript-keyword-file* (null *javascript-keyword-hash-list*)
+; (setq *javascript-keyword-hash-list*
+; (load-keyword-file *javascript-keyword-file*)))
(defvar *javascript-mode-syntax-table* nil)
(unless *javascript-mode-syntax-table*
@@ -239,6 +239,9 @@
(setq paragraph-separate paragraph-start)
(make-local-variable 'indent-tabs-mode)
(setq indent-tabs-mode *javascript-indent-tabs-mode*)
+ (and *javascript-keyword-file* (null *javascript-keyword-hash-list*)
+ (setq *javascript-keyword-hash-list*
+ (load-keyword-file *javascript-keyword-file*)))
(when *javascript-keyword-hash-list*
(make-local-variable 'keyword-hash-table)
(setq keyword-hash-table *javascript-keyword-hash-list*))
@@ -327,12 +330,21 @@
parent object (eg, 'document', 'window', etc.) Otherwise, it just works
as a generic keyword completion."
(interactive "*")
- (save-excursion
- (setq from (progn (skip-syntax-spec-backward "w_") (point)))
- (and (char= (preceding-char) #\.)
- (backward-char)
- (setq complist (javascript-get-complist))))
- (do-completion from (point) :list complist nil t))
+; (save-excursion
+; (setq from (progn (skip-syntax-spec-backward "w_") (point)))
+; (and (char= (preceding-char) #\.)
+; (backward-char)
+; (setq complist (javascript-get-complist))))
+; (do-completion from (point) :list complist nil t))
+ (if (string-matchp "[0-9A-Z#$%&+._-]" (string (preceding-char)))
+ (progn (save-excursion
+ (setq from (progn (skip-syntax-spec-backward "w_") (point)))
+ (and (char= (preceding-char) #\.)
+ (backward-char)
+ (setq complist (javascript-get-complist))))
+ (do-completion from (point) :list complist nil t))
+ (javascript-indent-line))
+ )
;; javascript-dot-notation: << . >>
(defun javascript-dot-notation ();; v2.0
< 2011/08/16 Modified >
Object-Orientedな開発をしているとindentがうまくいかないので、java-modeで編集するようにした。色を付けるkeywordはetc/Javaを編集する。