Add yas org snippet helper functions
and a few little similar tweaks
This commit is contained in:
parent
bc1a07af46
commit
325d1a31e3
15
config.org
15
config.org
|
@ -4541,18 +4541,29 @@ Return nil otherwise."
|
|||
(when (re-search-forward "header-args:")
|
||||
(buffer-substring-no-properties
|
||||
(point)
|
||||
(or (and (forward-word) (point))
|
||||
(or (and (forward-symbol 1) (point))
|
||||
(1+ (point))))))
|
||||
("#+begin_src"
|
||||
(buffer-substring-no-properties
|
||||
(point)
|
||||
(or (and (forward-word) (point))
|
||||
(or (and (forward-symbol 1) (point))
|
||||
(1+ (point)))))
|
||||
("#+header:"
|
||||
(search-forward "#+begin_src")
|
||||
(+yas/org-src-lang))
|
||||
(_ nil))))
|
||||
|
||||
(defun +yas/org-src-header-p ()
|
||||
(or
|
||||
(looking-back "^#\\+property:[ \t]+header-args:.*" (line-beginning-position))
|
||||
(looking-back "^#\\+header:.*" (line-beginning-position))))
|
||||
|
||||
(defun +yas/org-last-src-lang ()
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(when (search-backward "#+begin_src" nil t)
|
||||
(+yas/org-src-lang))))
|
||||
|
||||
(defun +yas/org-most-common-no-property-lang ()
|
||||
"Find the lang with the most source blocks that has no global header-args, else nil."
|
||||
(let (src-langs header-langs)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: Property - header arg
|
||||
# key: h
|
||||
# condition: (or (looking-back "#\\+PROPERTY:.*" (line-beginning-position)) ((looking-back "#\\+property:.*" (line-beginning-position))))
|
||||
# condition: (or (looking-back "^#\\+PROPERTY:.*" (line-beginning-position)) (looking-back "^#\\+property:.*" (line-beginning-position)))
|
||||
# --
|
||||
header-args:${1:`(or (+yas/org-most-common-no-property-lang) "?")`} $0
|
Loading…
Reference in New Issue