mirror of
https://github.com/vale981/ement.el
synced 2025-03-05 09:21:37 -05:00
Tidy: Blocks
This commit is contained in:
parent
4df31c910b
commit
e6f3ba5ad3
2 changed files with 519 additions and 514 deletions
25
README.org
25
README.org
|
@ -13,21 +13,26 @@ Then various cleanups were done, some of which are included below:
|
||||||
|
|
||||||
** Change JSON example blocks to source blocks
|
** Change JSON example blocks to source blocks
|
||||||
|
|
||||||
|
This also changes the type of blocks that are HTTP request examples which appear to contain JSON.
|
||||||
|
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
(let ((reporter (make-progress-reporter "Changing block types" 0 (buffer-size))))
|
(let ((reporter (make-progress-reporter "Changing block types" 0 (buffer-size))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward (rx bol "#+BEGIN_" (group "EXAMPLE") (0+ blank) eol) nil t)
|
(while (re-search-forward (rx bol "#+BEGIN_" (group "EXAMPLE") (0+ blank) eol) nil t)
|
||||||
(goto-char (match-end 0))
|
(save-restriction
|
||||||
(forward-line 1)
|
(org-narrow-to-block)
|
||||||
(when (save-match-data
|
(goto-char (match-end 0))
|
||||||
(re-search-forward (rx (0+ blank) "{") (point-at-eol) t))
|
(forward-line 1)
|
||||||
;; Appears to be a JSON block.
|
(when (save-match-data
|
||||||
(goto-char (match-end 1))
|
(or (re-search-forward (rx (0+ blank) "{") (point-at-eol) t)
|
||||||
(replace-match "SRC" t t nil 1)
|
(re-search-forward (rx bol (0+ blank) "}" (0+ blank) "\n" "#+END") nil t)))
|
||||||
(insert " json")
|
;; Appears to be a JSON block.
|
||||||
(re-search-forward (rx bol "#+END_" (group "EXAMPLE") (0+ blank) eol) nil)
|
(goto-char (match-end 1))
|
||||||
(replace-match "SRC" t t nil 1))
|
(replace-match "SRC" t t nil 1)
|
||||||
|
(insert " json")
|
||||||
|
(re-search-forward (rx bol "#+END_" (group "EXAMPLE") (0+ blank) eol) nil)
|
||||||
|
(replace-match "SRC" t t nil 1)))
|
||||||
(progress-reporter-update reporter (point)))))
|
(progress-reporter-update reporter (point)))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue