-
Notifications
You must be signed in to change notification settings - Fork 0
/
partial-recall-x.el
76 lines (58 loc) · 2.6 KB
/
partial-recall-x.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;;; partial-recall-x.el --- Extension for `partial-recall' -*- lexical-binding: t; -*-
;; Author: Krister Schuchardt <krister.schuchardt@gmail.com>
;; Homepage: https://github.com/Walheimat/partial-recall
;; Version: 0.13.1
;; Package-Requires: ((emacs "28.1"))
;;; Commentary:
;; Functionality to integrate `partial-recall' in external libraries
;; or make `partial-recall' accessible from external code.
;;; Code:
(declare-function consult--buffer-state "ext:consult.el")
(declare-function consult--buffer-query "ext:consult.el")
(require 'partial-recall)
(defcustom partial-recall-x-consult-narrow-key ?u
"Key used to narrow to `partial-recall' buffers."
:group 'partial-recall
:type 'character)
(defvar partial-recall-x-consult-buffer-source
(list :name "Partial Recall"
:hidden t
:narrow partial-recall-x-consult-narrow-key
:category 'buffer
:state #'consult--buffer-state
:history 'buffer-name-history
:require-match t
:items
#'(lambda () (consult--buffer-query :sort 'visibility
:predicate #'partial-recall--buffer-in-memory-p
:as #'buffer-name)))
"Buffers that are recalled from the current tab.")
;;;###autoload
(defun partial-recall-x-buffer-specs (&optional buffer)
"Get the BUFFER's specs.
The specs are a plist of the attributes `:meaningful', `:real'
and `:implanted'."
(interactive)
(let* ((buffer (or buffer (current-buffer)))
(specs (list :meaningful (partial-recall--meaningful-buffer-p buffer)
:real (not (null (partial-recall--buffer-in-memory-p buffer)))
:implanted (buffer-local-value 'partial-recall--permanent buffer))))
(if (called-interactively-p 'any)
(let ((partial-recall-log t))
(partial-recall-log "Buffer '%s' has specs '%s'" buffer specs))
specs)))
(defun partial-recall-x-memory-specs (&optional memory)
"Get the MEMORY's specs.
The specs are a plist of attributes `:size' and `:capacity' and
`:original-capacity'."
(interactive)
(let* ((memory (or memory (partial-recall--reality)))
(specs (list :size (ring-length (partial-recall-memory--moments memory))
:capacity (ring-size (partial-recall-memory--moments memory))
:original-capacity (partial-recall-memory--orig-size memory))))
(if (called-interactively-p 'any)
(let ((partial-recall-log t))
(partial-recall-log "Memory '%s' has specs '%s'" memory specs))
specs)))
(provide 'partial-recall-x)
;;; partial-recall-x.el ends here