s-kostyaev / elisa

ELISA (Emacs Lisp Information System Assistant) is a project designed to help Emacs users quickly find answers to their questions related to Emacs and Emacs Lisp. Utilizing the powerful Ellama package, ELISA provides accurate and relevant responses to user queries, enhancing productivity and efficiency in the Emacs environment.
GNU General Public License v3.0
37 stars 2 forks source link

info manuals default path #11

Open oatmealm opened 2 months ago

oatmealm commented 2 months ago

I think default-directory points to default directory of current buffer, rather than the real location of info manuals? In doom at least it's not picking any manuals, though I can manually parse them elisa-parse.... (elisp) etc.

https://github.com/s-kostyaev/elisa/blob/de9fa3c1a432482622e7a1aa2c02578099d10ba6/elisa.el#L235

s-kostyaev commented 2 months ago

Should be fixed in 0.1.3

s-kostyaev commented 2 months ago

@oatmealm have you tried it?

oatmealm commented 2 months ago

a quick check shows it doesn't... it seems like ...get-builtin can't find anything in the path it's searching... I understand info files are kept with the source when installed via straight or something similar?

s-kostyaev commented 2 months ago

Builtin info manuals are installed with emacs itself.

KaiHa commented 2 months ago

Hello @s-kostyaev , I would recommend utilizing the variable Info-directory-list[1], or, for a more straightforward solution, consider using the info--manual-names function, although I am unsure if it is considered bad style to use this function from outside of info.el. And please keep in mind, that the info files might have an .info.gz suffix, so filtering for *.info might also result in missed info manuals.

If you go for the info--manual-names approach it might be as easy as the below change:

 (defun elisa-parse-builtin-manuals ()
   "Parse builtin manuals."
   (mapc (lambda (s)
      (ignore-errors (elisa-parse-info-manual s)))
-   (elisa-get-builtin-manuals)))
+       (info--manual-names nil)))

[1] https://www.gnu.org/software/emacs/manual/html_node/info/Emacs-Info-Variables.html#index-Info_002ddirectory_002dlist

KaiHa commented 2 months ago
 (defun elisa-parse-builtin-manuals ()
   "Parse builtin manuals."
   (mapc (lambda (s)
    (ignore-errors (elisa-parse-info-manual s)))
- (elisa-get-builtin-manuals)))
+       (info--manual-names nil)))

Be careful, that seems not to work as expected. Most likely because async-start starts the subordinate Emacs process with -Q (minimum customization).

KaiHa commented 2 months ago

@s-kostyaev , have you thought about using make-thread instead of async-start? Something like the following seems to work with the info--manual-names change from above. You might want to put a with-mutex around the body of the thread.

 (defun elisa-async-parse-builtin-manuals ()
   "Parse builtin manuals asyncronously."
   (interactive)
   (message "Begin parsing builtin manuals.")
-  (elisa--async-do-parse 'elisa-parse-builtin-manuals))
+  (make-thread (lambda ()
+        (elisa-parse-builtin-manuals)
+        (message "elisa-parse-builtin-manuals done."))
+               "elisa-parse-thread"))

The below change seems to be also necessary:

 (defun elisa-parse-info-manual (name)
   "Parse info manual with NAME and save index to database."
   (with-temp-buffer
-    (info name (current-buffer))
+    (info-setup name (current-buffer))
     (let ((continue t))
s-kostyaev commented 1 month ago

@oatmealm please check if version 0.1.4 works for you.

s-kostyaev commented 1 month ago

@KaiHa Thank you. I think the main issue is that I filter out gzipped manuals. Let's check step by step.

About make-thread: I prefer async-start because I don't want to block emacs. With cooperative multithreading it's hard.

s-kostyaev commented 1 month ago

@oatmealm waiting your reply here. I can't reproduce error, so wait for you to check if it's fixed.

KaiHa commented 1 month ago

@s-kostyaev I ran into another pitfall. On my system the info page info-stnd contains an endless loop, after the Appendix it jumps back to chapter 12 when using Info-forward-node. I don't know if you want to cater for such broken info documents, otherwise if you don't do, some might experience that elisa-parse-*-manuals simply does not return.

oatmealm commented 1 month ago

@oatmealm waiting your reply here. I can't reproduce error, so wait for you to check if it's fixed.

It seems to be indexing, but emacs crashes again when starting a chat. I'll reproduce and send more info asap.