From 554aad49b5e78a593c32e0f8a76f6a512727c814 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 30 Jun 2021 15:22:57 -0700 Subject: [PATCH] [oni-org] Only expand snippets if the key is at start of line --- oni-org/oni-org.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index 4fc97d6..fab80b2 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2021.0630.112414 +;; Version: 2021.0630.150728 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti) ;; This program is free software; you can redistribute it and/or modify @@ -108,6 +108,13 @@ installs it will always be ~." (let ((base-dir "~")) (expand-file-name file-name base-dir))) +(defun oni-org-set-yasnippet-condition () + "Change the ‘yas-buffer-local-condition’ variable to work for org. +This condition requires that the key used for the snippet is +located at the start of the line." + (setq-local yas-buffer-local-condition + '(looking-back (rx "\n" (one-or-more (not space)))))) + (defun oni-org-setup-prettify-symbols-mode () "Set up prettify symbols mode for org mode." (setq-local prettify-symbols-alist @@ -356,6 +363,7 @@ also move point to the start of the heading." (add-hook 'org-mode-hook #'oni-org-set-tag-faces) (add-hook 'org-mode-hook #'oni-org-set-todo-keyword-faces) +(add-hook 'org-mode-hook #'oni-org-set-yasnippet-condition) (add-hook 'org-mode-hook 'electric-quote-local-mode) (add-hook 'org-mode-hook 'flyspell-mode) (add-hook 'org-mode-hook 'olivetti-mode)