Improve the clojure parser
This commit is contained in:
parent
142ec95360
commit
2673711f7c
@ -39,7 +39,7 @@
|
|||||||
(c++-mode . origami-c-style-parser)
|
(c++-mode . origami-c-style-parser)
|
||||||
(emacs-lisp-mode . origami-elisp-parser)
|
(emacs-lisp-mode . origami-elisp-parser)
|
||||||
(lisp-interaction-mode . origami-elisp-parser)
|
(lisp-interaction-mode . origami-elisp-parser)
|
||||||
(clojure-mode . origami-elisp-parser))
|
(clojure-mode . origami-clj-parser))
|
||||||
"alist mapping major-mode to parser function."
|
"alist mapping major-mode to parser function."
|
||||||
:type 'hook
|
:type 'hook
|
||||||
:group 'origami)
|
:group 'origami)
|
||||||
@ -67,7 +67,7 @@ children of the pair."
|
|||||||
(parser-1? pair))
|
(parser-1? pair))
|
||||||
pair))))
|
pair))))
|
||||||
|
|
||||||
(defun origami-elisp-parser (create)
|
(defun origami-lisp-parser (create regex)
|
||||||
(lambda (content)
|
(lambda (content)
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert (parser-content-string content))
|
(insert (parser-content-string content))
|
||||||
@ -76,7 +76,7 @@ children of the pair."
|
|||||||
(let (beg end offset acc)
|
(let (beg end offset acc)
|
||||||
(while (< (point) (point-max))
|
(while (< (point) (point-max))
|
||||||
(setq beg (point))
|
(setq beg (point))
|
||||||
(search-forward-regexp "(def\\w*\\s-*\\(\\s_\\|\\w\\|[?!]\\)*\\([ \\t]*(.*?)\\)?" nil t)
|
(search-forward-regexp regex nil t)
|
||||||
(setq offset (- (point) beg))
|
(setq offset (- (point) beg))
|
||||||
(end-of-defun)
|
(end-of-defun)
|
||||||
(backward-char)
|
(backward-char)
|
||||||
@ -86,6 +86,12 @@ children of the pair."
|
|||||||
(beginning-of-defun -1))
|
(beginning-of-defun -1))
|
||||||
(list (reverse acc))))))
|
(list (reverse acc))))))
|
||||||
|
|
||||||
|
(defun origami-elisp-parser (create)
|
||||||
|
(origami-lisp-parser create "(def\\w*\\s-*\\(\\s_\\|\\w\\|[?!]\\)*\\([ \\t]*(.*?)\\)?"))
|
||||||
|
|
||||||
|
(defun origami-clj-parser (create)
|
||||||
|
(origami-lisp-parser create "(def\\(\\w\\|-\\)*\\s-*\\(\\s_\\|\\w\\|[?!]\\)*\\([ \\t]*\\[.*?\\]\\)?"))
|
||||||
|
|
||||||
(provide 'origami-parsers)
|
(provide 'origami-parsers)
|
||||||
|
|
||||||
;;; parser.el ends here
|
;;; parser.el ends here
|
||||||
|
Loading…
Reference in New Issue
Block a user