(keymap-set shell-mode-map "SPC" #'comint-magic-space))
#+end_src
+** Save logs of =comint= buffers :cmd:kbd:
+:PROPERTIES:
+:CUSTOM_ID: comint-log-buffer
+:CreatedAt: <2022-07-13 Wed>
+:CapturedAt:
+:CapturedAs: Emacs configuration fragment
+:END:
+
+#+begin_src emacs-lisp
+ (defvar esy/logs-directory "~/logs"
+ "Directory where some log files will be saved.")
+
+ (defvar-local esy/log-buffer-filename nil
+ "File in which the current buffer is logged.")
+
+ (defun esy/log-buffer ()
+ "Save the current buffer under `esy/logs-directory'."
+ (interactive)
+ (let ((filename (or esy/log-buffer-filename
+ (setq esy/log-buffer-filename
+ (expand-file-name
+ (concat mode-name
+ "_"
+ (format-time-string
+ "%Y%m%d%H%M%S"
+ (current-time))
+ ".log")
+ esy/logs-directory)))))
+ (save-restriction
+ (widen)
+ (write-region (point-min)
+ (point-max)
+ filename))))
+
+ (with-eval-after-load 'comint
+ (keymap-set comint-mode-map "C-c C-q" #'esy/log-buffer))
+
+#+end_src
+
* Misc. settings
:PROPERTIES:
:CUSTOM_ID: misc