Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 66 lines (51 sloc) 2.243 kb
479bbfd @railwaycat update to emacs 24.0.94 with mac 2.90
authored
1 ;;; org-eshell.el - Support for links to working directories in eshell
2
6c29c6a @railwaycat emacs-24.4.90 with emacs-24.4.90-mac-5.4
authored
3 ;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
479bbfd @railwaycat update to emacs 24.0.94 with mac 2.90
authored
4
5 ;; Author: Konrad Hinsen <konrad.hinsen AT fastmail.net>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;;; Code:
25
26 (require 'org)
27 (require 'eshell)
28 (require 'esh-mode)
29
30 (org-add-link-type "eshell" 'org-eshell-open)
31 (add-hook 'org-store-link-functions 'org-eshell-store-link)
32
33 (defun org-eshell-open (link)
34 "Switch to am eshell buffer and execute a command line.
35 The link can be just a command line (executed in the default
36 eshell buffer) or a command line prefixed by a buffer name
37 followed by a colon."
38 (let* ((buffer-and-command
39 (if (string-match "\\([A-Za-z0-9-+*]+\\):\\(.*\\)" link)
70089e3 @railwaycat Emacs 24.2.90 with emacs-24.2.90-mac-3.90
authored
40 (list (match-string 1 link)
41 (match-string 2 link))
479bbfd @railwaycat update to emacs 24.0.94 with mac 2.90
authored
42 (list eshell-buffer-name link)))
43 (eshell-buffer-name (car buffer-and-command))
44 (command (cadr buffer-and-command)))
70089e3 @railwaycat Emacs 24.2.90 with emacs-24.2.90-mac-3.90
authored
45 (if (get-buffer eshell-buffer-name)
46 (org-pop-to-buffer-same-window eshell-buffer-name)
47 (eshell))
48 (goto-char (point-max))
49 (eshell-kill-input)
50 (insert command)
51 (eshell-send-input)))
479bbfd @railwaycat update to emacs 24.0.94 with mac 2.90
authored
52
53 (defun org-eshell-store-link ()
54 "Store a link that, when opened, switches back to the current eshell buffer
55 and the current working directory."
56 (when (eq major-mode 'eshell-mode)
57 (let* ((command (concat "cd " dired-directory))
58 (link (concat (buffer-name) ":" command)))
59 (org-store-link-props
70089e3 @railwaycat Emacs 24.2.90 with emacs-24.2.90-mac-3.90
authored
60 :link (concat "eshell:" link)
479bbfd @railwaycat update to emacs 24.0.94 with mac 2.90
authored
61 :description command))))
62
63 (provide 'org-eshell)
64
65 ;;; org-eshell.el ends here
Something went wrong with that request. Please try again.