Handle carriage return in inf-ruby output

Added a custom function `inf-ruby-process-carriage-return` to clean up unwanted carriage returns from inf-ruby output. This function is now hooked into `comint-preoutput-filter-functions` to process output in `inf-ruby-mode`. This change ensures better handling of newline characters in the output stream.
This commit is contained in:
Jeremy Dormitzer 2024-11-14 13:56:52 -05:00
parent 1327019fdb
commit f9a67dde68

View File

@ -18,7 +18,16 @@
:commands (inf-ruby inf-ruby-console-auto) :commands (inf-ruby inf-ruby-console-auto)
:general :general
([remap inf-ruby] #'inf-ruby-console-auto) ([remap inf-ruby] #'inf-ruby-console-auto)
:hook (after-init . inf-ruby-switch-setup)) :hook (after-init . inf-ruby-switch-setup)
:config
(defun inf-ruby-process-carriage-return (output)
(let ((processed (replace-regexp-in-string ".*\r" "" output)))
(if (string-match-p "\\`\n" processed)
(replace-regexp-in-string "\\`\n" "" processed)
processed)))
(defun inf-ruby-carriage-return-hook ()
(add-hook 'comint-preoutput-filter-functions #'inf-ruby-process-carriage-return nil t))
(add-hook 'inf-ruby-mode-hook #'inf-ruby-carriage-return-hook))
(use-package rbenv (use-package rbenv
:hook (after-init . global-rbenv-mode) :hook (after-init . global-rbenv-mode)