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

Re: Elisp: "cd" seems not to work



WDYT?
--- Begin Message ---
Hi,

(I'll forward this message to the emacs-w3m mailing list.)

>>>>> In <uslj4jy0w.fsf@xxxxxxxxxxx> Joe Fineman wrote:

> I want to visit Google with W3M, but I want the default directory to
> remain the same while I do it.  So:

> (defun google (what)
>   "Use google to search for WHAT."
>   (interactive "sSearch: ")
>   (save-window-excursion
>     (delete-other-windows)
>     (let ((dir default-directory))
>       (w3m-browse-url (concat "http://www.google.com/search?q="
> 			      (w3m-url-encode-string what)))
>       (cd dir)
>     (recursive-edit))))

> It doesn't work.  The default directory continues to be ~/.w3m.  Why?
> --
> ---  Joe Fineman    joe_f@xxxxxxxxxxx

>||:  It's much more fun to imagine how I might have behaved  :||
>||:  worse than how I might have behaved better.             :||

Because it defaults to the value of `w3m-profile-directory' if
the page doesn't visit a local file.  However, it has never been
useful to me, so I'm using the following advice in order to make
it the home directory.

(defadvice w3m-current-directory (around return-home-directory activate)
  "Return the home directory by default."
  (let ((w3m-profile-directory "~/"))
    ad-do-it))

The next one might be yours.

(defadvice w3m-current-directory (around return-default-directory activate)
  "Return the value of `default-directory' by default."
  (let ((w3m-profile-directory default-directory))
    ad-do-it))

--- End Message ---