From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Ehud Karni" Newsgroups: gmane.emacs.sources,gmane.emacs.help Subject: Re: M-x compile for different file extensions Date: Sun, 20 Oct 2002 02:00:11 +0200 Organization: Mivtach-Simon Insurance agencies Sender: gnu-emacs-sources-admin@gnu.org Message-ID: <200210200000.g9K00B5d021923@beta.mvs.co.il> References: Reply-To: ehud@unix.mvs.co.il NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-8 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1035072021 16970 80.91.224.249 (20 Oct 2002 00:00:21 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 00:00:21 +0000 (UTC) Cc: "Gnu Emacs help" , " Gnu Emacs source code" Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1833Vw-0004PK-00 for ; Sun, 20 Oct 2002 02:00:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 1833W7-00045G-00; Sat, 19 Oct 2002 20:00:27 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 1833VL-00033A-00 for gnu-emacs-sources@gnu.org; Sat, 19 Oct 2002 19:59:39 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 1833VH-0002vJ-00 for gnu-emacs-sources@gnu.org; Sat, 19 Oct 2002 19:59:38 -0400 Original-Received: from unix.simonwiesel.co.il ([192.114.178.12] helo=unix.mvs.co.il) by monty-python.gnu.org with esmtp (Exim 4.10) id 1833VC-0002uk-00; Sat, 19 Oct 2002 19:59:30 -0400 Original-Received: from beta.mvs.co.il (beta [10.253.0.3]) by unix.mvs.co.il (8.11.6/8.11.6) with ESMTP id g9JNxMh21375; Sun, 20 Oct 2002 01:59:22 +0200 Original-Received: from beta.mvs.co.il (localhost [127.0.0.1]) by beta.mvs.co.il (8.12.5/8.12.5) with ESMTP id g9K00Ded021929; Sun, 20 Oct 2002 02:00:13 +0200 Original-Received: (from ehud@localhost) by beta.mvs.co.il (8.12.5/8.12.5/Submit) id g9K00B5d021923; Sun, 20 Oct 2002 02:00:11 +0200 X-Authentication-Warning: beta.mvs.co.il: ehud set sender to ehud@unix.mvs.co.il using -f Original-To: wgh@askme.ok, " Henrik Enberg" In-reply-to: (message from wgh on Sat, 19 Oct 2002 17:41:34 GMT) X-Mailer: Emacs 21.2.1 rmail (send-msg 1.106) Errors-To: gnu-emacs-sources-admin@gnu.org X-BeenThere: gnu-emacs-sources@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: GNU Emacs source code postings and patches List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.sources:198 gmane.emacs.help:2764 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2764 On Sat, 19 Oct 2002 17:41:34 GMT, wgh wrote: > > Is there a way to have M-x compile to automatically detect > what command to use depending on the file extension of the > current buffer being edited? > > Because I don't really see the advantage of using M-x compile > if I can get away with fewer keystrokes in Bash doing the > exact same thing (i.e. typing the compile command, pressing > the up arrow if I need to recompile, etc.) I had the same need and I have written some functions to accomplish this. It was posted to emacs sources on 2002-07-22 but I never got any responses. Here is the updated version. I have enhanced the Emacs `compile' package with some commands. 1. Automatic selection of compile commands according to the file extension and DEBUG state. (defuns: `compile-main', `compile-sub', `compile-debug-toggle') 2. A command to change the list of extensions and associate compile commands dynamicly. (see help for `compile-ek') 3. A way to give 2 specific compilation commands (normal/debug) for the current edited file (`compile-ext-edit'). 4. An easy way to interact (send input to) with the compilation process (`compile-send-to-process'). 5. Run some commands with interactive input to them (when needed) in a compilation window, with an option to kill the compilation buffer. (`compile-commands', read the help carefully). 6. Please note that you can embed the compile command within the file (see help for `compile-ek') e.g. for a shell script you can add ## Compile by: /bin/sh -e $* arg1 arg2 ## Compile debug: /bin/sh -ex $* dbg1 dbg2 The ekcompl.el is listed below. Every one is encouraged to change it (especially the `compile-main-ext' and `compile-sub-ext' vars). Any comments and improvements are welcomed. To get it send an email to: auto_mail@unix.mvs.co.il. Subject: =22files=22 (one word, no quotes). 1st line of the content: =22ekcompl.el.gz=22 (one word, no quotes). The file will be then automaticly sent to the reply address. Ehud. ;; -*- mode: emacs-lisp; unibyte: t; -*- ;; ekcompl.el --- Automatic compilation commands ;; Copyright (C) 1992-2000 Ehud karni ;; This file is NOT part of GNU Emacs, distribution conditions below. ;; ;; EHUD KARNI =E9=F0=F8=F7 =E3=E5=E4=E0 ;; Ben Gurion st' 14 =EF=E5=E9=F8=E5=E2 =EF=E1 '=E7=F8 ;; Kfar - Sava 44 257 =E0=E1=F1 - =F8=F4=EB ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; 972-(0)9-7659599 ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ;; RCS: $Id: ekcompl.el,v 1.106 2000/05/08 16:10:24 ehud Exp $ ;; ;; $Log: ekcompl.el,v $ ;; Revision 1.106 2000/05/08 16:10:24 ehud ;; Added remote compilation option when called with prefix arg. The ;; `compile-remote-call' variable is the script name for executing remotly. ;; ;; Revision 1.105 2000/03/05 14:16:49 ehud ;; Comment headers changes (NOT GNU) + Other comments =3D=3D ONLY =3D=3D ;; ;; Revision 1.104 1998/03/15 17:12:33 ehud ;; Last revision for 19.34 ;; ;; Revision 1.103 1996/02/19 10:25:45 ehud ;; Emacs 19.30 version ;; ;; Revision 1.102 1995/09/20 17:10:46 ehud ;; rearrange of compile-ek (add compile-rplc-nm-ext), ;; make special I-A commands available (see commented compile-cob-fnx) ;; ;; Revision 1.101 1995/08/28 15:34:30 ehud ;; change of compile-ek: allow user to specify compilation in 1st 20 lines. ;; ;; Revision 1.100 1995/01/19 17:17:35 ehud ;; SW initial version control for all el's ;; 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;; The updated package can be got by email: ;; Send email to: auto_mail@unix.mvs.co.il. ;; Subject: =22files=22 (one word, no quotes). ;; 1st line of the content: =22ekcompl.el.gz=22 (one word, no quotes). ;; The file will be then automaticly sent to the reply address. (require 'compile) (defvar compile-debug nil =22*Debug indicator for compilations (nil=3Dnormal other=3Ddebug on)=22) (defvar compile-main-ext '((=22.c=22 =22ccn=22 =22ccdb=22) ; SW c (=22.ec=22 =22ccnsql=22 =22ccdbsql=22) ; SW c/informix ;; (=22.pc8=22 =22+MFcf=22 =22+MFcf-dbg=22) ;=3D=3D=3D=3D Micro Focus Cobol =3D=3D=3D=3D ;; (=22.pco=22 =22+MFcf=22 =22+MFcf-dbg=22) ;=3D=3D=3D=3D with Oracle preprocessing (=22.cbl=22 =22cobn=22 =22cobdb=22) ; SW Cobol (=22.eco=22 =22esqlcobol=22 =22cobsqldb=22) ; SW Cobol/informix (=22.f=22 =22ftn=22 =22ftndb=22) ; SW Fortran (=22.ef=22 =22ftnsql=22 =22ftndbsql=22) ; SW Fortran/informix (=22.el=22 =22+bcEL=22) ; emacs lisp (=22.lts=22 =22letcmp -lu=22 =22letcmp -u=22) ; SW letus (=22.pns=22 =22smfcmp -lo=22 =22smfcmp -o=22) ; SW screen formater (SMF) ) =22Extension list and commands for compilations of main programs=22) (defvar compile-sub-ext '((=22.c=22 =22ccsb=22 =22ccsbd=22) ; SW c (=22.ec=22 =22ccsbsql=22 =22ccsbdsql=22) ; SW c/informix (=22.cbl=22 =22cobsub=22 =22cobsubd=22) ; SW Cobol (=22.eco=22 =22cobsqlsub=22 =22cobsqlsubd=22) ; SW Cobol/informix (=22.f=22 =22ftsb=22 =22ftsbd=22)) ; SW Fortran =22Extension list and commands for compilations of sub-programs=22) (defvar compile-remote-call =22rem-call.sh=22 =22*command (usually a script) to run remote compilations=22) (defvar compile-hosts-list '(=22linux=22 =22aviion=22 =22sw-dbs=22) =22*Initial hosts list for remote compilations. This is a history list so it gets updated whenever the user choose a host.=22) (defvar compile-host =22linux=22 =22*host name for remote compilations=22) (defun compile-debug-toggle () =22Toggle the compile-debug variable (t / nil)=22 (interactive) (if compile-debug (progn (setq compile-debug nil) (message =22Normal compilation=22)) (progn (setq compile-debug 'DEBUG) (message =22Compilation with DEBUG=22)))) (defun compile-main (&optional remote) =22Save buffer and than Compile main program using the compile-main-ext which is (if not changed): shell script language ext normal debug MF Cobol .cbl cobn cobdb System C .c ccn ccdb GH Fortran 77 .f ftn ftndb Emacs Lisp .el byte-compile (no debug option) You can change the extension list by using M-x compile-ext-edit (or Alt-S-F5). To compile remotely use prefix argument. See help for `compile-ek' for ways to override the default compilation script. =22 (interactive =22P=22) (if remote (setq remote (compile-get-host))) (compile-ek compile-main-ext remote)) (defun compile-sub (&optional remote) =22Save buffer and than Compile sub-program using the compile-sub-ext which is (if not changed): shell script language ext normal debug MF Cobol .cbl cobsub cobsubd System C .c ccsb ccsbd GH Fortran 77 .f ftsb ftsdb You can change the extension list by using M-x compile-ext-edit (or Alt-S-F5). See help for `compile-ek' for ways to override the default compilation script. =22 (interactive =22P=22) (if remote (setq remote (compile-get-host))) (compile-ek compile-sub-ext remote)) (defun compile-get-host () =22Get host for remote compilation (default is `compile-host') and re-save. Empty string means compile locally and `compile-host' is preserved.=22 (let ((host (read-string =22Enter host for remote compilation (empty-locally): =22 compile-host 'compile-hosts-list))) (if (string-equal host =22=22) (setq host nil)) (and host (setq compile-host host)) host)) (defun compile-ek (EXT-LIST remote) =22Save buffer and Compile it using the script name that match the file extension (.xxxx) from EXT-LIST (1st name for normal, 2nd for debug). 2nd arg REMOTE is name of host for remote compilation or nil (local). If the extension is not found, display error message. The standard script may be changed by changing the standard extension list using `compile-ext-edit' (usually bound to [S-f25] - Shift-Alt-F5. A file can override the script assigned to it by its extension by having in its first 20 lines the string \=22Compile by: \=22 followed by the command (up to end of line) to perform Normal compilation, use the string \=22Compile debug: \=22 for Debug compilation. The command can include $* (replaced by the file name) and $@ (the file name without its extension). e.g. to use make to compile a program: Compile by: gmake -f $ap_sys/Nmake $@.exe Compile debug: gmake -f $ap_sys/makeDB $* =22 (let* (call-buf ;file name (absolute) (srch (if compile-debug =22debug=22 =22by=22)) p1 p2 ;temp vars (pos (point)) ;saved pos mxp ;max pos to search ) (if (eq major-mode 'dired-mode) ;in dired ? (setq call-buf (dired-get-filename)) ;yes, skip search in file (progn ;not dired (normal editing) (save-buffer 3) ;save this buffer (setq call-buf (buffer-file-name)) ;absolute file name (goto-char (point-min)) ;1st char/line (search-forward =22\n=22 nil 1 20) ;search line 20/end of buffer (setq mxp (point)) ;set as limit of search (goto-char (point-min)) (if (not (search-forward (concat =22Compile =22 srch =22: =22) mxp 'NOERROR)) ;search for =22Compile by/debug:=22 (goto-char pos) ; =22Compile by: =22 not found (progn ; extra insurance (setq mxp (point)) ; 1st char of compile command (end-of-line) ; last char of compile command (setq srch (buffer-substring mxp (point))) ;raw compile command (goto-char pos) ; Return to original position (setq EXT-LIST nil) ; no search for file extension (compile-ek-sub ; do compile with =22massaged=22 (compile-rplc-nm-ext srch) ; compile command remote 'NO-FILE) ; host/nil (no file name) ) ;end of =22Compile by:=22 processing ))) ; (while EXT-LIST ;EXT-LIST is nil if =22Compile by:=22 (setq p2 (car EXT-LIST)) ;p2=3D(=22ext=22 =22normal compile=22 =22debug=22) (setq EXT-LIST (cdr EXT-LIST)) ;rest of EXT-LIST (setq p1 (car p2)) ;p1=3D=22ext=22 (setq p2 (cdr p2)) ;p2=3D(=22normal compile=22 =22debug=22) (if (string=3D p1 ;p1=3D=22ext=22 (substring call-buf (- (length p1)))) ;is it =22ext=22 ? (progn ;yes, extension found (setq EXT-LIST nil) ;end loop ! (if compile-debug ;debug mode ? (setq p2 (cdr p2))) ;yes, p2=3D(=22debug compile command=22) (setq p1 (car p2)) ;p1=3D=22compile command=22 (if (and p1 (not (string=3D p1 =22=22))) ; not nil or empty string (progn (compile-ek-sub p1 remote) ; compile command and remote-host/nil (setq p1 nil)) (setq p1 t))))) (if p1 (message =22File (%s) - no command found for this extension. Error !=22 call-buf)))) (defun compile-rplc-nm-ext (cmd-in) (let ((flnm (file-name-nondirectory ; leave only file name (basename) (if (eq major-mode 'dired-mode) (dired-get-filename 'LOCAL 'NO-ERROR) ; the file on this line (dired) (buffer-file-name)))) ; this buffer file name cmd ; command is empty p1 p2 ;local vars (positions/chars) ) (setq cmd-in (concat cmd-in =22 =22)) ;add 2 spaces for safety (while (setq p1 (string-match =22\\$=22 cmd-in)) ; do for all $* & $@ in user command (setq p2 (aref cmd-in (1+ p1))) ; char after $ (cond ((=3D p2 ?*) ; replace $* by full file name (setq p2 flnm)) ((=3D p2 ?@) ; $@ replaced by file name (setq p2 (string-match =22\\.[^\\.]*$=22 flnm)) ;without extension (if p2 (setq p2 (substring flnm 0 p2)) ; omit extension (setq p2 flnm))) ; NO extension found (t (setq p2 (concat =22$=22 (char-to-string p2)))) ) ;end of cond (setq cmd (concat cmd (substring cmd-in 0 p1) p2)) (setq cmd-in (substring cmd-in (+ p1 2))) ) ;end of while (concat cmd cmd-in))) ;return command for shell execution (defun compile-ek-sub (cmd remote &optional no_file) =22Compile using CMD on host REMOTE (nil->locally). If optional NO_FILE do not add name of file=22 (require 'compile) (cond ((string=3D cmd =22+bcEL=22) ;special case - byte compile (byte-compile-file call-buf)); of Emacs Lisp ;; ;; ((string=3D cmd =22+MFcf=22) ;special case - Micro Focus ;; ;; (compile-cob-fnx compile-ek-arg)) ; Cobol for Phoenix (t (and remote (setq cmd (concat compile-remote-call =22 =22 remote =22 =22 cmd))) (or no_file (setq cmd (concat cmd =22 =22 (file-name-nondirectory call-buf)))) (compile-internal cmd =22 =3D=3D=3D No more compilation errors =3D=3D=3D=22 ;compile with cmd (concat =22 Compilation (by =22 cmd =22)=22))))) (defun compile-ext-edit () =22Edit compile-main-ext or compile-sub-ext=22 (interactive) (let ((ext-list) (ext) (p1) (p2)) (if (y-or-n-p =22Do you wand to change main (else sub) extension list? =22) (setq ext-list =22main=22) (setq ext-list =22sub=22)) (setq ext (read-string (concat =22Compile =22 ext-list =22 Extension: =22) =22=22)) (if (string=3D =22sub=22 ext-list) (setq p1 (included-car ext compile-sub-ext)) (setq p1 (included-car ext compile-main-ext))) (setq p2 (cdr p1)) (setq p1 (list ext (read-string (concat ext-list =22 Compile (normal) name: =22) (car p2)) (read-string (concat ext-list =22 Compile (debug) name: =22) (car (cdr p2))) )) ; end of setq p1 (if (equal '(=22=22 =22=22) (cdr p1)) (setq p1 (list ext))) ; no commands (delete) (compile-ext-rep ext-list p1))) (defun compile-ext-rep (TYPE EXTL) =22Replace (add) names of compilation scripts in extension list. The compilation TYPE is string - \=22sub\=22 or \=22main\=22. EXTL is list of 3 strings - (ext, nrml-proc, dbg-proc). e.g. To change the names for Cobol (extension .cbl) compiler scripts to cob_n (normal) and cob_dbg (debug) the EXTL should be: (\=22.cbl\=22 \=22cob_n\=22 \=22cob_dbg\=22)=22 (if (string=3D =22sub=22 TYPE) (setq compile-sub-ext (included-car-rep EXTL compile-sub-ext)) (setq compile-main-ext (included-car-rep EXTL compile-main-ext)))) (defun included-car (ELT LIST) =22Returns non-nil if ELT is an (car element) of LIST. Comparison done with equal. The value is the element whose car is ELT.=22 (if LIST (if (equal (car (car LIST)) ELT) (setq LIST (car LIST)) (included-car ELT (cdr LIST))))) (defun included-car-rep (NEW LIST) =22Replace (add/delete) element which its car equals the car of NEW in LIST. If not found add NEW, if the cdr of NEW is nil delete the found element. Comparison done with equal. The value is the new list.=22 (let ((p1 LIST) (p2 (car NEW)) p3 ) (setq LIST nil) (while p1 (progn (setq p3 (car p1)) (if (equal (car p3) p2) (progn (if (cdr NEW) (setq LIST (append LIST (list NEW)))) (setq NEW nil)) (setq LIST (append LIST (list p3)))) (setq p1 (cdr p1)))) (setq LIST (append LIST (if (cdr NEW) (list NEW)))))) ;; example of special interactive compilation command ;; ;;(defvar compile-fnx-number 1 =22Default TARGET for Phoenix MF cobol (see help for `compile-cob-fnx')=22) ;; ;;(defun compile-cob-fnx (&optional arg) ;; =22Compile MF Cobol with Oracle preprocessor (by gmake). ;;You can have the following targets: ;; 0 - .int (interpreter code run by rts or anim) ;; 1 - .gnt (native code run by rts or anim) ;; 2 - .o (object code for ld loader) ;; 3 - .exe (staticly linked executable program) ;; 9 - `tst' - pre compiler only (omit `at DB')=22 ;; (interactive =22P=22) ;; (or arg ;; (save-window-excursion ;; (describe-function 'compile-cob-fnx) ;; (setq arg (string-to-int (read-string ;; =22Enter new TARGET for this compilation =22 (format =22%s=22 compile-fnx-number)))) ;; (kill-buffer =22*Help*=22))) ;; (cond ;; ((=3D arg 0) ;; (setq arg =22int=22)) ;; ((=3D arg 1) ;; (setq arg =22gnt=22)) ;; ((=3D arg 2) ;; (setq arg =22o=22)) ;; ((=3D arg 3) ;; (setq arg =22exe=22)) ;; ((=3D arg 9) ;; (setq arg =22tst=22)) ;; (t ;; (error =22arg to compile-cob-fnx is not 0-3 or 9.=22))) ;; (compile-ek-sub (compile-rplc-nm-ext (concat =22oracob $@ =22 arg)) t)) (defun compile-commands (cmds &optional name rptkl) =22Perform several shell commands using the `compile-internal' function. Parameters: CMDS and optional NAME REPEAT and NOKILL. The CMDS parameter is a list of conses. Each is made of a string & a number. The string is the command to execute (sent to the compile process), the number is the time in seconds to wait before sending the next command. The commands are sent as is (no \\n added !), add \\n if you need it. No echo of the commands is seen! You can use it to send passwords too. The subshell run is always \=22/bin/sh -i\=22. The optional parameter NAME is the process buffer name, (def: \=22*sub-shell*\=22). The optional parameter RPTKL has 3 possible values: nil (omitted) means no further actions, t causes the last command in CMDS to be sent repeatedly (once per second) until the subshell exits and then kills the subshell buffer, other value of RPTKL waits for the end of the subshell and than kills its buffer. e.g. CMDS value to login as another user & execute cmnd-1. '((\=22su ouser\\n\=22 3) (\=22passwd\\n\=22 2) (\=22cmd1\\n\=22 1) (\=22exit\\n\=22 0))=22 (interactive) (require 'compile) (let (pbuf ;; compilation buffer str ;; current command tm ;; time to wait ) (or (and name (stringp name)) (setq name =22*sub-shell*=22)) ;; user name for this sub shell (setq pbuf (compile-internal =22exec /bin/sh -i=22 =22End of sub shell=22 name )) (set-buffer pbuf) ;; working buffer (pop-to-buffer pbuf 'OTHER) ;; make it visible (preferably in OTHER-WINDOW) (while cmds ;; commands list of conses (setq str (car cmds)) ;; 1st command cons (setq cmds (cdr cmds)) ;; rest of commands (setq tm (nth 1 str)) ;; seconds to wait (setq str (car str)) ;; command to send (process-send-string pbuf str) ;; send this command (accept-process-output) ;; accept output (if (> tm 0) ;; time to wait > 0 ? (sit-for tm)) ;; wait tm seconds (goto-char (point-max)) ;; put cursor at the end ) (if rptkl ;; wait only if rptkl non nil (while (get-buffer-process pbuf) ;; while process is alive (if (eq rptkl t) ;; send only for t (process-send-string pbuf str)) ;; send command to process (accept-process-output) ;; accept output (sit-for 1))) ;; wait 1 sec & redispaly buffer (if rptkl (kill-buffer pbuf)))) (let ((lmap '(compilation-minor-mode-map compilation-mode-map)) map) (require 'compile) ;; you can change the keys ONLY after 'compile is loaded (while lmap ;; do for all compile.el maps (setq map (car lmap)) ;; current map (setq lmap (cdr lmap)) ;; rest of maps (define-key (symbol-value map) [mouse-3] 'compile-mouse-goto-error) (define-key (symbol-value map) =22\C-a=22 'compile-send-to-process) (define-key (symbol-value map) =22\C-n=22 'compile-send-to-process-nl))) (defun compile-send-to-process-nl (&optional str) =22Send STR (string) with \\n appended to process associated with this buffer.=22 (interactive) (compile-send-to-process str 'NEW-LINE)) ;; send with new line (defun compile-send-to-process (&optional str nl) =22Send STR (string) to process associated with this buffer. If 2nd optional parameter NL is non nil, append \\n to the string.=22 (interactive) (let* ((cbuf (current-buffer)) ;; current buffer (cprc (get-buffer-process cbuf))) ;; current process or nil (if (null cprc) ;; error if no process (error =22No process associated to this buffer=22)) (or (and str ;; check for existence of (stringp str)) ;; command (must be string) (setq str ;; NOT SO, read from user (read-from-minibuffer =22String to send: =22)) ) ;; end of string check (if nl ;; new line requested ? (setq str (concat str =22\n=22))) ;; yes, add it (goto-char (point-max)) ;; put string in process (insert-string str) ;; buffer at the end (set-marker (process-mark cprc) (point));; for 'accept-process-output (process-send-string cprc str) ;; NOW, send command )) ;; end of defun ;; reg-exp for /bin/sh errors (add-to-list 'compilation-error-regexp-alist '(=22\\([^+][^:\n]+\\): line \\([0-9]+\\): =22 1 2)) (provide 'ekcompl) ;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ekcompl.el ends here =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -- Ehud Karni Tel: +972-3-7966-561 /=22\ Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ mailto:ehud@unix.mvs.co.il Better Safe Than Sorry