-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcc-emacs-lisp-mode.el
145 lines (115 loc) · 4.7 KB
/
cc-emacs-lisp-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
;;; cc-emacs-lisp-mode.el --- Elisp Customization -*- lexical-binding: t; -*-
;; Copyright (C) 2023-2024 Charles Choi
;; Author: Charles Choi <[email protected]>
;; Keywords: tools
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
(require 'elisp-mode)
(require 'paredit)
(require 'flycheck)
(require 'edebug)
(require 'cclisp)
;;; Code:
(add-hook 'emacs-lisp-mode #'enable-paredit-mode)
(add-hook 'emacs-lisp-mode #'flycheck-mode)
(keymap-set emacs-lisp-mode-map "M-[" #'backward-sexp)
(keymap-set emacs-lisp-mode-map "M-]" #'forward-sexp)
(keymap-set emacs-lisp-mode-map "<f6>" #'cc/describe-function-point-is-in)
(keymap-set emacs-lisp-mode-map "M-j" #'fill-paragraph)
(keymap-set emacs-lisp-mode-map "M-n" #'cc/browse-forward-sexp)
(keymap-set emacs-lisp-mode-map "M-p" #'cc/browse-backward-sexp)
(transient-define-prefix cc/edebug-tmenu ()
["Debug"
:class transient-row
:if edebug-mode-p
("h" "here" edebug-goto-here :transient nil)
("f" "→" edebug-forward-sexp :transient nil)
("i" "→(" edebug-step-in :transient nil)
("o" "→)" edebug-step-out :transient nil)
("e" "❯…" edebug-eval-expression)
("r" "∴" edebug-previous-result :transient nil)
("d" "≣" edebug-pop-to-backtrace :transient nil)]
["Actions"
:class transient-row
("I" "🔬 Instrument" cc/instrument-function :transient nil)
("R" "▶️ Run" eval-defun :transient nil)
("E" "🔎 Watch List" edebug-visit-eval-list :if edebug-mode-p)
("S" "🛑 Stop" edebug-stop :transient nil)]
["Navigate"
:class transient-row
("C-b" "←" backward-char :transient t)
("C-f" "→" forward-char :transient t)
("C-p" "↑" previous-line :transient t)
("C-n" "↓" next-line :transient t)
("M-[" "(←" backward-sexp :transient t)
("M-]" "→)" forward-sexp :transient t)]
[["Modes"
:description (lambda () (format "Modes (now %s)" edebug-initial-mode))
:pad-keys t
("SPC" "Step" edebug-step-mode :transient nil)
("g" "Go" edebug-go-mode :transient nil)
("n" "Next" edebug-next-mode :transient nil)
("c" "Continue" edebug-continue-mode :transient nil)
("t" "Trace" edebug-trace-mode :transient nil)
("T" "Trace Fast" edebug-Trace-fast-mode :transient nil)
("G" "Go Nonstop" edebug-Go-nonstop-mode :transient nil)
("m" "Set Mode…" edebug-set-initial-mode :transient t)]
["Breakpoint"
:pad-keys t
("s" "Set" edebug-set-breakpoint :transient t)
("u" "Unset" edebug-unset-breakpoint :transient t)
("U" "Unset All" edebug-unset-breakpoints :transient t)
("D" "Disable" edebug-toggle-disable-breakpoint :transient t)
("x" "Set Conditional…" edebug-set-conditional-breakpoint :transient nil)
("B" "Move to next" edebug-next-breakpoint :transient t)]
["Control"
:pad-keys t
:if edebug-mode-p
("a" "Abort One Level" abort-recursive-edit :transient nil)
("q" "Quit Edebug" top-level :transient nil)
("Q" "Quit Edebug Nonstop" edebug-top-level-nonstop :transient nil)]
["Views"
:pad-keys t
:if edebug-mode-p
("v" "View" edebug-view-outside)
("p" "Bounce Point" edebug-bounce-point)
("w" "Where" edebug-where)]]
[:class transient-row
("C-i" "Info" cc/open-edebug-info)
("C-g" "Dismiss" ignore :transient transient-quit-one)])
(defun edebug-mode-p ()
(if edebug-mode t
nil))
(defun cc/open-edebug-info ()
(interactive)
(other-frame-prefix)
(info "(elisp) Edebug"))
(defun cc/instrument-function ()
(interactive)
(setq current-prefix-arg '(4))
(call-interactively #'eval-defun))
;;(keymap-set edebug-mode-map "C-<f9>" #'cc/edebug-tmenu)
(keymap-set emacs-lisp-mode-map "<f8>" #'cc/edebug-tmenu)
(transient-define-prefix cc/edebug-watch-tmenu ()
[["Expression"
("a" "Add" edebug-update-eval-list)
("d" "Delete" edebug-delete-eval-item)]
["Eval"
("l" "Last" edebug-eval-last-sexp)
("p" "Print" edebug-eval-print-last-sexp)]
[""
("w" "Resume debug" edebug-where)]]
[("C-g" "Dismiss" ignore :transient transient-quit-one)])
(keymap-set edebug-eval-mode-map "<f8>" #'cc/edebug-watch-tmenu)
(provide 'cc-emacs-lisp-mode)
;;; cc-emacs-lisp-mode.el ends here