Add support for c preprocessor #if

This commit is contained in:
Greg Sexton 2016-07-03 16:28:45 +01:00
commit 714fba2a9c

View File

@ -165,6 +165,20 @@ position in the CONTENT."
(if (listp face) face (list face))))))))) (if (listp face) face (list face)))))))))
(origami-build-pair-tree create "{" "}" positions)))) (origami-build-pair-tree create "{" "}" positions))))
(defun origami-c-macro-parser (create)
(lambda (content)
(let ((positions (origami-get-positions content "#if\\|#endif")))
(origami-build-pair-tree create "#if" "#endif" positions))))
(defun origami-c-parser (create)
(let ((c-style (origami-c-style-parser create))
(macros (origami-c-macro-parser create)))
(lambda (content)
(origami-fold-children
(origami-fold-shallow-merge
(origami-fold-root-node (funcall c-style content))
(origami-fold-root-node (funcall macros content)))))))
(defun origami-java-parser (create) (defun origami-java-parser (create)
(let ((c-style (origami-c-style-parser create)) (let ((c-style (origami-c-style-parser create))
(javadoc (origami-javadoc-parser create))) (javadoc (origami-javadoc-parser create)))
@ -208,8 +222,8 @@ position in the CONTENT."
(defcustom origami-parser-alist (defcustom origami-parser-alist
`((java-mode . origami-java-parser) `((java-mode . origami-java-parser)
(c-mode . origami-c-style-parser) (c-mode . origami-c-parser)
(c++-mode . origami-c-style-parser) (c++-mode . origami-c-parser)
(perl-mode . origami-c-style-parser) (perl-mode . origami-c-style-parser)
(cperl-mode . origami-c-style-parser) (cperl-mode . origami-c-style-parser)
(js-mode . origami-c-style-parser) (js-mode . origami-c-style-parser)