4 ms·
I switched from VSCode to Doom Emacs a couple of months ago. I've been using ChatGPT (GPT-4) to help me write config (~1,000 lines of elisp code so far) and it
by Pr0ject217 3y ago
I switched from VSCode to Doom Emacs a couple of months ago.
I've been using ChatGPT (GPT-4) to help me write config (~1,000 lines of elisp code so far) and it's been very interesting/fun. I'm not going back.
- bachback 3y agovery cool can you share more?
- Pr0ject217 3y agoMy process is kind of organic. I'll start working on a project, and if I run into something that feels wrong about the Doom Emacs default config/keybindings, I'll just open up a conversation with ChatGPT (the GPT-4 model, it's much better than 3.5). I'll tell it that I'm using Doom Emacs, and then explain what I want, or what problem I'm having, and it will output code that I can try. It's not always correct on the first try, and sometimes I have to have a dialogue with it for a little while before it gets it right. Sometimes it struggles and begins to guess - and for those cases, I'll fall back to doing manual searches in Google, and if that fails, give up entirely and just write myself a TODO comment and keep marching forward. It's help me set up config quickly that would've taken me a very long time to figure out.
- BeetleB 3y agoThat's interesting. I've asked Bing Chat and ChatGPT several times to write me elisp code, and not once did it work well. It often invents APIs.
- ParetoOptimal 3y agoHm, I've had luck with openai gpt4. I've had it make fake APIs before, but usually when I say "fooFakeApi doesn't exist" it corrects itself.
- pmoriarty 3y agoBut how well does it do on elisp?
- BeetleB 3y agoWhen I've informed it of fake APIs, it apologizes, and replaces it with another fake API.
- ParetoOptimal 3y agoYes. It gave me quite a lot of trouble when I asked it to replace "cut -d:" with pure elisp. Eventually after a few minutes I got it to work, but during real work I probably would have just written it myself if something so simple didn't work the first time I asked. Here's the log: ChatGPT> Replace the cut shell command with a pure elisp implementation in this code: (let* ((group-command "cut -d: -f1 /etc/group") ; command to list the groups (group-data (with-temp-buffer (shell-command group-command (current-buffer)) (sort (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n") #'string<)))) (message "Selected group: %s" (completing-read "Choose a group: " group-data nil t))) <shell-maker-end-of-prompt> (let* ((group-command "cut -d: -f1 /etc/group") ; command to list the groups (group-data (sort (split-string (with-output-to-string (call-process-shell-command group-command nil standard-output)) "\n") #'string<))) (message "Selected group: %s" (completing-read "Choose a group: " group-data nil t))) ChatGPT> replace group-command with and call-process-shell-command with elisp that does the same <shell-maker-end-of-prompt> (setq group-command "cut -d: -f1 /etc/group") (setq group-data (sort (split-string (shell-command-to-string group-command) "\n") #'string<)) (message "Selected group: %s" (completing-read "Choose a group: " group-data nil t))) ChatGPT> What is the elisp equivalent of: cut -d: -f1 /etc/group <shell-maker-end-of-prompt> The equivalent Elisp code for `cut -d: -f1 /etc/group` is: (concat (nth 0 (split-string (with-temp-buffer (insert-file-contents "/etc/group") (buffer-string)) "\n")) ":") ChatGPT> Give me elisp I can evaluate to check that the elisp you gave is equal to the cut call <shell-maker-end-of-prompt> You can evaluate the following Elisp code to check that the Elisp I provided is equal to the `cut` call: (equal (concat (nth 0 (split-string (with-temp-buffer (insert-file-contents "/etc/group") (buffer-string)) "\n")) ":") (shell-command-to-string "cut -d: -f1 /etc/group")) ChatGPT> It's not equal. the cut shell command gave a list of results. The elisp you gave only gives one result <shell-maker-end-of-prompt> I apologize for the confusion. You're right, the Elisp code I provided only returns the first entry in `/etc/group`. Here's the updated code to get all group names from `/etc/group` file separated by a newline: (with-temp-buffer (insert-file-contents "/etc/group") (let ((groups (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))) (mapconcat #'(lambda (group) (car (split-string group ":"))) groups "\n"))) When you evaluate this Elisp code, it will return all the group names separated by a newline character, as the `cut -d: -f1 /etc/group` command would. ChatGPT> Give me elisp to check the equality of it <shell-maker-end-of-prompt> You can use the following Elisp code to check the equality of the two commands: (equal (with-temp-buffer (insert-file-contents "/etc/group") (let ((groups (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))) (mapconcat #'(lambda (group) (car (split-string group ":"))) groups "\n"))) (shell-command-to-string "cut -d: -f1 /etc/group"))
- newtwilly 3y agoI recently had GPT 3.5 write me a function for translating the number under point to an ISO timestamp. It handled whether the epoch number was milliseconds or seconds since epoch. I kinda had to iterate on it and ask it to do some things different, but it never wrote invalid code.