From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Hinsen Subject: orgmode add-on that implements links to eshell buffers Date: Mon, 3 Jan 2011 13:07:36 +0100 Message-ID: <9064DFD4-95F5-45F4-9F55-F92D03FC1B68@fastmail.net> Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: multipart/mixed; boundary=Apple-Mail-10-69160585 Return-path: Received: from [140.186.70.92] (port=50459 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZjCA-0002Co-I6 for emacs-orgmode@gnu.org; Mon, 03 Jan 2011 07:07:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZjC8-0004t2-UH for emacs-orgmode@gnu.org; Mon, 03 Jan 2011 07:07:26 -0500 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:46182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZjC8-0004sZ-Qn for emacs-orgmode@gnu.org; Mon, 03 Jan 2011 07:07:24 -0500 Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id E9DBF409 for ; Mon, 3 Jan 2011 07:07:22 -0500 (EST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --Apple-Mail-10-69160585 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii The attached file implements a new link type "eshell". An eshell link = consists of an optional buffer name followed by a colon, and of an = eshell command line. Opening the link switches to the indicated buffer, = creating it if necessary, or to the default *eshell* buffer, and = executes the command line exactly as if it were entered from the = keyboard. Inside an eshell buffer, org-store-link stores a link that = switches back to the same buffer and does a cd to the current working = directory. I'd be happy to contribute this file to org-mode if there is interest. Konrad. --Apple-Mail-10-69160585 Content-Disposition: attachment; filename=org-eshell.el Content-Type: application/octet-stream; name="org-eshell.el" Content-Transfer-Encoding: 7bit ;;; org-eshell.el - Support for links to working directories in eshell ;; Copyright (C) 2011 Free Software Foundation, Inc. ;; ;; Author: Konrad Hinsen ;; Version: 0.1 ;; ;; This file is not part of GNU Emacs. ;; ;; Emacs 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 3, or (at your option) ;; any later version. ;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'org) (require 'eshell) (require 'esh-mode) (org-add-link-type "eshell" 'org-eshell-open) (add-hook 'org-store-link-functions 'org-eshell-store-link) (defun org-eshell-open (link) "Switch to am eshell buffer and execute a command line. The link can be just a command line (executed in the default eshell buffer) or a command line prefixed by a buffer name followed by a colon." (let* ((buffer-and-command (if (string-match "\\([A-Za-z0-9-+*]+\\):\\(.*\\)" link) (list (match-string 1 link) (match-string 2 link)) (list eshell-buffer-name link))) (eshell-buffer-name (car buffer-and-command)) (command (cadr buffer-and-command))) (if (get-buffer eshell-buffer-name) (switch-to-buffer eshell-buffer-name) (eshell)) (end-of-buffer) (eshell-kill-input) (insert command) (eshell-send-input))) (defun org-eshell-store-link () "Store a link that, when opened, switches back to the current eshell buffer and the current working directory." (when (eq major-mode 'eshell-mode) (let* ((command (concat "cd " dired-directory)) (link (concat (buffer-name) ":" command))) (org-store-link-props :link (org-make-link "eshell:" link) :description command)))) (provide 'org-eshell) ;;; org-eshell.el ends here --Apple-Mail-10-69160585 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --Apple-Mail-10-69160585--