all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* End of file during parsing?
@ 2005-04-10 20:12 Rui Tiago Matos
  2005-04-10 23:37 ` Peter Dyballa
  0 siblings, 1 reply; 5+ messages in thread
From: Rui Tiago Matos @ 2005-04-10 20:12 UTC (permalink / raw)


I hacked up a bash function [1] to open some files in different
frames. It works great after emacs is running. Otherwise it doesn't:
it opens up emacs but I get:

command-line-1: End of file during parsing

Now, this is very strange because if I use --eval=... from the command
line directly it works as expected. Anyone has an idea about why this
doesn't work?

[1]
emacs () 
{ 
    if [ -z "$DISPLAY" ]; then
        emacs21 $@;
    else
        if [ ! "`/bin/ps -U $UID | grep emacs`" ]; then
            local CMDLINE="--eval=";
            local FILE;
            for FILE in $*;
            do
                if ( grep ^/ <<< $FILE ) || ( grep ^~ <<< $FILE ); then
                    CMDLINE="$CMDLINE(find-file-other-frame \"$FILE\")";
                else
                    CMDLINE="$CMDLINE(find-file-other-frame \"$PWD/$FILE\")";
                fi;
            done;
            if [ "$CMDLINE" != "--eval=" ]; then
                emacs21 $CMDLINE &
            else
                emacs21 &
            fi;
        else
            local CMDLINE="-q";
            local FILE;
            for FILE in $*;
            do
                if ( grep ^/ <<< $FILE ) || ( grep ^~ <<< $FILE ); then
                    CMDLINE="$CMDLINE (find-file-other-frame \"$FILE\")";
                else
                    CMDLINE="$CMDLINE (find-file-other-frame \"$PWD/$FILE\")";
                fi;
            done;
            if [ "$CMDLINE" != "-q" ]; then
                gnudoit $CMDLINE;
            fi;
        fi;
    fi
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: End of file during parsing?
  2005-04-10 20:12 End of file during parsing? Rui Tiago Matos
@ 2005-04-10 23:37 ` Peter Dyballa
  2005-04-10 23:47   ` Rui Tiago Matos
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Dyballa @ 2005-04-10 23:37 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 10.04.2005 um 22:12 schrieb Rui Tiago Matos:

> emacs ()
>

How does bash distinguish between the shell function emacs and the 
binary emacs?

--
Greetings

   Pete

"Computers are good at following instructions,
but not at reading your mind."
D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: End of file during parsing?
  2005-04-10 23:37 ` Peter Dyballa
@ 2005-04-10 23:47   ` Rui Tiago Matos
  0 siblings, 0 replies; 5+ messages in thread
From: Rui Tiago Matos @ 2005-04-10 23:47 UTC (permalink / raw)


On Apr 11, 2005 12:37 AM, Peter Dyballa <Peter_Dyballa@web.de> wrote:
> How does bash distinguish between the shell function emacs and the
> binary emacs?

It doesn't, but that is intended :-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: End of file during parsing?
       [not found] <mailman.1001.1113162562.2895.help-gnu-emacs@gnu.org>
@ 2005-04-11  3:39 ` Barry Margolin
  2005-04-11 21:59   ` Rui Tiago Matos
  0 siblings, 1 reply; 5+ messages in thread
From: Barry Margolin @ 2005-04-11  3:39 UTC (permalink / raw)


In article <mailman.1001.1113162562.2895.help-gnu-emacs@gnu.org>,
 Rui Tiago Matos <tiagomatos@gmail.com> wrote:

> I hacked up a bash function [1] to open some files in different
> frames. It works great after emacs is running. Otherwise it doesn't:
> it opens up emacs but I get:
> 
> command-line-1: End of file during parsing
> 
> Now, this is very strange because if I use --eval=... from the command
> line directly it works as expected. Anyone has an idea about why this
> doesn't work?

Try changing the command line that invokes emacs in that case to:

emacs21 "$CMDLINE"

The problem is that the shell is splitting the arguments at the spaces 
when you don't quote it.  So the argument that emacs is seeing is:

  --eval=(find-file-other frame

> 
> [1]
> emacs () 
> { 
>     if [ -z "$DISPLAY" ]; then
>         emacs21 $@;
>     else
>         if [ ! "`/bin/ps -U $UID | grep emacs`" ]; then
>             local CMDLINE="--eval=";
>             local FILE;
>             for FILE in $*;
>             do
>                 if ( grep ^/ <<< $FILE ) || ( grep ^~ <<< $FILE ); then
>                     CMDLINE="$CMDLINE(find-file-other-frame \"$FILE\")";
>                 else
>                     CMDLINE="$CMDLINE(find-file-other-frame \"$PWD/$FILE\")";
>                 fi;
>             done;
>             if [ "$CMDLINE" != "--eval=" ]; then
>                 emacs21 $CMDLINE &
>             else
>                 emacs21 &
>             fi;
>         else
>             local CMDLINE="-q";
>             local FILE;
>             for FILE in $*;
>             do
>                 if ( grep ^/ <<< $FILE ) || ( grep ^~ <<< $FILE ); then
>                     CMDLINE="$CMDLINE (find-file-other-frame \"$FILE\")";
>                 else
>                     CMDLINE="$CMDLINE (find-file-other-frame \"$PWD/$FILE\")";
>                 fi;
>             done;
>             if [ "$CMDLINE" != "-q" ]; then
>                 gnudoit $CMDLINE;
>             fi;
>         fi;
>     fi
> }

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: End of file during parsing?
  2005-04-11  3:39 ` Barry Margolin
@ 2005-04-11 21:59   ` Rui Tiago Matos
  0 siblings, 0 replies; 5+ messages in thread
From: Rui Tiago Matos @ 2005-04-11 21:59 UTC (permalink / raw)


On Apr 11, 2005 4:39 AM, Barry Margolin <barmar@alum.mit.edu> wrote:
> Try changing the command line that invokes emacs in that case to:
> 
> emacs21 "$CMDLINE"

Indeed that works, thanks!

Yet it only solved only part of the problem as I still continued to
have some problems but finally I've come to a solution and I can
finally edit multiple files smoothly :-) FWIW here is the final
version:

emacs () 
{ 
    if [ -z "$DISPLAY" ]; then
        emacs21 "$@";
    else
        if [ ! "`/bin/ps -U $UID | grep emacs`" ]; then
            local CMDLINE="--eval=(defun myfun () ";
            local FILE;
            for FILE in $*;
            do
                if ( grep ^/ <<< $FILE ) || ( grep ^~ <<< $FILE ); then
                    CMDLINE="$CMDLINE(find-file-other-frame \"$FILE\")";
                else
                    CMDLINE="$CMDLINE(find-file-other-frame \"$PWD/$FILE\")";
                fi;
            done;
            if [ $# != 0 ]; then
                emacs21 "$CMDLINE"")" -f myfun &
            else
                emacs21 &
            fi;
        else
            local CMDLINE="-q";
            local FILE;
            for FILE in $*;
            do
                if ( grep ^/ <<< $FILE ) || ( grep ^~ <<< $FILE ); then
                    CMDLINE="$CMDLINE (find-file-other-frame \"$FILE\")";
                else
                    CMDLINE="$CMDLINE (find-file-other-frame \"$PWD/$FILE\")";
                fi;
            done;
            if [ "$CMDLINE" != "-q" ]; then
                gnudoit $CMDLINE;
            fi;
        fi;
    fi
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-11 21:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-10 20:12 End of file during parsing? Rui Tiago Matos
2005-04-10 23:37 ` Peter Dyballa
2005-04-10 23:47   ` Rui Tiago Matos
     [not found] <mailman.1001.1113162562.2895.help-gnu-emacs@gnu.org>
2005-04-11  3:39 ` Barry Margolin
2005-04-11 21:59   ` Rui Tiago Matos

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.