[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: w3m-uri-replace-alist: necessity of using colons in keys
- From: Michael Heerdegen <michael_heerdegen@xxxxxx>
- Date: Mon, 02 Sep 2013 14:48:58 +0200
- X-ml-name: emacs-w3m
- X-mail-count: 12132
- References: <87hae5c27g.fsf@xxxxxx> <b4m8uzfluc3.fsf@xxxxxxx>
Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
> If you're talking about APEL's put-alist, I think this should be:
>
> (setq w3m-uri-replace-alist
> (put-alist "\\`ew" '(w3m-search-uri-replace "emacswiki")
> w3m-uri-replace-alist))
I were talking about my own version, I should have clarified that.
> > and then enter a uri like "ew w3m" this won't work (try it!)
>
> Well, you don't want "http //www.gnu.org" to work as well as
> "http://www.gnu.org", do you?
No, of course not.
> > because
> > before `w3m-uri-replace' is called, `w3m-canonicalize-url' "fixes" the
> > url to a Google feeling lucky thing. The colon is hardcoded in
> > `w3m-url-components-regexp'.
>
> Because "gg:" and the like is the scheme name + delimiter like
> "http:". Of course it's a local rule, so those schemes are valid
> only in emacs-w3m. But it might be better to let an "ew w3m" thing
> work iff the key you registered is "\\`ew " (or "\\`ew[\t ]+").
> Is it ok?
Yes, that's exactly what I want.
> If so, I'll install this patch:
>
>
> --- w3m.el~ 2013-08-26 10:46:18.000000000 +0000
> +++ w3m.el 2013-09-02 04:26:00.864628700 +0000
> @@ -4584,17 +4584,21 @@
> (if (string-match "\\`\\(https?://[-.0-9a-z]+\\)\\([#?].*\\)" url)
> (concat (match-string 1 url) "/" (match-string 2 url))
> (w3m-string-match-url-components url)
> - (cond
> - ((match-beginning 1)
> - url)
> - ((and (file-name-absolute-p url) (file-exists-p url))
> - (concat "file://" url))
> - (feeling-lucky
> - (concat "\
> + (let (replaced)
> + (cond
> + ((match-beginning 1)
> + url)
> + ((and (file-name-absolute-p url) (file-exists-p url))
> + (concat "file://" url))
> + ((and (setq replaced (ignore-errors (w3m-uri-replace url)))
> + (not (string= url replaced)))
> + replaced)
> + (feeling-lucky
> + (concat "\
> http://www.google.com/search?btnI=I%%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q="
> - (w3m-url-encode-string url nil t)))
> - (t
> - (concat "http://" url)))))
> + (w3m-url-encode-string url nil t)))
> + (t
> + (concat "http://" url))))))
>
> (defun w3m-input-url (&optional prompt initial default quick-start
> feeling-lucky no-initial)
> @@ -9033,18 +9037,16 @@
> (catch 'found-replacement
> (dolist (elem w3m-uri-replace-alist uri)
> (when (string-match (car elem) uri)
> - (if (setq uri
> - (cond
> - ((consp (cdr elem))
> - (apply (cadr elem) uri (cddr elem)))
> - ;; Rest conditions are inserted in order to keep
> - ;; backward compatibility.
> - ((functionp (cdr elem))
> - (funcall (cdr elem) uri))
> - ((stringp (cdr elem))
> - (w3m-pattern-uri-replace uri (cdr elem)))))
> - (throw 'found-replacement uri)
> - (error "Invalid replacement: %s" elem))))))
> + (throw 'found-replacement
> + (cond
> + ((consp (cdr elem))
> + (apply (cadr elem) uri (cddr elem)))
> + ;; Rest conditions are inserted in order to keep
> + ;; backward compatibility.
> + ((functionp (cdr elem))
> + (funcall (cdr elem) uri))
> + ((stringp (cdr elem))
> + (w3m-pattern-uri-replace uri (cdr elem)))))))))
>
> (defun w3m-goto-mailto-url (url &optional post-data)
> (let ((before (nreverse (buffer-list)))
> @@ -9388,7 +9390,6 @@
> (not (w3m-interactive-p)))
> (setq url (w3m-canonicalize-url url)))
> (set-text-properties 0 (length url) nil url)
> - (setq url (w3m-uri-replace url))
> (unless (or (w3m-url-local-p url)
> (string-match "\\`about:" url))
> (w3m-string-match-url-components url)
Looks ok to me, and works (dunno if the `ignore-errors' is really
needed, btw). If you're sure it doesn't break something else, please
install. Thanks!
Regards,
Michael.