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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
| | ;;; org-panel.el --- Simple routines for us with bad memory
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: Thu Nov 15 15:35:03 2007
;; Version: 0.21
;; Lxast-Updated: Wed Nov 21 03:06:03 2007 (3600 +0100)
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;; `easymenu', `font-lock', `noutline', `org', `outline', `syntax',
;; `time-date'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This defines a kind of control panel for `org-mode'. This control
;; panel should make it fast to move around and edit structure etc.
;;
;; To bring up the control panel type
;;
;; M-x orgpan-panel
;;
;; Type ? there for help.
;;
;; I suggest you add the following to your .emacs for quick access of
;; the panel:
;;
;; (eval-after-load 'org-mode
;; (define-key org-mode-map [(control ?c) ?p] 'orgpan-panel))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; 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 2, 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; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(require 'org)
(require 'outline)
;; Fix-me: this is for testing. A minor mode version interferes badly
;; with emulation minor modes. On the other hand, the other version
;; interferes badly with (interactive ...).
(defvar orgpan-minor-mode-version t)
(defface orgpan-field
'((t (:inherit 'widget-field)))
"Face for fields."
:group 'winsize)
(defvar orgpan-field-face 'orgpan-field)
(defface orgpan-active-field
'((t (:inherit 'highlight)))
"Face for fields."
:group 'winsize)
(defvar orgpan-active-field-face 'orgpan-active-field)
(defface orgpan-spaceline
'((t (:height 0.2)))
"Face for spacing lines."
:group 'winsize)
(defcustom orgpan-panel-buttons nil
"Panel style, if non-nil use buttons.
If there are buttons in the panel they are used to change the way
the arrow keys work. The panel looks something like this, with
the first button chosen:
[Navigate] [Restructure] [TODO/Priority]
----------
up/down, left: Go to, right: Visibility
The line below the buttons try to give a short hint about what
the arrow keys does. \(Personally I prefer the version without
buttons since I then do not have to remember which button is
active.)"
:type 'boolean
:group 'winsize)
;; Fix-me: add org-mode-map
(defconst orgpan-org-mode-commands nil)
(defconst orgpan-org-commands
'(
orgpan-copy-subtree
orgpan-cut-subtree
orgpan-paste-subtree
undo
;;
;orgpan-occur
;;
org-cycle
org-global-cycle
outline-up-heading
outline-next-visible-heading
outline-previous-visible-heading
outline-forward-same-level
outline-backward-same-level
org-todo
org-show-todo-tree
org-priority-up
org-priority-down
org-move-subtree-up
org-move-subtree-down
org-do-promote
org-do-demote
org-promote-subtree
org-demote-subtree))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Hook functions etc
;;(defvar orgpan-this-panel-window nil)
(defun orgpan-delete-panel ()
"Remove the panel."
(interactive)
(when (buffer-live-p orgpan-panel-buffer)
(delete-windows-on orgpan-panel-buffer)
(kill-buffer orgpan-panel-buffer))
(setq orgpan-panel-buffer nil)
(setq orgpan-panel-window nil)
(orgpan-panel-minor-mode 0)
(remove-hook 'post-command-hook 'orgpan-minor-post-command)
(remove-hook 'post-command-hook 'orgpan-mode-post-command)
;;(remove-hook 'window-configuration-change-hook 'orgpan-window-config-change)
)
(defvar orgpan-last-command-was-from-panel nil)
(defun orgpan-mode-pre-command ()
(setq orgpan-last-command-was-from-panel nil)
(condition-case err
(if (not (and (windowp orgpan-org-window)
(window-live-p orgpan-org-window)))
(progn
(setq this-command 'ignore)
(orgpan-delete-panel)
(message "The window belonging to the panel had disappeared, removed panel."))
(let ((buf (window-buffer orgpan-org-window)))
(when (with-current-buffer buf
(derived-mode-p 'org-mode))
(setq orgpan-last-org-buffer buf))
;; Fix me: add a list of those commands that are not
;; meaningful from the panel (for example org-time-stamp)
(when (or (memq this-command orgpan-org-commands)
(memq this-command orgpan-org-mode-commands)
;; For some reason not all org commands are found above:
(string= "org-" (substring (format "%s" this-command) 0 4)))
(if (not (with-current-buffer buf
(derived-mode-p 'org-mode)))
(progn
(if (buffer-live-p orgpan-org-buffer)
(set-window-buffer orgpan-org-window orgpan-org-buffer)
(message "Please use `l' or `b' to choose an org-mode buffer"))
(setq this-command 'ignore))
(setq orgpan-org-buffer (window-buffer orgpan-org-window))
(setq orgpan-last-command-was-from-panel t)
(select-window orgpan-org-window)
;;(when (active-minibuffer-window
;;(set-buffer orgpan-org-buffer)
))))
(error (lwarn 't :warning "orgpan-pre: %S" err))))
(defun orgpan-mode-post-command ()
(condition-case err
(progn
(unless (and (windowp orgpan-panel-window)
(window-live-p orgpan-panel-window)
(bufferp orgpan-panel-buffer)
(buffer-live-p orgpan-panel-buffer))
;;(orgpan-delete-panel)
)
(when (and orgpan-last-command-was-from-panel
(windowp orgpan-panel-window)
(window-live-p orgpan-panel-window))
(select-window orgpan-panel-window)
(when (derived-mode-p 'orgpan-mode)
(setq deactivate-mark t)
(when orgpan-panel-buttons
(unless (and orgpan-point
(= (point) orgpan-point))
;; Go backward so it is possible to click on a "button":
(orgpan-backward-field)))))
(setq orgpan-this-panel-window nil))
(error (lwarn 't :warning "orgpan-post: %S" err))))
;; (defun orgpan-window-config-change ()
;; "Check if any frame is displaying an orgpan panel.
;; If not remove `orgpan-mode-post-command' and this function from
;; the hooks."
;; (condition-case err
;; (unless (and (
;; (let ((found-pan nil))
;; (dolist (f (frame-list))
;; (dolist (w (window-list f 'nomini))
;; (with-current-buffer (window-buffer w)
;; (when (derived-mode-p 'orgpan-mode)
;; (setq found-pan t)))))
;; (unless found-pan
;; (remove-hook 'post-command-hook 'orgpan-mode-post-command)
;; (remove-hook 'window-configuration-change-hook 'orgpan-window-config-change)))
;; (error (lwarn 't :warning "Error in orgpan-config-change: %S" err))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Commands
(defun orgpan-last-buffer ()
"Open last org-mode buffer in panels org window."
(interactive)
(let ((buf (window-buffer orgpan-org-window))
(last-buf orgpan-last-org-buffer))
(when (with-current-buffer buf
(derived-mode-p 'org-mode))
(setq orgpan-last-org-buffer buf))
(when (eq last-buf buf)
(setq last-buf nil))
(if (not last-buf)
(orgpan-switch-buffer)
(set-window-buffer orgpan-org-window last-buf))))
(defun orgpan-switch-buffer ()
"Switch to next org-mode buffer in panels org window."
(interactive)
(let ((buf (window-buffer orgpan-org-window))
(org-buffers nil))
(with-current-buffer buf
(when (derived-mode-p 'org-mode)
(bury-buffer buf)
(setq orgpan-last-org-buffer buf)))
(setq org-buffers (delq nil (mapcar (lambda (buf)
(when (with-current-buffer buf
(derived-mode-p 'org-mode))
buf))
(buffer-list))))
(setq org-buffers (delq buf org-buffers))
(set-window-buffer orgpan-org-window (car org-buffers))
(setq orgpan-org-buffer (car org-buffers))))
(defun orgpan-paste-subtree ()
(interactive)
(if (y-or-n-p "Paste subtree here? ")
(org-paste-subtree)
(message "Nothing was pasted")))
(defun orgpan-cut-subtree ()
(interactive)
(let ((heading (progn
(org-back-to-heading)
(buffer-substring (point) (line-end-position))
)))
(if (y-or-n-p (format "Do you want to cut the subtree\n%s\n? " heading))
(org-cut-subtree)
(message "Nothing was cut"))))
(defun orgpan-copy-subtree ()
(interactive)
(let ((heading (progn
(org-back-to-heading)
(buffer-substring (point) (line-end-position))
)))
(if (y-or-n-p (format "Do you want to copy the subtree\n%s\n? " heading))
(org-copy-subtree)
(message "Nothing was copied"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Buttons
(defvar orgpan-ovl-help nil)
(defun orgpan-check-panel-mode ()
(unless (derived-mode-p 'orgpan-mode)
(error "Not orgpan-mode in buffer: " major-mode)))
(defun orgpan-display-bindings-help ()
(orgpan-check-panel-mode)
(setq orgpan-point (point))
(let* ((ovls (overlays-at (point)))
(ovl (car ovls))
(help (when ovl (overlay-get ovl 'orgpan-explain))))
(dolist (o (overlays-in (point-min) (point-max)))
(overlay-put o 'face orgpan-field-face))
(overlay-put ovl 'face orgpan-active-field-face)
(overlay-put orgpan-ovl-help 'before-string help)))
(defun orgpan-forward-field ()
(interactive)
(orgpan-check-panel-mode)
(let ((pos (next-overlay-change (point))))
(unless (overlays-at pos)
(setq pos (next-overlay-change pos)))
(when (= pos (point-max))
(setq pos (point-min))
(unless (overlays-at pos)
(setq pos (next-overlay-change pos))))
(goto-char pos))
(orgpan-display-bindings-help))
(defun orgpan-backward-field ()
(interactive)
(orgpan-check-panel-mode)
(when (= (point) (point-min))
(goto-char (point-max)))
(let ((pos (previous-overlay-change (point))))
(unless (overlays-at pos)
(setq pos (previous-overlay-change pos)))
(goto-char pos))
(orgpan-display-bindings-help))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Mode
(defconst orgpan-mode-map
;; Fix-me: clean up here!
;; Fix-me: viper support
(let ((map (make-sparse-keymap)))
(define-key map [?q] 'orgpan-delete-panel)
(define-key map [??] 'orgpan-help)
;; Copying etc
(define-key map [?c] 'orgpan-copy-subtree)
(define-key map [?x] 'orgpan-cut-subtree)
(define-key map [?p] 'orgpan-paste-subtree)
(define-key map [?z] 'undo)
;; Buffers:
(define-key map [?b] 'orgpan-switch-buffer)
(define-key map [?l] 'orgpan-last-buffer)
;; Some keys for moving between headings. Emacs keys for next/prev
;; line seems ok:
(define-key map [(control ?p)] 'outline-previous-visible-heading)
(define-key map [(control ?n)] 'outline-next-visible-heading)
(define-key map [(shift control ?p)] 'outline-backward-same-level)
(define-key map [(shift control ?n)] 'outline-forward-same-level)
;; A mnemunic for up:
(define-key map [(control ?u)] 'outline-up-heading)
;; Search sparse tree:
;;
;; Fix-me: Search does not work, some problem with
;; interactive. Probably have to turn the whole thing around and
;; always be in the org buffer, but with a minor mode running
;; there.
;;
;;(define-key map [?s] 'org-sparse-tree)
(define-key map [?s] 'orgpan-occur)
;; Same as in org-mode:
;;(define-key map [(control ?c)(control ?v)] 'org-show-todo-tree)
;; Fix-me: This leads to strange problems:
;;(define-key map [t] 'ignore)
map))
(defun orgpan-occur ()
"Replacement for `org-occur'.
Technical reasons."
(interactive)
(let ((rgx (read-from-minibuffer "my mini Regexp: ")))
(setq orgpan-last-command-was-from-panel t)
(select-window orgpan-org-window)
(org-occur rgx)))
(defvar orgpan-panel-window nil
"The window showing `orgpan-panel-buffer'.")
(defvar orgpan-panel-buffer nil
"The panel buffer.
There can be only one such buffer at any time.")
(defvar orgpan-org-window nil)
;;(make-variable-buffer-local 'orgpan-org-window)
;; Fix-me: used?
(defvar orgpan-org-buffer nil)
;;(make-variable-buffer-local 'orgpan-org-buffer)
(defvar orgpan-last-org-buffer nil)
;;(make-variable-buffer-local 'orgpan-last-org-buffer)
(defvar orgpan-point nil)
;;(make-variable-buffer-local 'orgpan-point)
(defun orgpan-avoid-viper-in-buffer ()
;; Fix-me: This is ugly. However see `this-major-mode-requires-vi-state':
(set (make-local-variable 'viper-emacs-state-mode-list) '(orgpan-mode))
(set (make-local-variable 'viper-new-major-mode-buffer-list) nil)
(local-set-key [?\ ] 'ignore))
(define-derived-mode orgpan-mode nil "Org-Panel"
"Mode for org-simple.el control panel."
(setq buffer-read-only t)
(unless orgpan-minor-mode-version
(add-hook 'pre-command-hook 'orgpan-mode-pre-command nil t)
(add-hook 'post-command-hook 'orgpan-mode-post-command t))
(orgpan-avoid-viper-in-buffer)
(setq cursor-type nil))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Panel layout
(defun orgpan-insert-field (text keymap explain)
(insert text)
(let* ((end (point))
(len (length text))
(beg (- end len))
(ovl (make-overlay beg end)))
(overlay-put ovl 'face orgpan-field-face)
(overlay-put ovl 'keymap keymap)
(overlay-put ovl 'orgpan-explain explain)))
(defconst orgpan-with-keymap
(let ((map (make-sparse-keymap)))
(set-keymap-parent map org-mode-map)
;; Users are used to tabbing between fields:
(define-key map [(tab)] 'orgpan-forward-field)
(define-key map [(shift tab)] 'orgpan-backward-field)
;; Now we must use something else for visibility (first does not work if Viper):
(define-key map [(meta tab)] 'org-cycle)
(define-key map [(control meta tab)] 'org-global-cycle)
map))
(defconst orgpan-without-keymap
(let ((map (make-sparse-keymap)))
(set-keymap-parent map org-mode-map)
;; Visibility (those are in org-mode-map):
;;(define-key map [tab] 'org-cycle)
;;(define-key map [(shift tab)] 'org-global-cycle)
;; Navigate:
(define-key map [left] 'outline-up-heading)
(define-key map [right] 'org-cycle)
(define-key map [up] 'outline-previous-visible-heading)
(define-key map [down] 'outline-next-visible-heading)
(define-key map [(shift down)] 'outline-forward-same-level)
(define-key map [(shift up)] 'outline-backward-same-level)
;; Restructure:
(define-key map [(control up)] 'org-move-subtree-up)
(define-key map [(control down)] 'org-move-subtree-down)
(define-key map [(control left)] 'org-do-promote)
(define-key map [(control right)] 'org-do-demote)
(define-key map [(control shift left)] 'org-promote-subtree)
(define-key map [(control shift right)] 'org-demote-subtree)
;; Todo etc
(define-key map [?+] 'org-priority-up)
(define-key map [?-] 'org-priority-down)
(define-key map [?t] 'org-todo)
map))
(defun orgpan-make-panel-without-buttons (buf)
(with-current-buffer buf
(insert (propertize "Org Panel" 'face 'orgpan-active-field))
(insert " ? for help, q quit\n")
(insert (propertize "arrows" 'face 'font-lock-keyword-face)
": Go to, "
(propertize "C-arrows" 'face 'font-lock-keyword-face)
": Edit tree\n"
(propertize "cxpz" 'face 'font-lock-keyword-face)
": copy cut paste undo, "
(propertize "tT+-" 'face 'font-lock-keyword-face)
": todo priority, "
(propertize "s" 'face 'font-lock-keyword-face)
" search"
)
(set-keymap-parent orgpan-mode-map orgpan-without-keymap)
))
(defun orgpan-make-panel-with-buttons (buf)
(with-current-buffer buf
(let* ((base-map (make-sparse-keymap))
(space-line (propertize "\n\n" 'face 'orgpan-spaceline))
(arrow-face 'font-lock-keyword-face)
(L (propertize "left" 'face arrow-face))
(R (propertize "right" 'face arrow-face))
(U (propertize "up" 'face arrow-face))
(D (propertize "down" 'face arrow-face)))
;;(message D)(sit-for 2)
(define-key base-map [left] 'ignore)
(define-key base-map [right] 'ignore)
(define-key base-map [up] 'ignore)
(define-key base-map [down] 'ignore)
(define-key base-map [?q] 'delete-window)
(define-key base-map [??] 'orgpan-help)
;; Navigating
(let ((map (copy-keymap base-map)))
(define-key map [left] 'outline-up-heading)
(define-key map [right] 'org-cycle)
(define-key map [up] 'outline-previous-visible-heading)
(define-key map [down] 'outline-next-visible-heading)
(define-key map [(shift down)] 'outline-forward-same-level)
(define-key map [(shift up)] 'outline-backward-same-level)
(orgpan-insert-field "Navigate" map (concat U "/" D ", " L ": Go to, " R ": Visibility")))
(insert " ")
(let ((map (copy-keymap base-map)))
(define-key map [up] 'org-move-subtree-up)
(define-key map [down] 'org-move-subtree-down)
(define-key map [left] 'org-do-promote)
(define-key map [right] 'org-do-demote)
(define-key map [(shift left)] 'org-promote-subtree)
(define-key map [(shift right)] 'org-demote-subtree)
(orgpan-insert-field
"Restructure" map
(concat U "/" D ": "
(propertize "Move" 'face 'font-lock-warning-face)
", " L "/" R ": "
(propertize "Level (w S: Subtree Level)" 'face 'font-lock-warning-face))))
(insert " ")
(let ((map (copy-keymap base-map)))
(define-key map [up] 'org-priority-up)
(define-key map [down] 'org-priority-down)
(define-key map [right] 'org-todo)
(orgpan-insert-field "TODO/priority" map
(concat R ": TODO, " U "/" D ": Priority")))
)
(insert " ? for help, q quit\n")
(orgpan-display-bindings-help)
(setq orgpan-ovl-help (make-overlay (point) (point)))
))
(defun orgpan-make-panel-buffer ()
"Make the panel buffer."
(let* ((buf-name "*Org Panel*"))
(when orgpan-panel-buffer (kill-buffer orgpan-panel-buffer))
(setq orgpan-panel-buffer (get-buffer-create buf-name))
(if orgpan-panel-buttons
(orgpan-make-panel-with-buttons orgpan-panel-buffer)
(orgpan-make-panel-without-buttons orgpan-panel-buffer))
(with-current-buffer orgpan-panel-buffer
(orgpan-mode)
(goto-char (point-min)))
orgpan-panel-buffer))
(defun orgpan-help ()
(interactive)
(set-keymap-parent orgpan-with-keymap nil)
(set-keymap-parent orgpan-without-keymap nil)
(describe-function 'orgpan-panel)
(set-keymap-parent orgpan-with-keymap org-mode-map)
(set-keymap-parent orgpan-without-keymap org-mode-map)
(message "Use 'l' to remove help window")
)
(defun orgpan-panel ()
"Create a control panel for current `org-mode' buffer.
The control panel may be used to quickly move around and change
the headings. The idea is that when you want to to a lot of this
kind of editing you should be able to do that with few
keystrokes (and without having to remember the complicated
keystrokes). A typical situation when this perhaps can be useful
is when you are looking at your notes file \(usually ~/.notes,
see `remember-data-file') where you have saved quick notes with
`remember'.
The keys below are defined in the panel. Note that the commands
are carried out in the `org-mode' buffer that belongs to the
panel.
\\{orgpan-mode-map}
In addition to the keys above most of the keys in `org-mode' can
also be used from the panel.
Note: There are two forms of the control panel, one with buttons
and one without. The default is without, see
`orgpan-panel-buttons'. If buttons are used choosing a different
button changes the binding of the arrow keys."
(interactive)
(unless (derived-mode-p 'org-mode)
(error "Buffer is not in org-mode"))
(orgpan-delete-panel)
(unless orgpan-org-mode-commands
(map-keymap (lambda (ev def)
(when (and def
(symbolp def)
(fboundp def))
(setq orgpan-org-mode-commands
(cons def orgpan-org-mode-commands))))
org-mode-map))
;;(org-back-to-heading)
;;(remove-hook 'window-configuration-change-hook 'orgpan-window-config-change)
(setq orgpan-org-window (selected-window))
(setq orgpan-panel-window (split-window nil nil 'below))
(select-window orgpan-panel-window)
(set-window-buffer (selected-window) (orgpan-make-panel-buffer))
;;(set-window-dedicated-p (selected-window) t)
(fit-window-to-buffer nil 4 4)
;; The minor mode version starts here:
(when orgpan-minor-mode-version
(select-window orgpan-org-window)
(orgpan-panel-minor-mode 1)
(add-hook 'post-command-hook 'orgpan-minor-post-command t)))
(defun orgpan-minor-post-command ()
(unless (and
;; Check org window and buffer
(windowp orgpan-org-window)
(window-live-p orgpan-org-window)
(eq orgpan-org-window (selected-window))
(derived-mode-p 'org-mode)
;; Check panel window and buffer
(windowp orgpan-panel-window)
(window-live-p orgpan-panel-window)
(bufferp orgpan-panel-buffer)
(buffer-live-p orgpan-panel-buffer)
(eq (window-buffer orgpan-panel-window) orgpan-panel-buffer)
;; Check minor mode
orgpan-panel-minor-mode)
(orgpan-delete-panel)))
(define-minor-mode orgpan-panel-minor-mode
"Minor mode used in `org-mode' buffer when showing panel."
:keymap orgpan-mode-map
:lighter " PANEL"
:group 'orgpan
)
(provide 'org-panel)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; org-panel.el ends here
|