emacs-pretest-bug
[Top][All Lists]
Advanced

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

Hi,

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))
                     2)
                 (equal (nth num command-line-args) "w3m")
                 (equal (nth (1- num) command-line-args) "-f"))
            (progn
              (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))
               (equal
                (nth (setq num (- (length command-line-args) (length args) 1))
                     command-line-args)
                "-f"))
          (progn
            (setq url (or w3m-home-page "about:"))
            (setcdr (nthcdr (1- num) command-line-args)
                    (nthcdr (+ num 2) command-line-args)))))
    url))

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

(defun w3m (&optional url new-session interactive-p)
  "docstring"
  (interactive
   (let ((url (w3m-examine-command-line-args)))
     (list
      ;; url
      (or url (read-string "URL: "))
      ;; new-session
      nil
      ;; 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.

Regards,
-- 
Katsumi Yamaoka <address@hidden>




reply via email to

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