1 ;;; org-screen.el --- Integreate Org-mode with screen.
3 ;; Copyright (c) 2008-2014 Andrew Hyatt
5 ;; Author: Andrew Hyatt <ahyatt at gmail dot com>
6 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
8 ;; This file is not yet part of GNU Emacs.
10 ;; This program 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)
15 ;; This program 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. If not, see <http://www.gnu.org/licenses/>.
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;; This file contains functionality to integrate screen and org-mode.
27 ;; When using org-mode, it is often useful to take tasks that have
28 ;; some command-line work associated with them, and associate them
29 ;; with a screen session. Screen is used rather than a direct
30 ;; terminal to facilitate portability of the resulting session.
32 ;; To use screen in org, in your .emacs file, simply put this file in
33 ;; a directory in your load-path and write:
35 ;; (require 'org-screen)
37 ;; When have a task and want to start some command-line activity
38 ;; associated with that task, go to the end of your item and type:
42 ;; This will prompt you for a name of a screen session. Type in a
43 ;; name and it will insert a link into your org file at your current
46 ;; When you want to visit the link, go to the link and type C-c C-o to
49 ;; You may want to get rid of the constant queries about whether you
50 ;; really want to execute lisp code. Do so by adding to your .emacs:
52 ;; (setq org-confirm-elisp-link-function nil)
57 (defcustom org-screen-program-name
"/usr/bin/screen"
58 "Full location of the screen executable."
62 (defun org-screen (name)
63 "Start a screen session with name"
64 (interactive "MScreen name: ")
66 (org-screen-helper name
"-S"))
67 (insert-string (concat "[[screen:" name
"]]")))
69 (defun org-screen-buffer-name (name)
70 "Returns the buffer name corresponding to the screen name given."
71 (concat "*screen " name
"*"))
73 (defun org-screen-helper (name arg
)
74 "This method will create a screen session with a specified name
75 and taking the specified screen arguments. Much of this function
76 is copied from ansi-term method."
78 ;; Pick the name of the new buffer.
79 (let ((term-ansi-buffer-name
80 (generate-new-buffer-name
81 (org-screen-buffer-name name
))))
82 (setq term-ansi-buffer-name
84 term-ansi-buffer-name org-screen-program-name nil arg name
))
85 (set-buffer term-ansi-buffer-name
)
88 (term-set-escape-char ?\C-x
)
89 term-ansi-buffer-name
))
91 (defun org-screen-goto (name)
92 "Open the screen with the specified name in the window"
93 (interactive "MScreen name: ")
94 (let ((screen-buffer-name (org-screen-buffer-name name
)))
95 (if (member screen-buffer-name
96 (mapcar 'buffer-name
(buffer-list)))
97 (org-pop-to-buffer-same-window screen-buffer-name
)
98 (org-pop-to-buffer-same-window (org-screen-helper name
"-dr")))))
100 (if org-link-abbrev-alist
101 (add-to-list 'org-link-abbrev-alist
102 '("screen" .
"elisp:(org-screen-goto \"%s\")"))
103 (setq org-link-abbrev-alist
104 '(("screen" .
"elisp:(org-screen-goto \"%s\")"))))
106 (provide 'org-screen
)