(shr-urlify): Highlight under mouse.
[bpt/emacs.git] / lisp / net / shr.el
index bdc30bc..cf3aec2 100644 (file)
@@ -143,8 +143,10 @@ cid: URL as the argument.")
     (define-key map [tab] 'shr-next-link)
     (define-key map [backtab] 'shr-previous-link)
     (define-key map [follow-link] 'mouse-face)
+    (define-key map [mouse-2] 'shr-mouse-browse-url)
     (define-key map "I" 'shr-insert-image)
     (define-key map "w" 'shr-copy-url)
+    (define-key map "u" 'shr-copy-url)
     (define-key map "v" 'shr-browse-url)
     (define-key map "o" 'shr-save-contents)
     (define-key map "\r" 'shr-browse-url)
@@ -656,6 +658,12 @@ size, and full-buffer size."
            (forward-line 1)
          (goto-char end))))))
 
+(defun shr-mouse-browse-url (ev)
+  "Browse the URL under the mouse cursor."
+  (interactive "e")
+  (mouse-set-point ev)
+  (shr-browse-url))
+
 (defun shr-browse-url (&optional external)
   "Browse the URL under point.
 If EXTERNAL, browse the URL using `shr-external-browser'."
@@ -824,6 +832,8 @@ START, and END.  Note that START and END should be markers."
    start (point)
    (list 'shr-url url
         'help-echo (if title (format "%s (%s)" url title) url)
+        'follow-link t
+        'mouse-face 'highlight
         'keymap shr-map)))
 
 (defun shr-encode-url (url)
@@ -1475,9 +1485,6 @@ ones, in case fg and bg are nil."
                    (if column
                        (aref widths width-column)
                      10))
-             ;; Sanity check for degenerate tables.
-             (when (zerop width)
-               (setq width 10))
              (when (and fill
                         (setq colspan (cdr (assq :colspan (cdr column)))))
                (setq colspan (string-to-number colspan))
@@ -1490,6 +1497,9 @@ ones, in case fg and bg are nil."
                (setq width-column (+ width-column (1- colspan))))
              (when (or column
                        (not fill))
+               ;; Sanity check for degenerate tables.
+               (when (zerop width)
+                 (setq width 10))
                (push (shr-render-td (cdr column) width fill)
                      tds))
              (setq i (1+ i)
@@ -1498,6 +1508,7 @@ ones, in case fg and bg are nil."
     (nreverse trs)))
 
 (defun shr-render-td (cont width fill)
+  (when (= width 0) (debug))
   (with-temp-buffer
     (let ((bgcolor (cdr (assq :bgcolor cont)))
          (fgcolor (cdr (assq :fgcolor cont)))