[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 3ffb27a833 3/3: Clip org targets to narrowed por
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 3ffb27a833 3/3: Clip org targets to narrowed portion of buffer |
Date: |
Tue, 21 Mar 2023 10:57:59 -0400 (EDT) |
branch: externals/embark
commit 3ffb27a833d326ccf7e375bb9d94ebf4dc37fa77
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Clip org targets to narrowed portion of buffer
The bounds returned by org-element-context give the full org element,
ignoring any narrowing. This caused an error getting the target string
with buffer-substring.
I now clip the org element bounds to the narrowed portion of the
buffer. For actions that are org commands, this will make no
difference since they do whatever they do, we don't pass them the
embark bounds or the embark target string. For actions ike saving on
the kill-ring, it'll be less confusing if the target and bounds
correspond to what is visible in the narrowed buffer.
This fixes #614.
---
embark-org.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/embark-org.el b/embark-org.el
index 0636dbee35..6a579f6d0d 100644
--- a/embark-org.el
+++ b/embark-org.el
@@ -104,8 +104,9 @@
for elt = (org-element-lineage (org-element-context) embark-org--types t)
then (org-element-lineage elt embark-org--types)
while elt
- for begin = (org-element-property :begin elt)
- for end = (org-element-property :end elt)
+ ;; clip bounds to narrowed portion of buffer
+ for begin = (max (org-element-property :begin elt) (point-min))
+ for end = (min (org-element-property :end elt) (point-max))
for target = (buffer-substring begin end)
;; Adjust table-cell to exclude final |. (Why is that there?)
;; Note: We are not doing this is an embark transformer because we