Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syohex/emacs-libyaml
libyaml binding of Emacs Lisp
https://github.com/syohex/emacs-libyaml
Last synced: about 2 months ago
JSON representation
libyaml binding of Emacs Lisp
- Host: GitHub
- URL: https://github.com/syohex/emacs-libyaml
- Owner: syohex
- License: gpl-3.0
- Created: 2016-02-03T16:29:07.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-11T11:41:08.000Z (over 1 year ago)
- Last Synced: 2024-10-27T23:23:25.426Z (2 months ago)
- Language: C
- Homepage:
- Size: 26.4 KB
- Stars: 27
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# libyaml.el
[libyaml](https://github.com/yaml/libyaml) binding for Emacs Lisp.
## Requirements
- Emacs 25 or higher(configured with `--with-modules`)
- libyaml## Interfaces
#### `(yaml-read-from-string string)`
Parse `string` and return Emacs Lisp objects.
#### `(yaml-read-file file)`
Read YAML file and return Emacs Lisp objects.
#### `(yaml-dump obj)`
Dump Emacs Lisp object to YAML string.
## Conversion Rule
| YAML | Emacs Lisp |
|:-------------------------|:-------------|
| 123 | integer |
| 123.4 | float |
| "123" | string |
| t, On, Yes, TRUE | t : symbol |
| n, No, Off, False | nil : symbol |
| - aaa
- bbb | vector |
| name: Foo
year: 19 | hash-table |## Examples
Example
```elisp
(let ((hash (make-hash-table)))
(puthash 'a 12 hash)
(puthash 'b 12 hash)
(yaml-dump hash))
``````
---
a: 12
b: 12
...
```Example
```elisp
(let (hash
(hash-1 (make-hash-table))
(hash-2 (make-hash-table)))
(puthash 'a 12 hash-1)
(puthash 'b 12 hash-1)
(puthash 'a 12 hash-2)
(puthash 'b 12 hash-2)
(setq hash `[,hash-1 ,hash-2])
(yaml-dump hash))
``````
---
- a: 12
b: 12
- a: 12
b: 12
...
```