[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Open files in a new frames from command line

From: Kevin Rodgers
Subject: Re: Open files in a new frames from command line
Date: Mon, 02 Feb 2004 15:17:36 -0700
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv: Gecko/20020406 Netscape6/6.2.2

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 "^--?"

(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))))
       (pop command-line-args-left))

(push 'my-command-line-make-new-frames

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

(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)))))

> Use as
> emacs --as-frames lirum.txt larum.txt

Invoke as emacs --other-frame FILE ...

Kevin Rodgers

reply via email to

[Prev in Thread] Current Thread [Next in Thread]