-
Notifications
You must be signed in to change notification settings - Fork 54
/
combobulate-ui.el
133 lines (113 loc) · 5.51 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
;;; 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)
(require 'combobulate-setup)
(declare-function combobulate--envelope-get-function-name "combobulate-envelope")
(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-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)
("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)])
(transient-define-prefix combobulate-edit ()
"Cursor edit nodes..."
["Bulk Edit"
["DWIM at Point"
("c" "Sequence" combobulate-cursor-edit-sequence-dwim)
("t" "Node Type" combobulate-cursor-edit-node-type-dwim)
("x" "Node Text" combobulate-cursor-edit-node-by-text-dwim)
("s" "Sibling" combobulate-cursor-edit-node-siblings-dwim)]
["Query"
("q" "By Query" combobulate-cursor-edit-query)]])
(transient-define-prefix combobulate-envelop ()
"Envelop node on or around point with a template"
["Envelopes"
:class transient-column
:setup-children
(lambda (_)
;; This is... not pretty.
(transient-parse-suffixes
'something
`[,@(mapcar (lambda (envelope)
(map-let (:key :description) envelope
`(,key ,description ,(combobulate--envelope-get-function-name envelope))))
(combobulate-read envelope-list))]))])
(transient-define-prefix combobulate ()
"Structured Editing and Navigation with Combobulate"
["Navigating and Searching"
["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)
("M-p" "Previous sequent" combobulate-navigate-sequence-previous :transient t)
("M-n" "Next sequent" combobulate-navigate-sequence-next :transient t)]
["Hierarchical"
("C-M-u" "Up into list" combobulate-navigate-up :transient t)
("C-M-d" "Down into list" combobulate-navigate-down :transient t)
("C-M-p" "Backward sibling" combobulate-navigate-previous :transient t)
("C-M-n" "Forward sibling" combobulate-navigate-next :transient t)]
["Querying"
("B" "Query Builder …" combobulate-query)
("x" "Xref …" combobulate-xref)
("h" "Highlight …" combobulate-highlight)]
[: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)]]
["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)
("M-P" "Drag node up" combobulate-drag-up :transient t)
("M-N" "Drag node down" combobulate-drag-down :transient t)]
["Splicing"
("M-<up>" "Elevate before and out" combobulate-splice-up :transient t)
("M-<down>" "Elevate after and out" combobulate-splice-down :transient t)
("M-<left>" "Elevate self and out" combobulate-splice-self :transient t)
("M-<right>" "Elevate all and out" combobulate-splice-parent)]])
(provide 'combobulate-ui)
;;; combobulate-ui.el ends here