karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.04k stars 113 forks source link

An Emacs mode declaration at top of file causes duplicate org-mod properties #337

Closed ProjectMoon closed 2 days ago

ProjectMoon commented 3 days ago

If you follow this, to declare an org-mode buffer with gptel auto-enabled: ; ; -*- mode: org-mode; eval: (gptel-mode 1); -*- You will wind up with multiple property blocks in the file. Putting the mode declaration at the file causes gptel to write a new property block in the org file with its own settings, rather than using the org property block right below it.

Is there a workaround to have certain org-mode files automatically load gptel, while others do not? Without having to muck around with the auto mode alist, preferably.

karthink commented 3 days ago

Couldn't reproduce this. I tried:

  1. In a chat buffer, call M-x add-file-local-variable-prop-line
  2. Choose eval, type in (gptel-mode 1) or what's in the screenshot below.
  3. Save the file. Only one properties block is created, or when there's one below the header line already, it's reused.

image

karthink commented 3 days ago

Is there a workaround to have certain org-mode files automatically load gptel, while others do not? Without having to muck around with the auto mode alist, preferably.

Adding that file-local var -- or dir-local if you store your chats in one place -- is the only way right now. What do you mean by "certain org-mode files"?

ProjectMoon commented 2 days ago

OK I think the reason this happened was because I actually started my prop line with ; instead of # for org-mode.

karthink commented 2 days ago

OK I think the reason this happened was because I actually started my prop line with ; instead of # for org-mode.

I avoid writing these by hand since they're easy to mess up, hence add-file-local-variable-prop-line.