Emacs - font lock
[dotfiles.git] / emacs.d / elisp / shell-command-output-mode.el
1 ;; ;;; shell-command-output-mode.el --- A major mode for shell command output buffer  -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2017  Peng Li
4
5 ;; Author: Peng Li <seudut@gmail.com>
6 ;; Keywords: 
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; Nothing
24
25 ;;; Code:
26
27 ;; (defun haha/delet-window ()
28 ;;   (interactive)
29 ;;   (quit-window t))
30
31 (defvar shell-command-output-mode-map
32   (let ((map (make-sparse-keymap)))
33     (define-key map (kbd "q") (lambda () (interactive) (quit-window t)))
34     map)
35   "Keymap used in shell-command-output-mode mode")
36
37 (defcustom shell-command-output-mode-hook nil
38   "Hook run when shell command output mode is enabled"
39   :type 'hook
40   :group 'shell-command-outut)
41
42 ;;;###autoload
43 (define-derived-mode shell-command-output-mode fundamental-mode "shell-command-output" ""
44   (use-local-map shell-command-output-mode-map)
45   (setq buffer-read-only t)
46   ;; enable evil motion state for this mode
47   (if (and (boundp evil-mode) (fboundp 'evil-motion-state))
48       (progn (add-to-list 'evil-motion-state-modes 'shell-command-output-mode)
49              (evil-motion-state)))
50   )
51
52 (provide 'shell-command-output-mode)
53 ;;; shell-command-output-mode.el ends here