Subject: bug#19812: 24.4; suggest `shell-mode' not interactive

From: Juri Linkov <[email-masked]>
Date: Wed, 28 Aug 2019 01:13:25 +0300

> If I read the comments correctly, nobody had a use case for using `M-x
> shell-mode'.  It was proposed that it could possibly be useful for
> working in log files and the like, but that shell-mode doesn't currently
> actually support that, so I went ahead and applied the patch to disable
> the interactive use of the mode.

I confirm that `M-x shell-mode' can't be used in saved log files.  I tried:

  (defvar shell-log-font-lock-keywords
    ;; `shell-prompt-pattern' can't be used: it finds too many false matches
    '(("^\\([^#$%>\12]*@[^#$%>\12]*:[^#$%>\12]*[#$%>] *\\)\\(.*\\)$"
       (1 'comint-highlight-prompt)
       (2 'comint-highlight-input)))
    "Shell prompts to highlight in Shell Log mode.")

  (define-derived-mode shell-log-mode shell-mode "Shell-Log"
    "Font-lock for shell logs."
    (put 'shell-log-mode 'mode-class nil)
    (setq-local font-lock-defaults '(shell-log-font-lock-keywords t)))

  (add-to-list 'auto-mode-alist '("\\.log\\'" . shell-log-mode))

but `shell-prompt-pattern' matches too many false positives, and
replacing it with a customized regexp is too ad-hoc and unreliable.