-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-delim-col-menu.el
64 lines (59 loc) · 2.4 KB
/
my-delim-col-menu.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
(defun my-delimits-column-region
(orig-fun &rest args)
(let
((delimit-columns-separator
(read-regexp
(format "%s (%s): " "Specify the regexp which separates each column" delimit-columns-separator)
(list delimit-columns-separator)))
(delimit-columns-before
(read-string
(format "%s (%s): " "Specify a string to be inserted before each column" delimit-columns-before)
nil nil delimit-columns-before))
(delimit-columns-after
(read-string
(format "%s (%s): " "Specify a string to be inserted after each column" delimit-columns-after)
nil nil delimit-columns-after))
(delimit-columns-str-separator
(read-string
(format "%s (%s): " "Specify a string to be inserted between each column" delimit-columns-str-separator)
nil nil delimit-columns-str-separator))
(delimit-columns-str-before
(read-string
(format "%s (%s): " "Specify a string to be inserted before the first column" delimit-columns-str-before)
nil nil delimit-columns-str-before))
(delimit-columns-str-after
(read-string
(format "%s (%s): " "Specify a string to be inserted after the last column" delimit-columns-str-after)
nil nil delimit-columns-str-after))
(delimit-columns-format
(let*
((choices
'(("Align Columns" . t)
("No Formatting")
("Align Separators" . separator)
("Pad Columns" . padding)))
(default-choice
(car
(rassoc delimit-columns-format choices)))
(choice
(completing-read
(format "%s (%s): " "Specify how to format columns" default-choice)
choices nil t nil nil default-choice)))
(message "%s" choice)
(assoc-default choice choices))))
(apply orig-fun args)))
(advice-add 'delimit-columns-region :around #'my-delimits-column-region)
(advice-add 'delimit-columns-rectangle :around #'my-delimits-column-region)
(define-key-after global-map
[menu-bar extra-tools]
(cons "Extra Tools"
(easy-menu-create-menu "Extra Tools" nil))
'tools)
(easy-menu-define my-delim-col-menu nil "Menu for Delim Col"
'("Delimit Columns in ..."
["Region" delimit-columns-region :help "Prettify all columns in a text region"]
["Rectangle" delimit-columns-rectangle :help "Prettify all columns in a text rectangle"]
"---"
["Customize" delimit-columns-customize :help "Customization of `columns' group"]))
(easy-menu-add-item (current-global-map) '("menu-bar" "extra-tools") my-delim-col-menu)
(provide 'my-delim-col-menu.el)