swing是否在java中使用emacs解析器?
我在internet上找到了一个用于emacs的解析器:http://www.emacswiki.org/emacs/rtrt-script.el用于testRT脚本(用于测试的IBM工具)
我想知道是否有可能在JavaSwing应用程序中使用这个EmacsLips解析器文件。我只需要缩进代码的部分。例如,使用以下命令行: 我给出了需要使用rtrt脚本缩进的文件。作为回报,我有一个缩进文件。 有办法吗? 谢谢你的帮助
编辑: 我认为我需要的部分是:
缩进du代码
(defun rtrt-script-indent-line ()
"Indent current line as RTRT-SCRIPT code"
(interactive)
(save-excursion ; si la ligne précedente est test ou
(beginning-of-line)
(if (bobp) ; Check for rule 1
(indent-line-to 0)
(let ((not-indented t) cur-indent)
(if (looking-at "^[ \t]*--[ -=]*\n") ; indentation des commentaires
(progn
(save-excursion ; si la ligne précedente est test ou
(forward-line -1) ; on indente au même niveau.
(if (looking-at "^[ \t]*\\<\\(TEST\|SERVICE\\)\\>")
(setq cur-indent (current-indentation))
(while not-indented
(forward-line -1)
;; on ignore les lignes blanches et les commentaires.
(while (looking-at "^[ \t]*\n")
(forward-line -1))
(if (looking-at "^[ \t]*\\<END\\>") ; Check for rule 3
(progn
(setq cur-indent (current-indentation))
(setq not-indented nil))
; Check for rule 4
(if (looking-at
"^[ \t]*\\<\\(ENVIRONMENT\\|ELEMENT\\|INITIALIZATION\\|DEFINE[ \t]+STUB\\|TERMINATION\\|TEST\\|SERVICE\\|NEXT_TEST\\)\\>")
(progn
(setq cur-indent (+ (current-indentation) rtrt-script-indent))
(setq not-indented nil))
(if (bobp) ; Check for rule 5
(setq not-indented nil))
))))
)
)
(if (looking-at "^[ \t]*\\<\\(END\\|NEXT_TEST\\)\\>") ; Check for rule 2
(progn
(save-excursion
(forward-line -1)
;; on ignore les lignes blanches.
(while (looking-at "^[ \t]*\\(\n\\|--.*\n\\)")
(forward-line -1))
(setq cur-indent (- (current-indentation) rtrt-script-indent)))
(if (< cur-indent 0)
(setq cur-indent 0)))
(save-excursion
(while not-indented
(forward-line -1)
;; on ignore les lignes blanches et les commentaires.
(while (looking-at "^[ \t]*\\(\n\\|--.*\n\\)")
(forward-line -1))
(if (looking-at "^[ \t]*\\<END\\>") ; Check for rule 3
(progn
(setq cur-indent (current-indentation))
(setq not-indented nil))
; Check for rule 4
(if (looking-at
"^[ \t]*\\<\\(ENVIRONMENT\\|ELEMENT\\|INITIALIZATION\\|DEFINE[ \t]+STUB\\|TERMINATION\\|TEST\\|SERVICE\\|NEXT_TEST\\)\\>")
(progn
(setq cur-indent (+ (current-indentation) rtrt-script-indent))
(setq not-indented nil))
(if (bobp) ; Check for rule 5
(setq not-indented nil))
))))
)
)
(if cur-indent
(progn
(save-excursion ; si la ligne précedente est test ou
(message "cur_indent =>%d" cur-indent)
(if (looking-at "^[ \t]*\n")
(indent-line-to 0)
(indent-line-to cur-indent)
;; tant qu'a faire on retire aussi les tabulations.
(untabify (point-at-bol) (point-at-eol)))
)
)
(indent-line-to 0)))
)
)
) ;; If we didn't see an indentation hint, then allow no indentation
# 1 楼答案
像这样的方法应该有用:
请注意,这将用缩进版本覆盖
my-file.rtrt
# 2 楼答案
您可以告诉emacs在启动时运行代码。参见
-f
、-l
和eval
(也可能是batch
)中的选项