[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: command-line-args
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 <yamaoka@jpl.org>