all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RE: Open files in a new frames from command line
@ 2004-02-02 23:12 Bingham, Jay
  0 siblings, 0 replies; 11+ messages in thread
From: Bingham, Jay @ 2004-02-02 23:12 UTC (permalink / raw)


On Monday, February 02, 2004 at 4:18 PM Kevin Rodgers wrote

> Oliver Scholz wrote:
> 
>> There is no such command line option, but you could make your own
>> command line option, if you put something like this (only slightly
>> tested) into your .emacs:
>> 
>> (defun my-is-option-p (str)
>>   "Return non-nil if STR is an command line option."
>>   (string-match "^--?"
>> 		str))
>> 
>> (defun my-command-line-make-new-frames ()
>>   "Process open each files in a new frame.
>> This function is supposed to be an element of
>> `command-line-functions' (q.v.). Its functionality is triggered
>> if ARGI is \"--as-frames\" and opens each element in
>> COMMAND-LINE-ARGS-LEFT not starting with a slash as a file in a
>> separate frame."
>>   (when (string= argi "--as-frames")
>>     (unless (my-is-option-p (car command-line-args-left))
>>       (find-file (pop command-line-args-left)))
>>     (while (and command-line-args-left
>> 		(not (my-is-option-p
>> 		      (car command-line-args-left))))
>>       (find-file-other-frame
>>        (pop command-line-args-left))
>>       t)))
>> 
>> (push 'my-command-line-make-new-frames
>>       command-line-functions)
> 
> It's a lot easier to use command-switch-alist:
> 
> (setq command-switch-alist
>    (cons '("--other-frame" . find-file-other-frame-command-line-arg) ;
-R
>     command-switch-alist))

I agree it is a lot easier to use command-switch-alist, especially when
I found that the original suggestion does not work in emacs 21.1 or
20.4.
However I have a question about your implementation since my reading of
the documentation on command-switch-alist indicates that the hyphen is
not included in the CAR of the alist.  I don't know how that plays with
double hyphen options.

> (defun find-file-other-frame-command-line-arg (switch)
>    "Visit next command line argument (after SWITCH) in a new frame."
>    ;; (prog1 (car x) (setq x (cdr x))) == (pop x):
>    (find-file-other-frame (prog1 (car command-line-args-left)
> 			   (setq command-line-args-left
> 				 (cdr command-line-args-left)))))

If you are looking for easy, why would you want to type that big long
option before every file name?  Here is what I did to Oliver's function
to make it work with only one option that affects all the remaining file
names on the command line.

(setq
 command-switch-alist
 (append
  '(("fpf" . jcb-frame-per-file))))

 (defun jcb-frame-per-file (arg)
  "Open each file on the command line in a new frame.
This function is triggered by the '-fpf' command line option.
Each file on the command line that follows it is opened in its own
frame."
  (while (and command-line-args-left
             (not ((string-match "^--?" str)
                   (car command-line-args-left))))
    (find-file-other-frame
     (pop command-line-args-left) t)
    t))

>> Use as
>>
>> emacs --as-frames lirum.txt larum.txt
> 
> Invoke as emacs --other-frame FILE ...

Invoke as:
 emacs first-file -fpf second-file ...

if the -fpf option is before the first file name then n+1 frames are
opened and *scratch* is in the first frame.

-_
J_)
C_)ingham
.    HP - NonStop Austin Software & Services - Software Quality
Assurance
.    Austin, TX
. "Language is the apparel in which your thoughts parade in public.
.  Never clothe them in vulgar and shoddy attire."     -Dr. George W.
Crane-

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <mailman.1752.1075763607.928.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.1057.1074645741.928.help-gnu-emacs@gnu.org>]
* RE: Open files in a new frames from command line
@ 2004-01-29 16:46 Bingham, Jay
  0 siblings, 0 replies; 11+ messages in thread
From: Bingham, Jay @ 2004-01-29 16:46 UTC (permalink / raw)


"Michael B. Schmidt" <MiBSchmidt@gmx.de> wrote:

> I need to open multiple files to work with them. I use the command:
> "emacs foo bar baz". This open the file foo,bar and baz each in a new
> Buffer. Is there away (command line option,script) to open the files
> in frames instead of new Buffers? (I know that I can open one of the
> files and then open each file with c-x 5 f but this is to much work
> :-)))

I have been watching this thread for several days and like others who
have responded I do not know of a command line option that will do what
you want.  Finally today it occurred to me that a function which I just
wrote (because I found doing multiple c-x 5 2's each time I started
emacs to be tedious) should be fairly simple to modify to do what you
describe.

The function that I wrote opens a number of frames based on the contents
of a list and positions the frames at specific locations on the screen.
It should not be difficult to adapt this function use a list of the
buffers associated with files that were opened with the command line as
the basis for the number of frames to create and to map the buffers in
list to the frames as they are opened.  Making it transparent would then
just be a matter of running the function from your .emacs file.  I do
not have the time right now to do those modifications but if you are
interested in doing it your self I will be glad to send the code to you.

-_
J_)
C_)ingham
.    HP - NonStop Austin Software & Services - Software Quality
Assurance
.    Austin, TX
. "Language is the apparel in which your thoughts parade in public.
.  Never clothe them in vulgar and shoddy attire."     -Dr. George W.
Crane-

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Open files in a new frames from command line
@ 2004-01-21  1:05 Michael B. Schmidt
  0 siblings, 0 replies; 11+ messages in thread
From: Michael B. Schmidt @ 2004-01-21  1:05 UTC (permalink / raw)


Hello,

I need to open multiple files to work with them. I use the command: 
"emacs foo bar baz". This open the file foo,bar and baz each in a new 
Buffer. Is there away (command line option,script) to open the files in 
frames instead of new Buffers? (I know that I can open one of the files 
and then open each file with c-x 5 f but this is to much work :-)))

Thank you

Michael

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

end of thread, other threads:[~2004-02-04 22:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-02 23:12 Open files in a new frames from command line Bingham, Jay
     [not found] <mailman.1752.1075763607.928.help-gnu-emacs@gnu.org>
2004-02-03 17:46 ` Kevin Rodgers
     [not found] <mailman.1057.1074645741.928.help-gnu-emacs@gnu.org>
2004-01-21  1:11 ` Kin Cho
2004-01-21  1:14 ` Christopher J. White
2004-01-29  8:20 ` Kai Grossjohann
2004-02-04 22:25   ` Joe Casadonte
2004-01-30 23:44 ` Oliver Scholz
2004-02-02 22:17   ` Kevin Rodgers
2004-02-03  4:38     ` Oliver Scholz
  -- strict thread matches above, loose matches on Subject: below --
2004-01-29 16:46 Bingham, Jay
2004-01-21  1:05 Michael B. Schmidt

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.