org-panel.el (22440B)
1 ;;; org-panel.el --- Simple routines for us with bad memory 2 ;; 3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com) 4 ;; Created: Thu Nov 15 15:35:03 2007 5 ;; Version: 0.21 6 ;; Lxast-Updated: Wed Nov 21 03:06:03 2007 (3600 +0100) 7 ;; 8 ;; Features that might be required by this library: 9 ;; 10 ;; `easymenu', `font-lock', `noutline', `org', `outline', `syntax', 11 ;; `time-date'. 12 ;; 13 ;; This file is not part of GNU Emacs. 14 ;; 15 ;; This program is free software; you can redistribute it and/or 16 ;; modify it under the terms of the GNU General Public License as 17 ;; published by the Free Software Foundation; either version 3, or 18 ;; (at your option) any later version. 19 ;; 20 ;; This program is distributed in the hope that it will be useful, 21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 ;; General Public License for more details. 24 ;; 25 ;; You should have received a copy of the GNU General Public License 26 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. 27 ;; 28 ;;; Commentary: 29 ;; 30 ;; This defines a kind of control panel for `org-mode'. This control 31 ;; panel should make it fast to move around and edit structure etc. 32 ;; 33 ;; To bring up the control panel type 34 ;; 35 ;; M-x orgpan-panel 36 ;; 37 ;; Type ? there for help. 38 ;; 39 ;; I suggest you add the following to your .emacs for quick access of 40 ;; the panel: 41 ;; 42 ;; (eval-after-load 'org-mode 43 ;; (define-key org-mode-map [(control ?c) ?p] 'orgpan-panel)) 44 ;; 45 ;;; Code: 46 47 (require 'org) 48 (require 'outline) 49 50 ;; Fix-me: this is for testing. A minor mode version interferes badly 51 ;; with emulation minor modes. On the other hand, the other version 52 ;; interferes badly with (interactive ...). 53 (defvar orgpan-minor-mode-version t) 54 55 (defface orgpan-field 56 '((t (:inherit 'widget-field))) 57 "Face for fields." 58 :group 'winsize) 59 (defvar orgpan-field-face 'orgpan-field) 60 61 (defface orgpan-active-field 62 '((t (:inherit 'highlight))) 63 "Face for fields." 64 :group 'winsize) 65 (defvar orgpan-active-field-face 'orgpan-active-field) 66 67 (defface orgpan-spaceline 68 '((t (:height 0.2))) 69 "Face for spacing lines." 70 :group 'winsize) 71 72 (defcustom orgpan-panel-buttons nil 73 "Panel style, if non-nil use buttons. 74 If there are buttons in the panel they are used to change the way 75 the arrow keys work. The panel looks something like this, with 76 the first button chosen: 77 78 [Navigate] [Restructure] [TODO/Priority] 79 ---------- 80 up/down, left: Go to, right: Visibility 81 82 The line below the buttons try to give a short hint about what 83 the arrow keys does. \(Personally I prefer the version without 84 buttons since I then do not have to remember which button is 85 active.)" 86 :type 'boolean 87 :group 'winsize) 88 89 ;; Fix-me: add org-mode-map 90 (defconst orgpan-org-mode-commands nil) 91 (defconst orgpan-org-commands 92 '( 93 orgpan-copy-subtree 94 orgpan-cut-subtree 95 orgpan-paste-subtree 96 undo 97 ;; 98 ;orgpan-occur 99 ;; 100 org-cycle 101 org-global-cycle 102 outline-up-heading 103 outline-next-visible-heading 104 outline-previous-visible-heading 105 outline-forward-same-level 106 outline-backward-same-level 107 org-todo 108 org-show-todo-tree 109 org-priority-up 110 org-priority-down 111 org-move-subtree-up 112 org-move-subtree-down 113 org-do-promote 114 org-do-demote 115 org-promote-subtree 116 org-demote-subtree)) 117 118 119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 120 ;;; Hook functions etc 121 122 (defun orgpan-delete-panel () 123 "Remove the panel." 124 (interactive) 125 (when (buffer-live-p orgpan-panel-buffer) 126 (delete-windows-on orgpan-panel-buffer) 127 (kill-buffer orgpan-panel-buffer)) 128 (setq orgpan-panel-buffer nil) 129 (setq orgpan-panel-window nil) 130 (orgpan-panel-minor-mode 0) 131 (remove-hook 'post-command-hook 'orgpan-minor-post-command) 132 (remove-hook 'post-command-hook 'orgpan-mode-post-command) 133 ;;(remove-hook 'window-configuration-change-hook 'orgpan-window-config-change) 134 ) 135 136 (defvar orgpan-last-command-was-from-panel nil) 137 (defun orgpan-mode-pre-command () 138 (setq orgpan-last-command-was-from-panel nil) 139 (condition-case err 140 (if (not (and (windowp orgpan-org-window) 141 (window-live-p orgpan-org-window))) 142 (progn 143 (setq this-command 'ignore) 144 (orgpan-delete-panel) 145 (message "The window belonging to the panel had disappeared, removed panel.")) 146 (let ((buf (window-buffer orgpan-org-window))) 147 (when (with-current-buffer buf 148 (derived-mode-p 'org-mode)) 149 (setq orgpan-last-org-buffer buf)) 150 ;; Fix me: add a list of those commands that are not 151 ;; meaningful from the panel (for example org-time-stamp) 152 (when (or (memq this-command orgpan-org-commands) 153 (memq this-command orgpan-org-mode-commands) 154 ;; For some reason not all org commands are found above: 155 (string= "org-" (substring (format "%s" this-command) 0 4))) 156 (if (not (with-current-buffer buf 157 (derived-mode-p 'org-mode))) 158 (progn 159 (if (buffer-live-p orgpan-org-buffer) 160 (set-window-buffer orgpan-org-window orgpan-org-buffer) 161 (message "Please use `l' or `b' to choose an org-mode buffer")) 162 (setq this-command 'ignore)) 163 (setq orgpan-org-buffer (window-buffer orgpan-org-window)) 164 (setq orgpan-last-command-was-from-panel t) 165 (select-window orgpan-org-window) 166 ;;(when (active-minibuffer-window 167 ;;(set-buffer orgpan-org-buffer) 168 )))) 169 (error (lwarn 't :warning "orgpan-pre: %S" err)))) 170 171 (defun orgpan-mode-post-command () 172 (condition-case err 173 (progn 174 (unless (and (windowp orgpan-panel-window) 175 (window-live-p orgpan-panel-window) 176 (bufferp orgpan-panel-buffer) 177 (buffer-live-p orgpan-panel-buffer)) 178 ;;(orgpan-delete-panel) 179 ) 180 (when (and orgpan-last-command-was-from-panel 181 (windowp orgpan-panel-window) 182 (window-live-p orgpan-panel-window)) 183 (select-window orgpan-panel-window) 184 (when (derived-mode-p 'orgpan-mode) 185 (setq deactivate-mark t) 186 (when orgpan-panel-buttons 187 (unless (and orgpan-point 188 (= (point) orgpan-point)) 189 ;; Go backward so it is possible to click on a "button": 190 (orgpan-backward-field)))))) 191 (error (lwarn 't :warning "orgpan-post: %S" err)))) 192 193 ;; (defun orgpan-window-config-change () 194 ;; "Check if any frame is displaying an orgpan panel. 195 ;; If not remove `orgpan-mode-post-command' and this function from 196 ;; the hooks." 197 ;; (condition-case err 198 ;; (unless (and ( 199 ;; (let ((found-pan nil)) 200 ;; (dolist (f (frame-list)) 201 ;; (dolist (w (window-list f 'nomini)) 202 ;; (with-current-buffer (window-buffer w) 203 ;; (when (derived-mode-p 'orgpan-mode) 204 ;; (setq found-pan t))))) 205 ;; (unless found-pan 206 ;; (remove-hook 'post-command-hook 'orgpan-mode-post-command) 207 ;; (remove-hook 'window-configuration-change-hook 'orgpan-window-config-change))) 208 ;; (error (lwarn 't :warning "Error in orgpan-config-change: %S" err)))) 209 210 211 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 212 ;;; Commands 213 214 (defun orgpan-last-buffer () 215 "Open last org-mode buffer in panels org window." 216 (interactive) 217 (let ((buf (window-buffer orgpan-org-window)) 218 (last-buf orgpan-last-org-buffer)) 219 (when (with-current-buffer buf 220 (derived-mode-p 'org-mode)) 221 (setq orgpan-last-org-buffer buf)) 222 (when (eq last-buf buf) 223 (setq last-buf nil)) 224 (if (not last-buf) 225 (orgpan-switch-buffer) 226 (set-window-buffer orgpan-org-window last-buf)))) 227 228 (defun orgpan-switch-buffer () 229 "Switch to next org-mode buffer in panels org window." 230 (interactive) 231 (let ((buf (window-buffer orgpan-org-window)) 232 (org-buffers nil)) 233 (with-current-buffer buf 234 (when (derived-mode-p 'org-mode) 235 (bury-buffer buf) 236 (setq orgpan-last-org-buffer buf))) 237 (setq org-buffers (delq nil (mapcar (lambda (buf) 238 (when (with-current-buffer buf 239 (derived-mode-p 'org-mode)) 240 buf)) 241 (buffer-list)))) 242 (setq org-buffers (delq buf org-buffers)) 243 (set-window-buffer orgpan-org-window (car org-buffers)) 244 (setq orgpan-org-buffer (car org-buffers)))) 245 246 (defun orgpan-paste-subtree () 247 (interactive) 248 (if (y-or-n-p "Paste subtree here? ") 249 (org-paste-subtree) 250 (message "Nothing was pasted"))) 251 252 (defun orgpan-cut-subtree () 253 (interactive) 254 (let ((heading (progn 255 (org-back-to-heading) 256 (buffer-substring (point) (line-end-position)) 257 ))) 258 (if (y-or-n-p (format "Do you want to cut the subtree\n%s\n? " heading)) 259 (org-cut-subtree) 260 (message "Nothing was cut")))) 261 262 (defun orgpan-copy-subtree () 263 (interactive) 264 (let ((heading (progn 265 (org-back-to-heading) 266 (buffer-substring (point) (line-end-position)) 267 ))) 268 (if (y-or-n-p (format "Do you want to copy the subtree\n%s\n? " heading)) 269 (org-copy-subtree) 270 (message "Nothing was copied")))) 271 272 273 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 274 ;;; Buttons 275 276 (defvar orgpan-ovl-help nil) 277 278 (defun orgpan-check-panel-mode () 279 (unless (derived-mode-p 'orgpan-mode) 280 (error "Not orgpan-mode in buffer: %s" major-mode))) 281 282 (defun orgpan-display-bindings-help () 283 (orgpan-check-panel-mode) 284 (setq orgpan-point (point)) 285 (let* ((ovls (overlays-at (point))) 286 (ovl (car ovls)) 287 (help (when ovl (overlay-get ovl 'orgpan-explain)))) 288 (dolist (o (overlays-in (point-min) (point-max))) 289 (overlay-put o 'face orgpan-field-face)) 290 (overlay-put ovl 'face orgpan-active-field-face) 291 (overlay-put orgpan-ovl-help 'before-string help))) 292 293 (defun orgpan-forward-field () 294 (interactive) 295 (orgpan-check-panel-mode) 296 (let ((pos (next-overlay-change (point)))) 297 (unless (overlays-at pos) 298 (setq pos (next-overlay-change pos))) 299 (when (= pos (point-max)) 300 (setq pos (point-min)) 301 (unless (overlays-at pos) 302 (setq pos (next-overlay-change pos)))) 303 (goto-char pos)) 304 (orgpan-display-bindings-help)) 305 306 (defun orgpan-backward-field () 307 (interactive) 308 (orgpan-check-panel-mode) 309 (when (= (point) (point-min)) 310 (goto-char (point-max))) 311 (let ((pos (previous-overlay-change (point)))) 312 (unless (overlays-at pos) 313 (setq pos (previous-overlay-change pos))) 314 (goto-char pos)) 315 (orgpan-display-bindings-help)) 316 317 318 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 319 ;;; Mode 320 321 (defconst orgpan-mode-map 322 ;; Fix-me: clean up here! 323 ;; Fix-me: viper support 324 (let ((map (make-sparse-keymap))) 325 (define-key map [?q] 'orgpan-delete-panel) 326 (define-key map [??] 'orgpan-help) 327 ;; Copying etc 328 (define-key map [?c] 'orgpan-copy-subtree) 329 (define-key map [?x] 'orgpan-cut-subtree) 330 (define-key map [?p] 'orgpan-paste-subtree) 331 (define-key map [?z] 'undo) 332 ;; Buffers: 333 (define-key map [?b] 'orgpan-switch-buffer) 334 (define-key map [?l] 'orgpan-last-buffer) 335 ;; Some keys for moving between headings. Emacs keys for next/prev 336 ;; line seems ok: 337 (define-key map [(control ?p)] 'outline-previous-visible-heading) 338 (define-key map [(control ?n)] 'outline-next-visible-heading) 339 (define-key map [(shift control ?p)] 'outline-backward-same-level) 340 (define-key map [(shift control ?n)] 'outline-forward-same-level) 341 ;; A mnemunic for up: 342 (define-key map [(control ?u)] 'outline-up-heading) 343 ;; Search sparse tree: 344 ;; 345 ;; Fix-me: Search does not work, some problem with 346 ;; interactive. Probably have to turn the whole thing around and 347 ;; always be in the org buffer, but with a minor mode running 348 ;; there. 349 ;; 350 ;;(define-key map [?s] 'org-sparse-tree) 351 (define-key map [?s] 'orgpan-occur) 352 ;; Same as in org-mode: 353 ;;(define-key map [(control ?c)(control ?v)] 'org-show-todo-tree) 354 ;; Fix-me: This leads to strange problems: 355 ;;(define-key map [t] 'ignore) 356 map)) 357 358 (defun orgpan-occur () 359 "Replacement for `org-occur'. 360 Technical reasons." 361 (interactive) 362 (let ((rgx (read-from-minibuffer "my mini Regexp: "))) 363 (setq orgpan-last-command-was-from-panel t) 364 (select-window orgpan-org-window) 365 (org-occur rgx))) 366 367 (defvar orgpan-panel-window nil 368 "The window showing `orgpan-panel-buffer'.") 369 370 (defvar orgpan-panel-buffer nil 371 "The panel buffer. 372 There can be only one such buffer at any time.") 373 374 (defvar orgpan-org-window nil) 375 ;;(make-variable-buffer-local 'orgpan-org-window) 376 377 ;; Fix-me: used? 378 (defvar orgpan-org-buffer nil) 379 ;;(make-variable-buffer-local 'orgpan-org-buffer) 380 381 (defvar orgpan-last-org-buffer nil) 382 ;;(make-variable-buffer-local 'orgpan-last-org-buffer) 383 384 (defvar orgpan-point nil) 385 ;;(make-variable-buffer-local 'orgpan-point) 386 387 (defvar viper-emacs-state-mode-list) 388 (defvar viper-new-major-mode-buffer-list) 389 390 (defun orgpan-avoid-viper-in-buffer () 391 ;; Fix-me: This is ugly. However see `this-major-mode-requires-vi-state': 392 (set (make-local-variable 'viper-emacs-state-mode-list) '(orgpan-mode)) 393 (set (make-local-variable 'viper-new-major-mode-buffer-list) nil) 394 (local-set-key [?\ ] 'ignore)) 395 396 (define-derived-mode orgpan-mode nil "Org-Panel" 397 "Mode for org-simple.el control panel." 398 (setq buffer-read-only t) 399 (unless orgpan-minor-mode-version 400 (add-hook 'pre-command-hook 'orgpan-mode-pre-command nil t) 401 (add-hook 'post-command-hook 'orgpan-mode-post-command t)) 402 (orgpan-avoid-viper-in-buffer) 403 (setq cursor-type nil)) 404 405 406 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 407 ;;; Panel layout 408 409 (defun orgpan-insert-field (text keymap explain) 410 (insert text) 411 (let* ((end (point)) 412 (len (length text)) 413 (beg (- end len)) 414 (ovl (make-overlay beg end))) 415 (overlay-put ovl 'face orgpan-field-face) 416 (overlay-put ovl 'keymap keymap) 417 (overlay-put ovl 'orgpan-explain explain))) 418 419 (defconst orgpan-with-keymap 420 (let ((map (make-sparse-keymap))) 421 (set-keymap-parent map org-mode-map) 422 ;; Users are used to tabbing between fields: 423 (define-key map [(tab)] 'orgpan-forward-field) 424 (define-key map [(shift tab)] 'orgpan-backward-field) 425 ;; Now we must use something else for visibility (first does not work if Viper): 426 (define-key map [(meta tab)] 'org-cycle) 427 (define-key map [(control meta tab)] 'org-global-cycle) 428 map)) 429 430 (defconst orgpan-without-keymap 431 (let ((map (make-sparse-keymap))) 432 (set-keymap-parent map org-mode-map) 433 ;; Visibility (those are in org-mode-map): 434 ;;(define-key map [tab] 'org-cycle) 435 ;;(define-key map [(shift tab)] 'org-global-cycle) 436 ;; Navigate: 437 (define-key map [left] 'outline-up-heading) 438 (define-key map [right] 'org-cycle) 439 (define-key map [up] 'outline-previous-visible-heading) 440 (define-key map [down] 'outline-next-visible-heading) 441 (define-key map [(shift down)] 'outline-forward-same-level) 442 (define-key map [(shift up)] 'outline-backward-same-level) 443 ;; Restructure: 444 (define-key map [(control up)] 'org-move-subtree-up) 445 (define-key map [(control down)] 'org-move-subtree-down) 446 (define-key map [(control left)] 'org-do-promote) 447 (define-key map [(control right)] 'org-do-demote) 448 (define-key map [(control shift left)] 'org-promote-subtree) 449 (define-key map [(control shift right)] 'org-demote-subtree) 450 ;; Todo etc 451 (define-key map [?+] 'org-priority-up) 452 (define-key map [?-] 'org-priority-down) 453 (define-key map [?t] 'org-todo) 454 map)) 455 456 (defun orgpan-make-panel-without-buttons (buf) 457 (with-current-buffer buf 458 (insert (propertize "Org Panel" 'face 'orgpan-active-field)) 459 (insert " ? for help, q quit\n") 460 (insert (propertize "arrows" 'face 'font-lock-keyword-face) 461 ": Go to, " 462 (propertize "C-arrows" 'face 'font-lock-keyword-face) 463 ": Edit tree\n" 464 (propertize "cxpz" 'face 'font-lock-keyword-face) 465 ": copy cut paste undo, " 466 (propertize "tT+-" 'face 'font-lock-keyword-face) 467 ": todo priority, " 468 (propertize "s" 'face 'font-lock-keyword-face) 469 " search" 470 ) 471 (set-keymap-parent orgpan-mode-map orgpan-without-keymap) 472 )) 473 474 (defun orgpan-make-panel-with-buttons (buf) 475 (with-current-buffer buf 476 (let* ((base-map (make-sparse-keymap)) 477 (space-line (propertize "\n\n" 'face 'orgpan-spaceline)) 478 (arrow-face 'font-lock-keyword-face) 479 (L (propertize "left" 'face arrow-face)) 480 (R (propertize "right" 'face arrow-face)) 481 (U (propertize "up" 'face arrow-face)) 482 (D (propertize "down" 'face arrow-face))) 483 ;;(message D)(sit-for 2) 484 (define-key base-map [left] 'ignore) 485 (define-key base-map [right] 'ignore) 486 (define-key base-map [up] 'ignore) 487 (define-key base-map [down] 'ignore) 488 (define-key base-map [?q] 'delete-window) 489 (define-key base-map [??] 'orgpan-help) 490 ;; Navigating 491 (let ((map (copy-keymap base-map))) 492 (define-key map [left] 'outline-up-heading) 493 (define-key map [right] 'org-cycle) 494 (define-key map [up] 'outline-previous-visible-heading) 495 (define-key map [down] 'outline-next-visible-heading) 496 (define-key map [(shift down)] 'outline-forward-same-level) 497 (define-key map [(shift up)] 'outline-backward-same-level) 498 (orgpan-insert-field "Navigate" map (concat U "/" D ", " L ": Go to, " R ": Visibility"))) 499 (insert " ") 500 (let ((map (copy-keymap base-map))) 501 (define-key map [up] 'org-move-subtree-up) 502 (define-key map [down] 'org-move-subtree-down) 503 (define-key map [left] 'org-do-promote) 504 (define-key map [right] 'org-do-demote) 505 (define-key map [(shift left)] 'org-promote-subtree) 506 (define-key map [(shift right)] 'org-demote-subtree) 507 (orgpan-insert-field 508 "Restructure" map 509 (concat U "/" D ": " 510 (propertize "Move" 'face 'font-lock-warning-face) 511 ", " L "/" R ": " 512 (propertize "Level (w S: Subtree Level)" 'face 'font-lock-warning-face)))) 513 (insert " ") 514 (let ((map (copy-keymap base-map))) 515 (define-key map [up] 'org-priority-up) 516 (define-key map [down] 'org-priority-down) 517 (define-key map [right] 'org-todo) 518 (orgpan-insert-field "TODO/priority" map 519 (concat R ": TODO, " U "/" D ": Priority"))) 520 ) 521 (insert " ? for help, q quit\n") 522 (orgpan-display-bindings-help) 523 (setq orgpan-ovl-help (make-overlay (point) (point))) 524 )) 525 526 (defun orgpan-make-panel-buffer () 527 "Make the panel buffer." 528 (let* ((buf-name "*Org Panel*")) 529 (when orgpan-panel-buffer (kill-buffer orgpan-panel-buffer)) 530 (setq orgpan-panel-buffer (get-buffer-create buf-name)) 531 (if orgpan-panel-buttons 532 (orgpan-make-panel-with-buttons orgpan-panel-buffer) 533 (orgpan-make-panel-without-buttons orgpan-panel-buffer)) 534 (with-current-buffer orgpan-panel-buffer 535 (orgpan-mode) 536 (goto-char (point-min))) 537 orgpan-panel-buffer)) 538 539 (defun orgpan-help () 540 (interactive) 541 (set-keymap-parent orgpan-with-keymap nil) 542 (set-keymap-parent orgpan-without-keymap nil) 543 (describe-function 'orgpan-panel) 544 (set-keymap-parent orgpan-with-keymap org-mode-map) 545 (set-keymap-parent orgpan-without-keymap org-mode-map) 546 (message "Use 'l' to remove help window") 547 ) 548 549 (defun orgpan-panel () 550 "Create a control panel for current `org-mode' buffer. 551 The control panel may be used to quickly move around and change 552 the headings. The idea is that when you want to to a lot of this 553 kind of editing you should be able to do that with few 554 keystrokes (and without having to remember the complicated 555 keystrokes). A typical situation when this perhaps can be useful 556 is when you are looking at your notes file \(usually ~/.notes, 557 see `remember-data-file') where you have saved quick notes with 558 `remember'. 559 560 The keys below are defined in the panel. Note that the commands 561 are carried out in the `org-mode' buffer that belongs to the 562 panel. 563 564 \\{orgpan-mode-map} 565 566 In addition to the keys above most of the keys in `org-mode' can 567 also be used from the panel. 568 569 Note: There are two forms of the control panel, one with buttons 570 and one without. The default is without, see 571 `orgpan-panel-buttons'. If buttons are used choosing a different 572 button changes the binding of the arrow keys." 573 (interactive) 574 (unless (derived-mode-p 'org-mode) 575 (error "Buffer is not in org-mode")) 576 (orgpan-delete-panel) 577 (unless orgpan-org-mode-commands 578 (map-keymap (lambda (ev def) 579 (when (and def 580 (symbolp def) 581 (fboundp def)) 582 (setq orgpan-org-mode-commands 583 (cons def orgpan-org-mode-commands)))) 584 org-mode-map)) 585 ;;(org-back-to-heading) 586 ;;(remove-hook 'window-configuration-change-hook 'orgpan-window-config-change) 587 (setq orgpan-org-window (selected-window)) 588 (setq orgpan-panel-window (split-window nil -4 'below)) 589 (select-window orgpan-panel-window) 590 (set-window-buffer (selected-window) (orgpan-make-panel-buffer)) 591 ;;(set-window-dedicated-p (selected-window) t) 592 ;; The minor mode version starts here: 593 (when orgpan-minor-mode-version 594 (select-window orgpan-org-window) 595 (orgpan-panel-minor-mode 1) 596 (add-hook 'post-command-hook 'orgpan-minor-post-command t))) 597 598 (defun orgpan-minor-post-command () 599 (unless (and 600 ;; Check org window and buffer 601 (windowp orgpan-org-window) 602 (window-live-p orgpan-org-window) 603 (eq orgpan-org-window (selected-window)) 604 (derived-mode-p 'org-mode) 605 ;; Check panel window and buffer 606 (windowp orgpan-panel-window) 607 (window-live-p orgpan-panel-window) 608 (bufferp orgpan-panel-buffer) 609 (buffer-live-p orgpan-panel-buffer) 610 (eq (window-buffer orgpan-panel-window) orgpan-panel-buffer) 611 ;; Check minor mode 612 orgpan-panel-minor-mode) 613 (orgpan-delete-panel))) 614 615 (define-minor-mode orgpan-panel-minor-mode 616 "Minor mode used in `org-mode' buffer when showing panel." 617 :keymap orgpan-mode-map 618 :lighter " PANEL" 619 :group 'orgpan 620 ) 621 622 623 (provide 'org-panel) 624 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 625 626 ;;; org-panel.el ends here