From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Newsgroups: gmane.emacs.help Subject: Re: emacs equivalent of vi % Date: Fri, 15 Aug 2008 12:13:29 -0700 (PDT) Organization: http://groups.google.com Message-ID: <18b791f9-e4ad-421e-95b1-529d746b38b8@b30g2000prf.googlegroups.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1218829294 29130 80.91.229.12 (15 Aug 2008 19:41:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Aug 2008 19:41:34 +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 21:42:26 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 1KU5Bn-00064A-9b for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Aug 2008 21:42:23 +0200 Original-Received: from localhost ([127.0.0.1]:43027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KU5Aq-0003KH-Pc for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Aug 2008 15:41:24 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!b30g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 85 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1218827609 9889 127.0.0.1 (15 Aug 2008 19:13:29 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 15 Aug 2008 19:13:29 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b30g2000prf.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:161341 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:56685 Archived-At: On Aug 15, 10:02 am, Emmett Grogan wrote: > 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 =E2=80=9Cperl x.pl=E2=80=9D 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 O, thank you. The code i did could use some improvement. Right now it doesn't run in the background. i.e. while it executes, your emacs is as good as frozen. I meant to make it a background process... but there's more coding needs to be done to get the outpt when it is done using some elisp's =E2=80=9Cprocess sentinel=E2=80=9D... also, the hard-coded file name suffix and program name map could perhaps employ magic-mode-alist and or auto-mode-alist... anyone's very welcome to fork it of course. Xah =E2=88=91 http://xahlee.org/ =E2=98=84