[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 5f5b005357 2/2: Target all nested org elements
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 5f5b005357 2/2: Target all nested org elements |
Date: |
Tue, 27 Dec 2022 10:57:37 -0500 (EST) |
branch: externals/embark
commit 5f5b0053570111252298b0ea5758cb52fb1180fe
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Target all nested org elements
This removes the need for a separate whole-table target finder.
---
embark-org.el | 46 +++++++++++++++++++---------------------------
1 file changed, 19 insertions(+), 27 deletions(-)
diff --git a/embark-org.el b/embark-org.el
index 534851eccc..65446c644b 100644
--- a/embark-org.el
+++ b/embark-org.el
@@ -93,7 +93,7 @@
;; strike-through
;; subscript
;; superscript
- ;; table ; supported via a specific target finder
+ table ; supported via a specific target finder
table-cell
;; table-row ; we'll put row & column actions in the cell map
;; target ; I think there are no useful actions for radio targets
@@ -105,22 +105,24 @@
"Supported Org object and element types.")
(defun embark-org-target-element-context ()
- "Target the smallest Org element or object around point."
- (when-let (((derived-mode-p 'org-mode 'org-agenda-mode))
- (element (org-element-context))
- ((memq (car element) embark-org--types))
- (begin (org-element-property :begin element))
- (end (org-element-property :end element))
- (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
- ;; want to adjust the bounds too.
- ;; TODO? If more adjustments like this become necessary, add a
- ;; nice mechanism for doing them.
- (when (and (eq (car element) 'table-cell) (string-suffix-p "|" target))
- (setq target (string-trim (string-remove-suffix "|" target))
- end (1- end)))
- `(,(intern (format "org-%s" (car element))) ,target ,begin . ,end)))
+ "Target all Org elements or objects around point."
+ (when (derived-mode-p 'org-mode 'org-agenda-mode)
+ (cl-loop
+ 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)
+ 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
+ ;; want to adjust the bounds too.
+ ;; TODO? If more adjustments like this become necessary, add a
+ ;; nice mechanism for doing them.
+ when (and (eq (car elt) 'table-cell) (string-suffix-p "|" target))
+ do (setq target (string-trim (string-remove-suffix "|" target))
+ end (1- end))
+ collect `(,(intern (format "org-%s" (car elt))) ,target ,begin . ,end))))
(add-to-list 'embark-target-finders 'embark-org-target-element-context)
@@ -145,13 +147,6 @@
;;; Tables
-(defun embark-org-target-table ()
- "Target entire Org table at point."
- (when (and (derived-mode-p 'org-mode) (org-at-table-p))
- `(org-table
- ,(buffer-substring (org-table-begin) (org-table-end))
- . (,(org-table-begin) . ,(org-table-end)))))
-
(dolist (motion '(org-table-move-cell-up org-table-move-cell-down
org-table-move-cell-left org-table-move-cell-right))
(add-to-list 'embark-repeat-actions motion))
@@ -186,9 +181,6 @@
(push 'embark--ignore-target ; prompts for file name
(alist-get 'org-table-export embark-target-injection-hooks))
-(push 'embark-org-target-table
- (cdr (memq 'embark-org-target-element-context embark-target-finders)))
-
(add-to-list 'embark-keymap-alist '(org-table . embark-org-table-map))
(add-to-list 'embark-keymap-alist '(org-table-cell .
embark-org-table-cell-map))