LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 957|回复: 2

有人用emacs写jsp吗?

[复制链接]
发表于 2005-1-21 13:45:31 | 显示全部楼层 |阅读模式
emacs好像没有标准的jsp模式,我在国外的网站上找到这么一个东东,但是java语法还是没有对齐,不知道怎么回事?



  1. ; functions to perform correct indentation of java code within a
  2. ; JSP page. I can live without syntax coloring - I can't live
  3. ; without proper indentation
  4. ;
  5. (setq auto-mode-alist
  6.      (cons '("\\.jsp\\'" . html-mode) auto-mode-alist))

  7. (defun jsp-java-sob ()
  8. "Return the point for the enclosing <% or nil if not present"
  9. (save-excursion
  10.    (search-backward "<%")))

  11. (defun jsp-java-eob ()
  12. "Return the point for the enclosing %> or nil if not present"
  13. (save-excursion
  14.    (search-forward "%>")))

  15. (defun jsp-in-java-debug ()
  16. (interactive)
  17. (if (jsp-in-java)
  18.      (message "debug: in java code")
  19.    (message "debug: not in java code")))

  20. (defun jsp-in-java ()
  21. (save-excursion
  22.    (let* ((current-point (point))
  23.           (start-java-tag (jsp-java-sob))
  24.           (end-java-tag (jsp-java-eob)))
  25.      (and (> current-point start-java-tag)
  26. (< current-point end-java-tag)))))


  27. (defun jsp-indent-java ()
  28. (interactive)
  29. "Indent a java block within a JSP page "
  30. (save-excursion
  31.    (let ((start (+ 2 (jsp-java-sob)))
  32.          (end (jsp-java-eob) ))
  33.      (if (string= "!" (char-to-string (char-after start)))
  34.          (setq start (+ start 1))
  35.        nil)
  36.      (if (jsp-in-java)
  37.          (progn
  38.            (java-mode)
  39.            (goto-char start)
  40.            ;; needed for proper indentation - removed later
  41.            (newline)   
  42.            (insert "{")
  43.            (newline)
  44.            
  45.            (goto-char end)
  46.            ;; needed for proper indentation - removed later
  47.            (newline)
  48.            (insert "}")
  49.            (newline)
  50.            ;;
  51.            ;; perform the indentation
  52.            ;;
  53.            (indent-region (+ start 2) (- end 0) nil)
  54.            ;;
  55.            ;; now remove the text we termporarily added for indentation
  56.            ;;
  57.            (delete-region (- (point) 3) (point))
  58.            (delete-region start (+ start 3))
  59.            (html-mode))
  60.        ()))))

  61. (setq html-mode-hook
  62.      '(lambda ()
  63.         (define-key sgml-mode-map "\C-c\C-q"  'jsp-indent-java)
  64.         ))
复制代码
发表于 2005-1-25 12:51:43 | 显示全部楼层
你好我用emacs写jsp 并且也进行了配置 我qq是179699468要的话我发给你
回复 支持 反对

使用道具 举报

发表于 2005-1-25 13:28:09 | 显示全部楼层
噢可以发附件的这就发上去 我也是从国外找的 这个里边有需要的模式文件和配置文件

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表