[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/yaml-mode 67b8355 042/124: Merge pull request #21 from wen
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/yaml-mode 67b8355 042/124: Merge pull request #21 from wentasah/fill-paragraph |
Date: |
Sun, 29 Aug 2021 11:36:09 -0400 (EDT) |
branch: elpa/yaml-mode
commit 67b8355c57549ad875b82c346aceb978311a267d
Merge: 210b075 4c1127c
Author: Yoshiki Kurihara <clouder@gmail.com>
Commit: Yoshiki Kurihara <clouder@gmail.com>
Merge pull request #21 from wentasah/fill-paragraph
Improve paragraph filling of block literals
---
yaml-mode.el | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/yaml-mode.el b/yaml-mode.el
index d0c60a5..80dbdbe 100644
--- a/yaml-mode.el
+++ b/yaml-mode.el
@@ -222,6 +222,7 @@ that key is pressed to begin a block literal."
(set (make-local-variable 'comment-start-skip) "#+ *")
(set (make-local-variable 'indent-line-function) 'yaml-indent-line)
(set (make-local-variable 'indent-tabs-mode) nil)
+ (set (make-local-variable 'fill-paragraph-function) 'yaml-fill-paragraph)
(set (make-local-variable 'font-lock-defaults)
'(yaml-font-lock-keywords
nil nil nil nil
@@ -388,6 +389,46 @@ margin."
(if (and (not arg) (looking-at yaml-document-delimiter-re))
(delete-horizontal-space))))
+(defun yaml-narrow-to-block-literal ()
+ "Narrow the buffer to block literal if the point is in it,
+otherwise do nothing."
+ (interactive)
+ (save-excursion
+ (goto-char (point-at-bol))
+ (while (and (looking-at-p yaml-blank-line-re) (not (bobp)))
+ (forward-line -1))
+ (let ((nlines yaml-block-literal-search-lines)
+ (min-level (current-indentation))
+ beg)
+ (forward-line -1)
+ (while (and (/= nlines 0)
+ (/= min-level 0)
+ (not (looking-at-p yaml-block-literal-re))
+ (not (bobp)))
+ (set 'nlines (1- nlines))
+ (unless (looking-at-p yaml-blank-line-re)
+ (set 'min-level (min min-level (current-indentation))))
+ (forward-line -1))
+ (when (and (< (current-indentation) min-level)
+ (looking-at-p yaml-block-literal-re))
+ (set 'min-level (current-indentation))
+ (forward-line)
+ (setq beg (point))
+ (while (and (not (eobp))
+ (or (looking-at-p yaml-blank-line-re)
+ (> (current-indentation) min-level)))
+ (forward-line))
+ (narrow-to-region beg (point))))))
+
+(defun yaml-fill-paragraph (&optional justify region)
+ "Fill paragraph.
+This behaves as `fill-paragraph' except that filling does not
+cross boundaries of block literals."
+ (interactive "*P")
+ (save-restriction
+ (yaml-narrow-to-block-literal)
+ (let ((fill-paragraph-function nil))
+ (fill-paragraph justify region))))
(defun yaml-set-imenu-generic-expression ()
(make-local-variable 'imenu-generic-expression)
- [nongnu] elpa/yaml-mode 0aceaf3 100/124: Merge pull request #73 from tarsiiformes/typos, (continued)
- [nongnu] elpa/yaml-mode 0aceaf3 100/124: Merge pull request #73 from tarsiiformes/typos, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 9e8362d 110/124: Merge pull request #76 from dgutov/spf-speedup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 97d507f 048/124: Derive from text-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode f49fb81 123/124: Add magic-mode-list entry, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 6555018 003/124: Merged branch(TEST-MARSHALL-PATCH@17) to trunk, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4ce371e 013/124: Removed version from README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 1fa61ec 016/124: Fixed bug for tabified indent., ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b751113 021/124: Merge pull request #5 from sugyan/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode c2ac933 023/124: changed version, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b15a8ff 028/124: fix anchor name can contain '_', ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 67b8355 042/124: Merge pull request #21 from wentasah/fill-paragraph,
ELPA Syncer <=
- [nongnu] elpa/yaml-mode 2941501 043/124: Merge pull request #29 from tarsius/font-lock-ensure, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode eb46305 052/124: rename test-file, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode a96d09d 054/124: Description of behaviour updated., ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 73951dd 055/124: added test files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 3362e1b 057/124: Merge pull request #33 from antalk2/antalk2-patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 4966854 061/124: Merge pull request #36 from mmckinst/license, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode e73adce 069/124: Fix regex in autoload as well, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode c0d6da0 073/124: Merge pull request #42 from scop/spelling, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode b03fba2 074/124: Merge pull request #43 from scop/raml, ELPA Syncer, 2021/08/29
- [nongnu] elpa/yaml-mode 93252a0 076/124: Change dashes from word to symbol syntax, ELPA Syncer, 2021/08/29