-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
pen-core.el
39 lines (31 loc) · 1.08 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
37
38
39
;; These are helper functions
;; examplary.el uses them.
;; So might org-brain
(defun pen-preceding-text ()
(str (buffer-substring (point) (max 1 (- (point) 1000)))))
(defun beginning-of-line-point ()
(save-excursion
(beginning-of-line)
(point)))
(defun pen-preceding-text-line ()
(cond
(major-mode-p 'term-mode))
(str (buffer-substring (point) (max 1 (beginning-of-line-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
(get-point-start-of-nth-previous-line window-line-radius)
(get-point-start-of-nth-next-line window-line-radius)))))
(provide 'pen-core)