From 7e99fc220de5be30eaace4bb336b35f5be8472ba Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 13 Jul 2022 11:33:38 +0300 Subject: [PATCH] ADDED: esy/log-buffer command, bound to C-c C-q in comint-mode-map --- .emacs.d/esy.org | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.emacs.d/esy.org b/.emacs.d/esy.org index c0b6fc4..d8d9ad9 100644 --- a/.emacs.d/esy.org +++ b/.emacs.d/esy.org @@ -1683,6 +1683,45 @@ terminates, e.g. when pressing =C-d=. (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 -- 2.39.2