* RE: Open files in a new frames from command line - Revised
@ 2004-02-03 0:17 Bingham, Jay
0 siblings, 0 replies; only message in thread
From: Bingham, Jay @ 2004-02-03 0:17 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 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-
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-02-03 0:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-03 0:17 Open files in a new frames from command line - Revised Bingham, Jay
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.