-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpen-core.el
36 lines (26 loc) · 1.07 KB
/
pen-core.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;; These are helper functions
;; examplary.el uses them.
;; So might org-brain
(defun pen-preceding-text ()
(str (buffer-substring (point) (max 1 (- (point) 1000)))))
;; TODO Figure out how to get the previous line start of line points
;; (tv (save-excursion (ntimes 5 (call-interactively 'previous-line)) (message (str (point)))))
(defun get-point-start-of-nth-previous-line (n)
(save-excursion
(eval `(expand-macro (ntimes ,n (ignore-errors (previous-line)))))
(beginning-of-line)
(point)))
(defun get-point-start-of-nth-next-line (n)
(save-excursion
(eval `(expand-macro (ntimes ,n (ignore-errors (next-line)))))
(beginning-of-line)
(point)))
(defun pen-surrounding-text (&optional window-line-size)
(if (not window-line-size)
(setq window-line-size 20))
(let ((window-line-radius (/ window-line-size 2)))
(str (buffer-substring (- (point)
(get-point-start-of-nth-previous-line window-line-radius)
10) (max 1 (- (point) 1000))))))
(ntimes 5 (message "hi"))
(provide 'pen-core)