ox-html.el (org-html-display-buffer-mode): New option
[org-mode.git] / contrib / lisp / org-screen.el
blob96c21212222349ac924a44e75eb9d2d6afd05eee
1 ;;; org-screen.el --- Integreate Org-mode with screen.
3 ;; Copyright (c) 2008-2013 Andrew Hyatt
4 ;;
5 ;; Author: Andrew Hyatt <ahyatt at gmail dot com>
6 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
7 ;;
8 ;; This file is not yet part of GNU Emacs.
9 ;;
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;;; Commentary:
28 ;; This file contains functionality to integrate screen and org-mode.
29 ;; When using org-mode, it is often useful to take tasks that have
30 ;; some command-line work associated with them, and associate them
31 ;; with a screen session. Screen is used rather than a direct
32 ;; terminal to facilitate portability of the resulting session.
34 ;; To use screen in org, in your .emacs file, simply put this file in
35 ;; a directory in your load-path and write:
37 ;; (require 'org-screen)
39 ;; When have a task and want to start some command-line activity
40 ;; associated with that task, go to the end of your item and type:
42 ;; M-x org-screen
44 ;; This will prompt you for a name of a screen session. Type in a
45 ;; name and it will insert a link into your org file at your current
46 ;; location.
48 ;; When you want to visit the link, go to the link and type C-c C-o to
49 ;; open the link.
51 ;; You may want to get rid of the constant queries about whether you
52 ;; really want to execute lisp code. Do so by adding to your .emacs:
54 ;; (setq org-confirm-elisp-link-function nil)
56 (require 'term)
57 (require 'org)
59 (defcustom org-screen-program-name "/usr/bin/screen"
60 "Full location of the screen executable."
61 :group 'org-screen
62 :type 'string)
64 (defun org-screen (name)
65 "Start a screen session with name"
66 (interactive "MScreen name: ")
67 (save-excursion
68 (org-screen-helper name "-S"))
69 (insert-string (concat "[[screen:" name "]]")))
71 (defun org-screen-buffer-name (name)
72 "Returns the buffer name corresponding to the screen name given."
73 (concat "*screen " name "*"))
75 (defun org-screen-helper (name arg)
76 "This method will create a screen session with a specified name
77 and taking the specified screen arguments. Much of this function
78 is copied from ansi-term method."
80 ;; Pick the name of the new buffer.
81 (let ((term-ansi-buffer-name
82 (generate-new-buffer-name
83 (org-screen-buffer-name name))))
84 (setq term-ansi-buffer-name
85 (term-ansi-make-term
86 term-ansi-buffer-name org-screen-program-name nil arg name))
87 (set-buffer term-ansi-buffer-name)
88 (term-mode)
89 (term-char-mode)
90 (term-set-escape-char ?\C-x)
91 term-ansi-buffer-name))
93 (defun org-screen-goto (name)
94 "Open the screen with the specified name in the window"
95 (interactive "MScreen name: ")
96 (let ((screen-buffer-name (org-screen-buffer-name name)))
97 (if (member screen-buffer-name
98 (mapcar 'buffer-name (buffer-list)))
99 (org-pop-to-buffer-same-window screen-buffer-name)
100 (org-pop-to-buffer-same-window (org-screen-helper name "-dr")))))
102 (if org-link-abbrev-alist
103 (add-to-list 'org-link-abbrev-alist
104 '("screen" . "elisp:(org-screen-goto \"%s\")"))
105 (setq org-link-abbrev-alist
106 '(("screen" . "elisp:(org-screen-goto \"%s\")"))))
108 (provide 'org-screen)