Per-buffer folding styles and explicit folding on triple-braces.

This commit is contained in:
David Högberg 2015-08-13 16:48:10 +02:00
parent a44b0660f0
commit 6f9367575a
2 changed files with 10 additions and 2 deletions

View File

@ -47,7 +47,8 @@
(python-mode . origami-indent-parser)
(emacs-lisp-mode . origami-elisp-parser)
(lisp-interaction-mode . origami-elisp-parser)
(clojure-mode . origami-clj-parser))
(clojure-mode . origami-clj-parser)
(triple-braces . origami-triple-braces-parser))
"alist mapping major-mode to parser function."
:type 'hook
:group 'origami)
@ -217,6 +218,11 @@ position in the CONTENT."
(defun origami-clj-parser (create)
(origami-lisp-parser create "(def\\(\\w\\|-\\)*\\s-*\\(\\s_\\|\\w\\|[?!]\\)*\\([ \\t]*\\[.*?\\]\\)?"))
(defun origami-triple-braces-parser (create)
(lambda (content)
(let ((positions (origami-get-positions content "{{{\\|}}}")))
(origami-build-pair-tree create "{{{" "}}}" positions))))
(provide 'origami-parsers)
;;; origami-parsers.el ends here

View File

@ -380,7 +380,9 @@ was last built."
-last-item
origami-fold-data)
(origami-create-overlay beg end offset buffer)))))))
(-when-let (parser-gen (or (cdr (assoc (buffer-local-value 'major-mode buffer)
(-when-let (parser-gen (or (cdr (assoc (if (local-variable-p 'origami-fold-style)
(buffer-local-value 'origami-fold-style buffer)
(buffer-local-value 'major-mode buffer))
origami-parser-alist))
'origami-indent-parser))
(funcall parser-gen create))))