[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Open files in a new frames from command line - Revised
From: |
Bingham, Jay |
Subject: |
RE: Open files in a new frames from command line - Revised |
Date: |
Mon, 2 Feb 2004 18:17:31 -0600 |
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 Oliver's suggested function does not work in emacs 21.1 or
20.4. However, I question your setting of command-switch-alist, since my
reading of the documentation on command-switch-alist indicates that the
hyphen is not included in the CAR of the alist. Your setting above
would cause the usage to be: emacs ---other-frame some-file.txt.
> (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 (and I think that was one of the OP's
requirements), why would you want to type that 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)
("-other-frames" . jcb-frame-per-file))))
(defun jcb-frame-per-file (arg)
"Open file(s) in a new frame.
Process the '-fpf' command line option. Open each file specified on the
command
line following this option (until another option is encountered) in its
own
frame. "
(while (and command-line-args-left
(not (string-match "^--?"
(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 ...
or
emacs first-file --other-frames 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-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RE: Open files in a new frames from command line - Revised,
Bingham, Jay <=