-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathkmenu.el
204 lines (188 loc) · 8.3 KB
/
kmenu.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
;;; kmenu.el --- Pulldown and popup menus for kotl-mode, the Koutliner mode -*- lexical-binding: t; -*-
;;
;; Author: Bob Weiner
;;
;; Orig-Date: 28-Mar-94 at 11:22:09
;; Last-Mod: 25-Nov-24 at 22:11:56 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 1994-2022 Free Software Foundation, Inc.
;; See the "../HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
;;; Commentary:
;;; Code:
;;; ************************************************************************
;;; Other required Elisp libraries
;;; ************************************************************************
(require 'easymenu)
;;; ************************************************************************
;;; Public declarations
;;; ************************************************************************
(defvar kotl-mode-map)
;;; ************************************************************************
;;; Public variables
;;; ************************************************************************
(defconst kotl-menu-common-body
(delq
nil
(list
'("Edit"
["Set-Cell-Attribute" kotl-mode:set-cell-attribute t]
"----"
["Demote" kotl-mode:demote-tree
:active t :keys "TAB"]
["Promote" kotl-mode:promote-tree
:active t :keys "M-TAB"]
"----"
["Add-Child" kotl-mode:add-child t]
["Add-Cell" kotl-mode:add-cell t]
["Add-Parent" kotl-mode:add-parent t]
["Append-Cell" kotl-mode:append-cell t]
["Split-Cell" kotl-mode:split-cell t]
"----"
["Kill-to-Cell-End" kotl-mode:kill-contents t]
["Kill-Tree" kotl-mode:kill-tree t]
["Yank" kotl-mode:yank t]
"----"
["Copy-After-Cell" kotl-mode:copy-after t]
["Copy-Before-Cell" kotl-mode:copy-before t]
["Move-After-Cell" kotl-mode:move-after t]
["Move-Before-Cell" kotl-mode:move-before t]
"----"
["Fill" kotl-mode:fill-cell t]
["Fill-Paragraph" kotl-mode:fill-paragraph t]
["Set-Fill-Prefix" kotl-mode:set-fill-prefix t]
"----"
["Tab-Key-Inserts-Spaces" kotl-mode:toggle-indent-tabs-mode
:style toggle :selected (not kotl-mode:indent-tabs-mode)]
["Tab-Key-Tabs-Over" kotl-mode:toggle-tab-flag
:style toggle :selected kotl-mode:tab-flag])
(if (boundp 'infodock-go-menu) infodock-go-menu)
'("Jump-to"
["Cell" kotl-mode:goto-cell t]
"----"
["Cell-Beginning" kotl-mode:beginning-of-cell t]
["Cell-End" kotl-mode:end-of-cell t]
"----"
["Parent" kotl-mode:up-level t]
["Child" kotl-mode:down-level t]
"----"
["Prev-Cell" kotl-mode:previous-cell t]
["Next-Cell" kotl-mode:next-cell t]
"----"
["Prev-Same-Level" kotl-mode:backward-cell t]
["Next-Same-Level" kotl-mode:forward-cell t]
"----"
["First-Sibling" kotl-mode:first-sibling t]
["Last-Sibling" kotl-mode:last-sibling t]
"----"
["Beginning-of-Tree" kotl-mode:beginning-of-tree t]
["End-of-Tree" kotl-mode:end-of-tree t]
"----"
["First-Cell" kotl-mode:beginning-of-buffer t]
["Last-Cell" kotl-mode:end-of-buffer t])
'("Label-Type"
["Alphanumeric (Default)" (kview:set-label-type kotl-kview 'alpha) t]
["Legal" (kview:set-label-type kotl-kview 'legal) t]
;; ["None" (kview:set-label-type kview 'no) t]
;; ["Partial-Alpha" (kview:set-label-type kview 'partial-alpha) t]
["Permanent-Idstamp" (kview:set-label-type kotl-kview 'id) t]
;; ["Stars" (kview:set-label-type kview 'star) t]
"----"
["Set-Label-Separator" kview:set-label-separator t])
'("Link"
["Add-at-Point" klink:create t])
(if (fboundp 'infodock-options-menu) (infodock-options-menu))
'("Tree"
["Copy-to-Buffer" kotl-mode:copy-tree-to-buffer t]
["Demote" kotl-mode:demote-tree
:active t :keys "TAB"]
["Kill" kotl-mode:kill-tree t]
["Mail" kotl-mode:mail-tree t]
["Promote" kotl-mode:promote-tree
:active t :keys "M-TAB"]
["Show-Attributes" (kotl-mode:cell-help nil 2)
:active t :keys "C-u C-c h"]
"----"
["Copy-After-Cell" kotl-mode:copy-after t]
["Copy-Before-Cell" kotl-mode:copy-before t]
["Move-After-Cell" kotl-mode:move-after t]
["Move-Before-Cell" kotl-mode:move-before t])
'("View"
["Set-View-Spec" kvspec:activate t]
["Toggle-Blank-Lines" kvspec:toggle-blank-lines t]
"----"
["Set-Cell-Attribute" kotl-mode:set-cell-attribute t]
["Show-Cell-Attributes" (kotl-mode:cell-help)
:active t :keys "C-c h"]
["All-Cells-Attributes" (kotl-mode:cell-help nil -1)
:active t :keys "C-u -1 C-c h"]
["Show-Tree-Attributes" (kotl-mode:cell-help nil 2)
:active t :keys "C-u C-c h"]
"----"
["Hide (Collapse)" kotl-mode:hide-tree t]
["Hide-Levels" kotl-mode:hide-sublevels t]
["Hide-Subtree" kotl-mode:hide-subtree t]
["Overview" kotl-mode:overview t]
"----"
["Show (Expand)" kotl-mode:show-tree t]
["Show-All" kotl-mode:show-all t]
["Show-Subtree" kotl-mode:show-subtree t]
["Show-Top-Level-Only" kotl-mode:top-cells t])))
"The middle menu entries common to all Koutliner menus.")
(defconst kotl-menu-common-preamble
'("Koutline"
["All-Cells-Attributes" (kotl-mode:cell-help nil -1)
:active t :keys "C-u -1 C-c h"]
["Example" kotl-mode:example
:active t :keys "C-h h k e"]
["Help" describe-mode t]
["Manual" (id-info "(hyperbole)Outliner") t]
"----"
;; Delete Koutline menu from all menubars.
["Remove-This-Menu" (hui-menu-remove Koutline kotl-mode-map) t]))
(defconst kotl-menu-common-postamble
'("----"
["Find (Open)" find-file t]
["Find-Read-Only" find-file-read-only t]
["Save" save-buffer t]
["Toggle-Read-Only"
(if (fboundp 'vc-toggle-read-only)
(call-interactively 'vc-toggle-read-only)
(call-interactively 'toggle-read-only))
:active t
:keys "C-x C-q"]
["Write (Save as)" kfile:write t]
"----"
["Display-This-Koutline-in-Web-Browser" kexport:display t]
["Import-File-to-Koutline" kimport:file t]
["Export-Other-Koutline-to-HTML" kexport:html t]
["Export-This-Koutline-to-HTML" kexport:koutline t]
"----"
["Quit" (id-tool-quit '(kill-buffer nil)) t]))
(defconst id-popup-kotl-menu
(append kotl-menu-common-preamble
`("----"
,@ kotl-menu-common-body)
kotl-menu-common-postamble))
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************
(defun kotl-menubar-menu ()
"Add a Koutline menu to the menubar for each koutline buffer."
(define-key kotl-mode-map [C-down-mouse-3] 'kotl-popup-menu)
(define-key kotl-mode-map [C-mouse-3] nil)
(unless (global-key-binding [menu-bar Koutline])
(easy-menu-define nil kotl-mode-map "Koutline Menubar Menu" id-popup-kotl-menu)
;; Force a menu-bar update.
(force-mode-line-update)))
(defun kotl-popup-menu (event)
"Popup the Koutline buffer menu."
(interactive "@e")
(mouse-set-point event)
(popup-menu id-popup-kotl-menu))
(add-hook 'kotl-mode-hook #'kotl-menubar-menu)
(provide 'kmenu)
;;; kmenu.el ends here