Improve org-mode support

This commit is contained in:
Lars Tveito 2020-03-08 20:08:39 +01:00
parent 28b7662f26
commit 6f7fbd3513

View File

@ -116,16 +116,20 @@ The timer calls `focus-read-only-hide-cursor' after
(apply #'derived-mode-p modes)))) (apply #'derived-mode-p modes))))
(if mode (cdr (assoc mode focus-mode-to-thing)) 'sentence)))) (if mode (cdr (assoc mode focus-mode-to-thing)) 'sentence))))
(defun focus-org-element-bounds ()
"Extract bounds from `org-element-at-point'"
(let* ((elem (org-element-at-point))
(beg (org-element-property :begin elem))
(end (org-element-property :end elem)))
(and beg end (cons beg end))))
(put 'org-element 'bounds-of-thing-at-point
#'focus-org-element-bounds)
(defun focus-bounds () (defun focus-bounds ()
"Return the current bounds, based on `focus-get-thing'." "Return the current bounds, based on `focus-get-thing'."
(or focus-pin-bounds (or focus-pin-bounds
(let ((thing (focus-get-thing))) (bounds-of-thing-at-point (focus-get-thing))))
(cond ((eq thing 'org-element)
(let* ((elem (org-element-at-point))
(beg (org-element-property :begin elem))
(end (org-element-property :end elem)))
(and beg end (cons beg end))))
(t (bounds-of-thing-at-point thing))))))
(defun focus-window-bounds () (defun focus-window-bounds ()
(cons (window-start) (window-end nil t))) (cons (window-start) (window-end nil t)))