forked from mickeynp/combobulate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
combobulate-ui.el
137 lines (117 loc) · 5.45 KB
/
combobulate-ui.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
;;; combobulate-ui.el --- user interface for combobulate -*- lexical-binding: t; -*-
;; Copyright (C) 2021-23 Mickey Petersen
;; Author: Mickey Petersen <mickey at masteringemacs.org>
;; Package-Requires: ((emacs "29"))
;; Version: 0.1
;; Homepage: https://www.github.com/mickeynp/combobulate
;; Keywords: convenience, tools, languages
;; 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:
;;
;;; Code:
(require 'map)
(require 'transient)
(require 'combobulate-settings)
(transient-define-prefix combobulate-highlight ()
"Highlight nodes in the buffer"
["Highlight"
("h" "Highlight DWIM" combobulate-highlight-dwim-at-point)
("q" "Highlight query" combobulate-highlight-query)
("c" "Clear all highlights" combobulate-highlight-clear)])
(transient-define-prefix combobulate-avy ()
"Call avy on a collection of nodes around point"
["Avy"
("a" "Jump to a nearby node" combobulate-avy-jump)
("d" "Jump to a nearby defun" combobulate-avy-jump-defun)])
(transient-define-prefix combobulate-xref ()
"Find and navigate query matches with Xref"
["Xref"
("b" "Xref in buffer" combobulate-xref-find-query-buffer-references)])
(transient-define-prefix combobulate-query ()
"Querying, filtering and searching nodes"
["Query Builder"
("q" "Open query builder" combobulate-query-builder)
("p" "Build match query for node at point" combobulate-query-builder-match-node-at-point)
("r" "Build query from root node to point" combobulate-query-builder-root-to-point)])
(transient-define-prefix combobulate-edit ()
"Edit nodes with multiple cursors..."
["Edit with multiple cursors"
["DWIM at Point"
("c" "Cluster" combobulate-edit-cluster-dwim)
("t" "Node Type" combobulate-edit-node-type-dwim)
("x" "Node Text" combobulate-edit-node-by-text-dwim)]
["Query"
("q" "By Query" combobulate-edit-query)]])
(transient-define-prefix combobulate-envelop ()
"Envelop node on or around point with a template"
["Envelopes"
:setup-children
(lambda (_)
;; This is... not pretty.
(transient-parse-suffixes
transient--prefix
`[,@(mapcar (lambda (envelope)
(map-let (:key :description :function) envelope
`(,key ,description ,function)))
combobulate-manipulation-envelopes)]
)
)])
(transient-define-prefix combobulate ()
"Structured Editing and Navigation with Combobulate"
["Navigation"
["Linear / Explicit"
("M-a" "Logical prev" combobulate-navigate-logical-previous :transient t)
("M-e" "Logical next" combobulate-navigate-logical-next :transient t)
("C-M-f" "Forward sexp" forward-sexp :transient t)
("C-M-b" "Backward sexp" backward-sexp :transient t)
("a" "Avy …" combobulate-avy)]
["Hierarchical"
("C-M-u" "Up into list" combobulate-navigate-up-list-maybe :transient t)
("C-M-d" "Down into list" combobulate-navigate-down-list-maybe :transient t)
("C-M-p" "Backward sibling" combobulate-navigate-previous :transient t)
("C-M-n" "Forward sibling" combobulate-navigate-forward :transient t)]
[:description (lambda () (concat
(propertize "Defun " 'face 'transient-heading)
(format "(to: %s)"
(propertize
(symbol-name combobulate-beginning-of-defun-behavior)
'face
'font-lock-doc-face))))
("C-M-a" "Beginning of defun" combobulate-navigate-beginning-of-defun :transient t)
("C-M-e" "End of defun" combobulate-navigate-end-of-defun :transient t)]
]
["Querying"
[("B" "Query Builder …" combobulate-query)
("x" "Xref …" combobulate-xref)
("h" "Highlight …" combobulate-highlight)]
[("M-n" "Next query ring entry" combobulate-query-ring-next-query :transient t)
("M-p" "Previous query ring entry" combobulate-query-ring-previous-query :transient t)]]
["Editing and Marking"
["Marking"
("C-M-h" "Mark defun" combobulate-mark-defun :transient t)
("M-h" "Expand region" combobulate-mark-node-dwim :transient t)]
["Editing"
("M-k" "Kill node DWIM" combobulate-kill-node-dwim :transient t)
("t" "Edit …" combobulate-edit)
("c" "Clone node DWIM" combobulate-clone-node-dwim)
("C-M-t" "Transpose sexp" combobulate-transpose-sexps)
("e" "Envelop …" combobulate-envelop)]
["Experimental"
("M-<up>" "Splice up and out" combobulate-splice-up :transient t)
("M-<down>" "Splice down and out" combobulate-splice-down :transient t)
("M-<left>" "Yeet" combobulate-yeet-forward :transient t)
("M-<right>" "Yoink" combobulate-yoink-forward :transient t)
("M-P" "Drag node up" combobulate-drag-up :transient t)
("M-N" "Drag node down" combobulate-drag-down :transient t)
("v" "Vanish parent" combobulate-vanish-node)]])
(provide 'combobulate-ui)
;;; combobulate-ui.el ends here