fix(org): toggle image when point before first heading
This commit is contained in:
parent
53504c55b9
commit
008b080b45
1 changed files with 13 additions and 10 deletions
|
@ -5,16 +5,16 @@
|
||||||
|
|
||||||
(defun +org--toggle-inline-images-in-subtree (&optional beg end refresh)
|
(defun +org--toggle-inline-images-in-subtree (&optional beg end refresh)
|
||||||
"Refresh inline image previews in the current heading/tree."
|
"Refresh inline image previews in the current heading/tree."
|
||||||
(let ((beg (or beg
|
(let* ((beg (or beg
|
||||||
(if (org-before-first-heading-p)
|
(if (org-before-first-heading-p)
|
||||||
(line-beginning-position)
|
(save-excursion (point-min))
|
||||||
(save-excursion (org-back-to-heading) (point)))))
|
(save-excursion (org-back-to-heading) (point)))))
|
||||||
(end (or end
|
(end (or end
|
||||||
(if (org-before-first-heading-p)
|
(if (org-before-first-heading-p)
|
||||||
(line-end-position)
|
(save-excursion (org-next-visible-heading 1) (point))
|
||||||
(save-excursion (org-end-of-subtree) (point)))))
|
(save-excursion (org-end-of-subtree) (point)))))
|
||||||
(overlays (cl-remove-if-not (lambda (ov) (overlay-get ov 'org-image-overlay))
|
(overlays (cl-remove-if-not (lambda (ov) (overlay-get ov 'org-image-overlay))
|
||||||
(ignore-errors (overlays-in beg end)))))
|
(ignore-errors (overlays-in beg end)))))
|
||||||
(dolist (ov overlays nil)
|
(dolist (ov overlays nil)
|
||||||
(delete-overlay ov)
|
(delete-overlay ov)
|
||||||
(setq org-inline-image-overlays (delete ov org-inline-image-overlays)))
|
(setq org-inline-image-overlays (delete ov org-inline-image-overlays)))
|
||||||
|
@ -243,6 +243,9 @@ If on a:
|
||||||
(org-element-property :end lineage))
|
(org-element-property :end lineage))
|
||||||
(org-open-at-point arg))))
|
(org-open-at-point arg))))
|
||||||
|
|
||||||
|
(`paragraph
|
||||||
|
(+org--toggle-inline-images-in-subtree))
|
||||||
|
|
||||||
((guard (org-element-property :checkbox (org-element-lineage context '(item) t)))
|
((guard (org-element-property :checkbox (org-element-lineage context '(item) t)))
|
||||||
(let ((match (and (org-at-item-checkbox-p) (match-string 1))))
|
(let ((match (and (org-at-item-checkbox-p) (match-string 1))))
|
||||||
(org-toggle-checkbox (if (equal match "[ ]") '(16)))))
|
(org-toggle-checkbox (if (equal match "[ ]") '(16)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue