有一些流程输出需要每行解析成结构体。
sug skProc strutils.capitalize proc (string): string{.noSideEffect.}
sug skProc strutils.quoteIfContainsWhite proc (string): string
sug skProc system.gorge proc (string, string): string
sug skProc system.of proc (T, S): bool{.noSideEffect.}
sug skProc system.definedInScope proc (expr): bool{.noSideEffect.}
sug skIterator system.items iterator (cstring): char{.inline.}
sug skProc system.ord proc (T): int{.noSideEffect.}这些数据在一个缓冲区中。那么,我如何读取每一行并将其传递给一个函数,该函数返回一个解析的表示并最终收集所有行呢?
编辑:解析行的代码(未调试):
(defstruct nimrod-sug type namespace name signature)
(defun nimrod-parse-suggestion-line (line)
(let ((split (split-string line "[\t\n]")))
(make-nimrod-sug
:type (nth 1 split)
:namespace (first (split-string (nth 2 split) "\\."))
:name (second (split-string (nth 2 split) "\\."))
:signature (nth 3 split))发布于 2013-01-03 06:20:29
对解析器做了一些小改动:
(defun nimrod-parse-suggestion-line (line)
(destructuring-bind (_ type fn &rest sig) (split-string line "[[:space:]]+" t)
(make-nimrod-sug :type type
:namespace (first (split-string fn "\\."))
:name (second (split-string fn "\\."))
:signature (apply 'concat sig)))) 假设缓冲区的名称是*output*,您可以这样解析它:
(with-current-buffer "*output*"
(mapcar 'nimrod-parse-suggestion-line
(split-string (buffer-string) "[\r\n]" t)))
; => ([cl-struct-nimrod-sug "skProc" "strutils" "capitalize" "proc(string):string{.noSideEffect.}"] ...)如果您当前正在访问输出缓冲区,则不需要with-current-buffer包装器。
https://stackoverflow.com/questions/14129842
复制相似问题