Summary

I begin the porting of the glossary system to Pen.el. I feel like it’s an important learning tool to be able to construct glossaries while working with LMs.

The glossary is also important for helping the user to create context that enable prompt functions to be more precise.

Once a user develops their glossary to a degree, Pen.el will be able to recognise the context for which you are working within and be more accurate with its queries.

This will result in more accurate, relevant and tailored results from LMs.

Progress

So far, the glossary system will help you to automatically generate glossaries with NLG and save to your ~/.pen directory.

The next stage is to include the button overlay so you may see at a glance while working what you have already learned and committed to the glossary.

Demo

Code

Code
http://github.com/semiosis/pen.el/blob/master/src/pen-glossary.el
Code (to be completed)
http://github.com/semiosis/pen.el/blob/master/src/pen-glossary-new.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
(defun pen-add-to-glossary (term &optional take-first definition)
  "C-u will allow you to add to any glossary file"
  (interactive (let ((s (pen-thing-at-point-ask)))
                 (if (not (sor s))
                     (setq s (read-string-hist "glossary term to add: ")))
                 (list s)))
  (deactivate-mark)
  (if (not definition)
      (setq definition (lm-define term t (pen-topic t))))

  (let* ((cb (current-buffer))
         (all-glossaries-fp (pen-mnm (pen-list2str (pen-list-glossary-files))))
         (fp
          (if (pen-is-glossary-file)
              (buffer-file-name)
            (pen-umn (or
                      (and (or (>= (prefix-numeric-value current-prefix-arg) 4)
                               (not (local-variable-p 'glossary-files)))
                           (pen-umn (fz all-glossaries-fp
                                        nil nil "glossary to add to: ")))
                      (and
                       (local-variable-p 'glossary-files)
                       (if take-first
                           (car glossary-files)
                         (pen-umn (fz (pen-mnm (pen-list2str glossary-files))
                                      "$HOME/glossaries/"
                                      nil "glossary to add to: "))))
                      (pen-umn (fz (pen-mnm (pen-list2str (list "$HOME/glossaries/glossary.txt")))
                                   "$HOME/glossaries/"
                                   nil "glossary to add to: ")))))))
    (with-current-buffer
        (find-file fp)
      (progn
        (if (save-excursion
              (beginning-of-line)
              (looking-at-p (concat "^" (pen-unregexify term) "$")))
            (progn
              (end-of-line))
          (progn
            (end-of-buffer)
            (newline)
            (newline)
            (insert term)))
        (newline)
        (if (sor definition)
            (insert (pen-pretty-paragraph (concat "    " definition)))
          (insert "    ")))
      (current-buffer))))