Skip to content

Commit 9c21ae6

Browse files
committed
Add "sent" commands to comint history
1 parent beb00b3 commit 9c21ae6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

inf-elixir.el

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Should be able to be run without any arguments."
7474

7575

7676
;;; Private functions
77+
7778
(defun inf-elixir--up-directory (dir)
7879
"Return the directory above DIR."
7980
(file-name-directory (directory-file-name dir)))
@@ -90,6 +91,13 @@ Should be able to be run without any arguments."
9091
(inf-elixir--find-umbrella-root default-directory)
9192
(locate-dominating-file default-directory "mix.exs")))
9293

94+
(defun inf-elixir--send (command)
95+
"Send COMMAND to the REPL process."
96+
(with-current-buffer inf-elixir-buffer
97+
(comint-add-to-input-history command))
98+
(comint-send-string inf-elixir-buffer command)
99+
(comint-send-string inf-elixir-buffer "\n"))
100+
93101

94102
;;; Public functions
95103

@@ -135,20 +143,17 @@ Should be able to be run without any arguments."
135143
(defun inf-elixir-send-line ()
136144
"Send the region to the REPL buffer and run it."
137145
(interactive)
138-
(comint-send-region inf-elixir-buffer (point-at-bol) (point-at-eol))
139-
(comint-send-string inf-elixir-buffer "\n"))
146+
(inf-elixir--send (buffer-substring (point-at-bol) (point-at-eol))))
140147

141148
(defun inf-elixir-send-region ()
142149
"Send the region to the REPL buffer and run it."
143150
(interactive)
144-
(comint-send-region inf-elixir-buffer (point) (mark))
145-
(comint-send-string inf-elixir-buffer "\n"))
151+
(inf-elixir--send (buffer-substring (point) (mark))))
146152

147153
(defun inf-elixir-send-buffer ()
148154
"Send the buffer to the REPL buffer and run it."
149155
(interactive)
150-
(comint-send-region inf-elixir-buffer 1 (point-max))
151-
(comint-send-string inf-elixir-buffer "\n"))
156+
(inf-elixir--send (buffer-string)))
152157

153158
(provide 'inf-elixir)
154159

0 commit comments

Comments
 (0)