[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/focus 2086fee8fc 1/2: Add special support for org mode
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/focus 2086fee8fc 1/2: Add special support for org mode |
Date: |
Sat, 10 Sep 2022 08:58:45 -0400 (EDT) |
branch: elpa/focus
commit 2086fee8fc6718a3ed5f68cd5e758aa05da1a9c2
Author: Lars Tveito <larstvei@ifi.uio.no>
Commit: larstvei <larstvei@ifi.uio.no>
Add special support for org mode
---
focus.el | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/focus.el b/focus.el
index a3667d5d75..48cb008dda 100644
--- a/focus.el
+++ b/focus.el
@@ -38,7 +38,9 @@
:group 'font-lock
:prefix "focus-")
-(defcustom focus-mode-to-thing '((prog-mode . defun) (text-mode . sentence))
+(defcustom focus-mode-to-thing '((prog-mode . defun)
+ (text-mode . paragraph)
+ (org-mode . org-element))
"An associated list between mode and thing.
A thing is defined in thingatpt.el; the thing determines the
@@ -101,7 +103,13 @@ The timer calls `focus-read-only-hide-cursor' after
(defun focus-bounds ()
"Return the current bounds, based on `focus-get-thing'."
- (bounds-of-thing-at-point (focus-get-thing)))
+ (let ((thing (focus-get-thing)))
+ (cond ((eq thing 'org-element)
+ (let* ((elem (org-element-at-point))
+ (beg (org-element-property :begin (org-element-at-point)))
+ (end (org-element-property :end (org-element-at-point))))
+ (cons beg end)))
+ (t (bounds-of-thing-at-point (focus-get-thing))))))
(defun focus-move-focus ()
"Move the focused section according to `focus-bounds'.
@@ -165,7 +173,7 @@ according to major-mode. If `focus-current-thing' is set,
this
default is overwritten. This function simply helps set the
`focus-current-thing'."
(interactive)
- (let* ((candidates '(defun line list paragraph sentence sexp symbol word))
+ (let* ((candidates '(defun line list org-element paragraph sentence sexp
symbol word))
(thing (completing-read "Thing: " candidates)))
(setq focus-current-thing (intern thing))))