From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emmett Grogan Newsgroups: gmane.emacs.help Subject: Re: emacs equivalent of vi % Date: Fri, 15 Aug 2008 19:02:54 +0200 Message-ID: <48A5B6BE.9040105@freenet.de> Reply-To: emmettgrogan@freenet.de NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1218819952 32281 80.91.229.12 (15 Aug 2008 17:05:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Aug 2008 17:05:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 15 19:06:44 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KU2ko-0007P4-Pj for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Aug 2008 19:06:23 +0200 Original-Received: from localhost ([127.0.0.1]:54226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KU2js-0005Ar-2y for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Aug 2008 13:05:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KU2hg-0003uZ-1A for help-gnu-emacs@gnu.org; Fri, 15 Aug 2008 13:03:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KU2hd-0003sr-QO for help-gnu-emacs@gnu.org; Fri, 15 Aug 2008 13:03:07 -0400 Original-Received: from [199.232.76.173] (port=49998 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KU2hd-0003si-MH for help-gnu-emacs@gnu.org; Fri, 15 Aug 2008 13:03:05 -0400 Original-Received: from mout3.freenet.de ([195.4.92.93]:58752) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KU2hd-0001vA-4J for help-gnu-emacs@gnu.org; Fri, 15 Aug 2008 13:03:05 -0400 Original-Received: from [195.4.92.15] (helo=5.mx.freenet.de) by mout3.freenet.de with esmtpa (ID emmettgrogan@freenet.de) (port 25) (Exim 4.69 #19) id 1KU2ha-0008KW-Pa for help-gnu-emacs@gnu.org; Fri, 15 Aug 2008 19:03:02 +0200 Original-Received: from p57a7a00b.dip0.t-ipconnect.de ([87.167.160.11]:35153 helo=mx.freenet.de) by 5.mx.freenet.de with esmtpa (ID emmettgrogan@freenet.de) (port 25) (Exim 4.69 #12) id 1KU2hZ-0000rG-Ki for help-gnu-emacs@gnu.org; Fri, 15 Aug 2008 19:03:02 +0200 User-Agent: Thunderbird 2.0.0.16 (X11/20080724) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56678 Archived-At: Xah: > This code will run the current file: > > (defun run-current-file () > "Execute or compile the current file.... > I assembled a elisp module out of it. In case someone is interested: ;; Version: $Id: run-current-file.el 4518 2008-08-13 21:31:36Z emmettgrogan $ ;; ;; This program 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 2, or (at your option) ;; any later version. ;; ;; This program 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 this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;; ;; Commentary: ;; ;; Original author: Xah Lee ;;; Adapted from http://xahlee.org/emacs/elisp_run_current_file.html ;; ;;; Code: ;; ;;;###autoload ;;; (defgroup run-current-file-menu nil "Execute or compile the current file.") ;; (defcustom run-current-file-name-masks '( ("php" . "php") ("pl" . "perl") ("py" . "python") ("sh" . "bash") ("java" . "javac") ) "Filename extensions that switch on run-current-file.") ;; (defun run-current-file () "Execute or compile the current file. For example, if the current buffer is the file x.pl, then it'll call “perl x.pl” in a shell. The file can be php, perl, python, bash, java. File suffix is used to determine what program to run." (interactive) (let (run-current-file-name-masks file-name file-ext prog-name cmd-str) ; get the file name ; get the program name ; run it (setq file-name (buffer-file-name)) (setq file-ext (file-name-extension file-name)) (setq prog-name (cdr (assoc file-ext run-current-file-name-masks))) (setq cmd-str (concat prog-name " " file-name)) (shell-command cmd-str)) ) ;; (provide 'run-current-file) ;;; (run-current-file) ends here