From: "Bingham, Jay" <jay.bingham@hp.com>
Subject: RE: Open files in a new frames from command line - Revised
Date: Mon, 2 Feb 2004 18:17:31 -0600 [thread overview]
Message-ID: <72A87F7160C0994D8C5A36E2FDC227F508DDA81A@txnexc01.americas.cpqcorp.net> (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-
reply other threads:[~2004-02-03 0:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=72A87F7160C0994D8C5A36E2FDC227F508DDA81A@txnexc01.americas.cpqcorp.net \
--to=jay.bingham@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.