[Top][All Lists]

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

Re: command-line-args

From: Katsumi Yamaoka
Subject: Re: command-line-args
Date: Sun, 21 Sep 2003 15:05:45 +0900
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)


I've fixed the problem that the w3m command couldn't be invoked
from the command line as before.  Here's a new function used to
examine the command line arguments:

(defun w3m-examine-command-line-args ()
  "Return a url string if it seems that the `w3m' command is invoked from
the command line like: ``emacs -f w3m'' or ``emacs -f w3m url''."
  (let ((url (car command-line-args-left))
        args num)
    (if url
        (if (and (setq args (memq url command-line-args))
                 (>= (setq num (- (length command-line-args) (length args) 1))
                 (equal (nth num command-line-args) "w3m")
                 (equal (nth (1- num) command-line-args) "-f"))
              (setq command-line-args-left (cdr command-line-args-left))
              (setcdr (nthcdr (- num 2) command-line-args)
                      (nthcdr (+ num 2) command-line-args)))
          (set url nil))
      (if (and (setq args (member "w3m" command-line-args))
                (nth (setq num (- (length command-line-args) (length args) 1))
            (setq url (or w3m-home-page "about:"))
            (setcdr (nthcdr (1- num) command-line-args)
                    (nthcdr (+ num 2) command-line-args)))))

And I've also modified the w3m command like follows:

(defun w3m (&optional url new-session interactive-p)
   (let ((url (w3m-examine-command-line-args)))
      ;; url
      (or url (read-string "URL: "))
      ;; new-session
      ;; interactive-p
      (not url))))

Where the `interactive-p' flag is a replacement of the
interactive-p function.  It is used in the w3m function in
order to know whether the command is called interactively.

Katsumi Yamaoka <address@hidden>

reply via email to

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