* Folding yaml by markers
@ 2019-10-11 14:41 Hartmut Goebel
2019-10-14 13:02 ` Robert Pluim
0 siblings, 1 reply; 3+ messages in thread
From: Hartmut Goebel @ 2019-10-11 14:41 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
I have to deal with some YAML documents, which use some kind of
"literate programming": The comments contain documentation for the
values. These files already contain fold markers `[[[` and `]]]`
provided by the mainterner (who uses vim).
I want to leverage these fold markers for emacs, by adjusting
hs-special-modes-alist, but did not manage. The blocks are folded by
yaml-structure, not by fold marks.
Any idea how do I need to set hs-special-modes-alist?
Here is my code:
(defvar hs-special-modes-alist
(mapcar 'purecopy
'((yaml-mode "[[[" "#\s+]]]" nil))))
And here is an example document:
---
# Heading/Folding structure in this document
# * Variables
# ** PostgreSQL installation, packages
# *** .. envvar:: postgresql__upstream
# *** .. envvar:: postgresql__upstream_key_id
# *** pg_wrapper integration
# *** .. envvar:: postgresql__default_database
#
# Variables [[[
# =======================================
# PostgreSQL installation, packages [[[
# -------------------------------------
# .. envvar:: postgresql__upstream [[[
#
# Enable PostgreSQL Global Developmet Group APT repository?
# More information: https://wiki.postgresql.org/wiki/Apt
postgresql__upstream: False
# ]]]
# .. envvar:: postgresql__upstream_key_id [[[
#
# The GPG fingerprint of the upstream APT repository key.
postgresql__upstream_key_id: 'B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8'
# ]]]
# ]]]
# pg_wrapper integration [[[
# --------------------------
# .. envvar:: postgresql__default_database [[[
#
# Name of the database the users should connect to, set as default in
# :file:`/etc/postgresql-common/user_clusters`. If the name is ``*``,
users will
# connect to the database with the same name as their login.
postgresql__default_database: '*'
# ]]]
# ]]]
# ]]]
--
Regards
Hartmut Goebel
| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Folding yaml by markers
2019-10-11 14:41 Folding yaml by markers Hartmut Goebel
@ 2019-10-14 13:02 ` Robert Pluim
2019-10-16 20:33 ` Hartmut Goebel
0 siblings, 1 reply; 3+ messages in thread
From: Robert Pluim @ 2019-10-14 13:02 UTC (permalink / raw)
To: Hartmut Goebel; +Cc: help-gnu-emacs
>>>>> On Fri, 11 Oct 2019 16:41:07 +0200, Hartmut Goebel <h.goebel@crazy-compilers.com> said:
Hartmut> Hello,
Hartmut> I have to deal with some YAML documents, which use some kind of
Hartmut> "literate programming": The comments contain documentation for the
Hartmut> values. These files already contain fold markers `[[[` and `]]]`
Hartmut> provided by the mainterner (who uses vim).
Hartmut> I want to leverage these fold markers for emacs, by adjusting
Hartmut> hs-special-modes-alist, but did not manage. The blocks are folded by
Hartmut> yaml-structure, not by fold marks.
Hartmut> Any idea how do I need to set hs-special-modes-alist?
Hartmut> Here is my code:
Hartmut> (defvar hs-special-modes-alist
Hartmut> (mapcar 'purecopy
Hartmut> '((yaml-mode "[[[" "#\s+]]]" nil))))
You probably want to use 'setq' rather than 'defvar'.
Robert
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Folding yaml by markers
2019-10-14 13:02 ` Robert Pluim
@ 2019-10-16 20:33 ` Hartmut Goebel
0 siblings, 0 replies; 3+ messages in thread
From: Hartmut Goebel @ 2019-10-16 20:33 UTC (permalink / raw)
To: Robert Pluim; +Cc: help-gnu-emacs
Am 14.10.19 um 15:02 schrieb Robert Pluim:
> Hartmut> (defvar hs-special-modes-alist
> Hartmut> (mapcar 'purecopy
> Hartmut> '((yaml-mode "[[[" "#\s+]]]" nil))))
>
> You probably want to use 'setq' rather than 'defvar'.
Thanks for pointing to this. Anway this does not seem to be the relevant
issue. I (being an elisp newbie) learned about M-: and added the value
manually. Now I'm one step further: Using
(add-to-list 'hs-special-modes-alist '(yaml-mode "\\[\\[\\[" "\\]\\]\\]"
"xxxx" nil nil))
I was able to add an appropriate entry to hs-special-modes-alist.
Using this expression, I was able to make hs-minor-mode fold, BUT ONLY
if the brackets are not part of a yaml comment. Which makes me curious!
If I understand the code (line 672 in hideshow.el) correctly,
`hs-c-start-regex` is st ot the 3rd paramater ("xxxx"), which is
documented to be a regex for starting a comment. Thus "xxxx" should
defacto disable comment detection. Yet comments are still considered.
Any hints on this?
The documentation for hs-special-modes-alist is at
<https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/hideshow.el#n268>
and the relevant function `|hs-grok-mode-type`|||at
<https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/hideshow.el#n654>.
--
Regards
Hartmut Goebel
| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-16 20:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-11 14:41 Folding yaml by markers Hartmut Goebel
2019-10-14 13:02 ` Robert Pluim
2019-10-16 20:33 ` Hartmut Goebel
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.