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

Re: An example implementation of "following anchor"



Hi,

This is the second mail written by Christoph Conrad.

--- Begin Message ---
Hello Tsuchiya,

to illustrate what i mean i have implemented a version of following
the anchor without re-rendering, see below. The implementation might
not be perfect, it would better use defadvice. Feel free to use the
code for any purpose. BTW: is TSUCHIYA your surname or your given
name?

(defun w3m-view-this-url (&optional arg)
  "*View the URL of the link under point."
  (interactive "P")
  (let ((url (w3m-anchor)) (act (w3m-action)) anchor-found anchor-pos)
    ;; target link is an anchor in the current url?
    (when (string-match (concat "^" w3m-current-url "#\\(.*$\\)") url)
      ;; extract anchor
      (let ( (anchor-string (match-string 1 url)) )
        (save-excursion
          ;; search anchor
          (goto-char (point-min))
          (while (and (not anchor-found)
                      (setq anchor-pos (next-single-property-change
                                        (point) 'w3m-name-anchor)))
            (when (equal anchor-string
                         (plist-get (text-properties-at anchor-pos)
                                    'w3m-name-anchor))
              (setq anchor-found t))
            (goto-char anchor-pos)))))
    (if anchor-found
        (progn
          (w3m-history-store-position)
          (goto-char anchor-pos))
      (cond
       (url (w3m-goto-url url arg))
       (act (eval act))))))

Best regards,
cu, -cc-
-- 
=> GNU Emacs Webring @ <http://www.gnusoftware.com/WebRing/> <=
Look Ma, this man can twist his fingers as if they were made of rubber,
isn't that amazing? -- Not really, he's been using emacs for years...!

--- End Message ---
-- 
TSUCHIYA Masatoshi
    http://www-nagao.kuee.kyoto-u.ac.jp/member/tsuchiya/