mirror of
https://github.com/larstvei/Focus.git
synced 2024-11-26 11:38:32 +00:00
Improve org-mode support
This commit is contained in:
parent
28b7662f26
commit
6f7fbd3513
18
focus.el
18
focus.el
@ -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)))
|
||||||
|
Loading…
Reference in New Issue
Block a user