From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Decebal Newsgroups: gmane.emacs.help Subject: Re: Making callable function of a macro Date: Tue, 30 Sep 2008 02:04:28 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <19cc8ee3-7dbc-47ac-bee9-bf233b42a0eb@j22g2000hsf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1222767822 23962 80.91.229.12 (30 Sep 2008 09:43:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Sep 2008 09:43:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 30 11:44:40 2008 connect(): Connection refused 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 1KkbmN-0008PD-Mo for geh-help-gnu-emacs@m.gmane.org; Tue, 30 Sep 2008 11:44:28 +0200 Original-Received: from localhost ([127.0.0.1]:45167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkblK-0005oR-VM for geh-help-gnu-emacs@m.gmane.org; Tue, 30 Sep 2008 05:43:23 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!e53g2000hsa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 94 Original-NNTP-Posting-Host: 80.79.97.145 Original-X-Trace: posting.google.com 1222765468 17369 127.0.0.1 (30 Sep 2008 09:04:28 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 30 Sep 2008 09:04:28 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e53g2000hsa.googlegroups.com; posting-host=80.79.97.145; posting-account=K-cdeAoAAAD_0d505kUtHXJaT5LFIu-3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 proxy-26:8080 (squid/2.5.STABLE8) Original-Xref: news.stanford.edu gnu.emacs.help:162882 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:58223 Archived-At: On 25 sep, 09:07, Decebal wrote: > I made the following macro to process some files: > ##### > Macro: > > ESC < =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; beginning-of-buff= er > C-SPC =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; set-mark-command > ESC C-s =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; isearch-forward-regexp > ^ =3D =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command * 2 > RET =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; newline > C-a =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; beginning-of-line > 2*C-n =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; next-line > C-w =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; kill-region > ESC > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; end-of-buffer > C-SPC =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; set-mark-command > ESC < =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; beginning-of-buff= er > ESC C-s =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; isearch-forward-regexp > ^ =3D =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command * 2 > RET =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; newline > C-a =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; beginning-of-line > C-w =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; kill-region > ESC < =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; beginning-of-buff= er > ESC C-% =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; query-replace-regexp > C-q =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; quoted-insert > LFD =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; newline-and-indent > ESC 5 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; digit-argument > SPC =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command > RET =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; newline > C-q =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; quoted-insert > TAB =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; indent-relative > RET =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; newline > ! =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command > ESC < =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; beginning-of-buff= er > RET =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; newline > C-p =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; previous-line > Probleem =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; self-insert-command * 8 > C-q =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; quoted-insert > TAB =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; indent-relative > Referentie =A0 =A0 =A0 =A0 =A0 =A0 =A0;; self-insert-command * 10 > C-q =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; quoted-insert > TAB =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; indent-relative > Oplossing =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; self-insert-command * 9 > C-a =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; beginning-of-line > ##### > > Now other people like the functionality that I made. ;-} > But they do not use Emacs. So I would like to change the macro to a > function. In this way the script that is used to generate the input > files, could call Emacs and process them directly. Is this possible? I have done it. I made the following script: ##### (defun do-make-tab-seperated-file () (re-search-forward "^=3D" nil nil) (forward-line 2) (delete-region (point-min) (point)) (re-search-forward "^=3D" nil nil) (beginning-of-line) (delete-region (point) (point-max)) (goto-char (point-min)) (insert "Problem\tReferentie\tOplossing\n") (while (re-search-forward "\n " nil t) (replace-match "\t") ) ) (defun make-tab-seperated-file (input-file output-file) (find-file input-file) (if (search-forward "No problems detected" nil t) (no-problems) (do-make-tab-seperated-file) ) (write-file output-file) ) (defun no-problems () (erase-buffer) (insert "Geen problemen gevonden") ) ##### And I call it with: emacs -batch -nw -l ~/bin/makeTabSeperated.el --eval=3D"(make-tab- seperated-file \"${OUTPUTDIR}/${base}${EXTENSION2}\" \"${base}$ {EXTENSION3}\")" 2>/dev/null The '2>/dev/null' is needed because emacs sends a lot of output to stderr. Is there a way to circumvent this? I would prefer to have the possibility to use stderr in my scripts. If those get drowned in the output of Emacs itself, it is not going to work.