gptel icon indicating copy to clipboard operation
gptel copied to clipboard

gptel-crowdsourced-prompts-file does not use xdg.el

Open yantar92 opened this issue 1 year ago • 3 comments

It would be nice if gptel-crowdsourced-prompts-file did not hard-code using environment variables only. xdg.el library (when available) is more accurate. It is enough to call xdg-cache-home.

yantar92 avatar Feb 01 '24 12:02 yantar92

  1. Does xdg.el support Windows?
  2. I don't know if xdg.el is loaded with Emacs. I would like to avoid requiring the library just to fetch the cache directory. Is the following valid, or do you have any suggestions?

(eval-when-compile (require 'xdg))

(defcustom gptel-crowdsourced-prompts-file
  (expand-file-name "gptel-crowdsourced-prompts.csv" (xdg-cache-home))
  "File used to store crowdsourced system prompts.

These are prompts cached from an online source (see
`gptel--crowdsourced-prompts-url'), and can be set from the
transient menu interface provided by `gptel-menu'."
  :group 'gptel
  :type 'file)

karthink avatar Feb 03 '24 21:02 karthink

karthink @.***> writes:

  1. Does xdg.el support Windows?

XDG does not provide standards for Windows. AFAIU, `xdg-cache-home' will return ~/.cache on Windows.

  1. I don't know if xdg.el is loaded with Emacs. I would like to avoid requiring the library just to fetch the cache directory.

xdg.el is very lightweight. And it is generally a good idea to follow configurable standard that respect user settings rather than not.

... Is the following valid, or do you have any suggestions?


(eval-when-compile (require 'xdg))
(defcustom gptel-crowdsourced-prompts-file
  (expand-file-name "gptel-crowdsourced-prompts.csv" (xdg-cache-home))
  "File used to store crowdsourced system prompts.

Bad idea. xdg.el pulls data from environment variables, when they are defined. If you execute (xdg-cache-home) at compile time, environment variables may not be respected if the user changes them.

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

yantar92 avatar Feb 03 '24 22:02 yantar92

Bad idea. xdg.el pulls data from environment variables, when they are defined. If you execute (xdg-cache-home) at compile time, environment variables may not be respected if the user changes them.

Noted.

karthink avatar Feb 03 '24 22:02 karthink

Closing as the crowdsourced prompts features is going to be removed from gptel.

karthink avatar Jan 02 '25 01:01 karthink