From 51fcac59c724fdf58f478db62dbf6f157621d598 Mon Sep 17 00:00:00 2001 From: Benjamin Levy Date: Mon, 10 May 2021 18:02:30 -0400 Subject: [PATCH] Treat trailing whitespace as outside the fragment --- org-fragtog.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/org-fragtog.el b/org-fragtog.el index 41fceba..b463926 100644 --- a/org-fragtog.el +++ b/org-fragtog.el @@ -106,9 +106,17 @@ return nil." ;; Element surrounding the cursor ((elem (org-element-context)) ;; Type of element surrounding the cursor - (elem-type (car elem)) + (elem-type (nth 0 elem)) + ;; List of fragment's properties + (elem-plist (nth 1 elem)) ;; A LaTeX fragment or environment is surrounding the cursor - (elem-is-latex (member elem-type '(latex-fragment latex-environment))) + (elem-is-latex (and (member elem-type '(latex-fragment latex-environment)) + ;; Normally org-mode considers whitespace after an + ;; element as part of the element. + ;; Avoid this behavior and consider trailing + ;; whitespace as outside the fragment. + (< (point) (- (plist-get elem-plist :end) + (plist-get elem-plist :post-blank))))) ;; Whether the fragment should be ignored (should-ignore (run-hook-with-args-until-success 'org-fragtog-ignore-predicates)))