+2013-06-18 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * net/shr.el (shr-make-table-1): Implement <td rowspan>.
+ (shr-table-horizontal-line): Allow nil as a value, and change the
+ default.
+ (shr-insert-table-ruler): Respect the nil value.
+
+2013-06-18 Tom Tromey <tromey@barimba>
+
+ * net/eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
+ New defvars.
+ (eww-open-file): New defun.
+ (eww-render): Initialize new variables.
+ (eww-display-html): Handle "link" and "a".
+ (eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
+ (eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
+ (eww-back-url): Rename from eww-previous-url.
+ (eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New
+ defuns.
+
2013-06-18 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-syntax-before-regexp-re):
+2013-06-18 Teodor Zlatanov <tzz@lifelogs.com>
+
+ * auth-source.el (auth-source-netrc-parse-entries): Remove debugging.
+
2013-06-18 Glenn Morris <rgm@gnu.org>
* eww.el, shr.el, shr-color.el: Move to ../net.
(when (and alist
(or default
(equal item "machine")))
- (auth-source-do-trivia
- "auth-source-netrc-parse-entries: got entry %S" alist)
+ ;; (auth-source-do-trivia
+ ;; "auth-source-netrc-parse-entries: got entry %S" alist)
(setq all (funcall adder check alist all)
alist nil))
;; In default entries, we don't have a next token.
;; Clean up: if there's an entry left over, use it.
(when alist
(setq all (funcall adder check alist all))
- (auth-source-do-trivia
- "auth-source-netrc-parse-entries: got2 entry %S" alist))
+ ;; (auth-source-do-trivia
+ ;; "auth-source-netrc-parse-entries: got2 entry %S" alist)
+ )
(nreverse all)))
(defvar auth-source-passphrase-alist nil)
"Title of current page.")
(defvar eww-history nil)
+(defvar eww-next-url nil)
+(defvar eww-previous-url nil)
+(defvar eww-up-url nil)
+(defvar eww-top-url nil)
+
;;;###autoload
(defun eww (url)
"Fetch URL and render the page."
(setq url (concat "http://" url)))
(url-retrieve url 'eww-render (list url)))
+;;;###autoload
+(defun eww-open-file (file)
+ "Render a file using EWW."
+ (interactive "fFile: ")
+ (eww (concat "file://" (expand-file-name file))))
+
(defun eww-render (status url &optional point)
(let ((redirect (plist-get status :redirect)))
(when redirect
(setq url redirect)))
+ (set (make-local-variable 'eww-next-url) nil)
+ (set (make-local-variable 'eww-previous-url) nil)
+ (set (make-local-variable 'eww-up-url) nil)
+ (set (make-local-variable 'eww-top-url) nil)
(let* ((headers (eww-parse-headers))
(shr-target-id
(and (string-match "#\\(.*\\)" url)
(input . eww-tag-input)
(textarea . eww-tag-textarea)
(body . eww-tag-body)
- (select . eww-tag-select))))
+ (select . eww-tag-select)
+ (link . eww-tag-link)
+ (a . eww-tag-a))))
(shr-insert-document document)
(eww-convert-widgets))
(goto-char (point-min))))
+(defun eww-handle-link (cont)
+ (let* ((rel (assq :rel cont))
+ (href (assq :href cont))
+ (where (assoc (cdr rel)
+ '(("next" . eww-next-url)
+ ("previous" . eww-previous-url)
+ ("start" . eww-top-url)
+ ("up" . eww-up-url)))))
+ (and href
+ where
+ (set (cdr where) (cdr href)))))
+
+(defun eww-tag-link (cont)
+ (eww-handle-link cont)
+ (shr-generic cont))
+
+(defun eww-tag-a (cont)
+ (eww-handle-link cont)
+ (shr-tag-a cont))
+
(defun eww-update-header-line-format ()
(if eww-header-line-format
(setq header-line-format (format-spec eww-header-line-format
(define-key map [delete] 'scroll-down-command)
(define-key map "\177" 'scroll-down-command)
(define-key map " " 'scroll-up-command)
+ (define-key map "l" 'eww-back-url)
+ (define-key map "n" 'eww-next-url)
(define-key map "p" 'eww-previous-url)
- ;;(define-key map "n" 'eww-next-url)
+ (define-key map "u" 'eww-up-url)
+ (define-key map "t" 'eww-top-url)
map))
(define-derived-mode eww-mode nil "eww"
(setq eww-history nil)
(kill-buffer (current-buffer)))
-(defun eww-previous-url ()
+(defun eww-back-url ()
"Go to the previously displayed page."
(interactive)
(when (zerop (length eww-history))
(let ((prev (pop eww-history)))
(url-retrieve (car prev) 'eww-render (list (car prev) (cadr prev)))))
+(defun eww-next-url ()
+ "Go to the page marked `next'.
+A page is marked `next' if rel=\"next\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-next-url
+ (eww-browse-url (shr-expand-url eww-next-url eww-current-url))
+ (error "No `next' on this page")))
+
+(defun eww-previous-url ()
+ "Go to the page marked `previous'.
+A page is marked `previous' if rel=\"previous\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-previous-url
+ (eww-browse-url (shr-expand-url eww-previous-url eww-current-url))
+ (error "No `previous' on this page")))
+
+(defun eww-up-url ()
+ "Go to the page marked `up'.
+A page is marked `up' if rel=\"up\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-up-url
+ (eww-browse-url (shr-expand-url eww-up-url eww-current-url))
+ (error "No `up' on this page")))
+
+(defun eww-top-url ()
+ "Go to the page marked `top'.
+A page is marked `top' if rel=\"start\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-top-url
+ (eww-browse-url (shr-expand-url eww-top-url eww-current-url))
+ (error "No `top' on this page")))
+
(defun eww-reload ()
"Reload the current page."
(interactive)
:group 'shr
:type '(choice (const nil) regexp))
-(defcustom shr-table-horizontal-line ?\s
- "Character used to draw horizontal table lines."
+(defcustom shr-table-horizontal-line nil
+ "Character used to draw horizontal table lines.
+If nil, don't draw horizontal table lines."
:group 'shr
:type 'character)
(defvar shr-external-rendering-functions nil)
(defvar shr-target-id nil)
(defvar shr-inhibit-decoration nil)
+(defvar shr-table-separator-length 1)
(defvar shr-map
(let ((map (make-sparse-keymap)))
(shr-start nil)
(shr-base nil)
(shr-preliminary-table-render 0)
- (shr-width (or shr-width (window-width))))
+ (shr-width (or shr-width (1- (window-width)))))
(shr-descend (shr-transform-dom dom))
(shr-remove-trailing-whitespace start (point))))
(defun shr-insert-table (table widths)
(let* ((collapse (equal (cdr (assq 'border-collapse shr-stylesheet))
"collapse"))
+ (shr-table-separator-length (if collapse 0 1))
(shr-table-vertical-line (if collapse "" shr-table-vertical-line)))
(unless collapse
(shr-insert-table-ruler widths))
(shr-insert-table-ruler widths)))))
(defun shr-insert-table-ruler (widths)
- (when (and (bolp)
- (> shr-indentation 0))
- (shr-indent))
- (insert shr-table-corner)
- (dotimes (i (length widths))
- (insert (make-string (aref widths i) shr-table-horizontal-line)
- shr-table-corner))
- (insert "\n"))
+ (when shr-table-horizontal-line
+ (when (and (bolp)
+ (> shr-indentation 0))
+ (shr-indent))
+ (insert shr-table-corner)
+ (dotimes (i (length widths))
+ (insert (make-string (aref widths i) shr-table-horizontal-line)
+ shr-table-corner))
+ (insert "\n")))
(defun shr-table-widths (table natural-table suggested-widths)
(let* ((length (length suggested-widths))
(defun shr-make-table-1 (cont widths &optional fill)
(let ((trs nil)
- (shr-inhibit-decoration (not fill)))
+ (shr-inhibit-decoration (not fill))
+ (rowspans (make-vector (length widths) 0))
+ width colspan)
(dolist (row cont)
(when (eq (car row) 'tr)
(let ((tds nil)
(columns (cdr row))
(i 0)
+ (width-column 0)
column)
(while (< i (length widths))
- (setq column (pop columns))
+ ;; If we previously had a rowspan definition, then that
+ ;; means that we now have a "missing" td/th element here.
+ ;; So just insert a dummy, empty one to (sort of) emulate
+ ;; rowspan.
+ (setq column
+ (if (zerop (aref rowspans i))
+ (pop columns)
+ (aset rowspans i (1- (aref rowspans i)))
+ '(td)))
(when (or (memq (car column) '(td th))
- (null column))
- (push (shr-render-td (cdr column) (aref widths i) fill)
- tds)
- (setq i (1+ i))))
+ (not column))
+ (when (cdr (assq :rowspan (cdr column)))
+ (aset rowspans i (+ (aref rowspans i)
+ (1- (string-to-number
+ (cdr (assq :rowspan (cdr column))))))))
+ (setq width
+ (if column
+ (aref widths width-column)
+ 0))
+ (when (and fill
+ (setq colspan (cdr (assq :colspan (cdr column)))))
+ (setq colspan (string-to-number colspan))
+ (dotimes (j (1- colspan))
+ (if (> (+ i 1 j) (1- (length widths)))
+ (setq width (aref widths (1- (length widths))))
+ (setq width (+ width
+ shr-table-separator-length
+ (aref widths (+ i 1 j))))))
+ (setq width-column (+ width-column (1- colspan))))
+ (when (or column
+ (not fill))
+ (push (shr-render-td (cdr column) width fill)
+ tds))
+ (setq i (1+ i)
+ width-column (1+ width-column))))
(push (nreverse tds) trs))))
(nreverse trs)))