[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[W3-dev] w3.el Patch
From: |
Ian D |
Subject: |
[W3-dev] w3.el Patch |
Date: |
Sat, 11 Aug 2012 10:31:59 -0400 |
A while back, I noticed that the back mechanism was no longer working in
w3. The patch below fixes this problem. It also updates the lisp code to
please Emacs' byte-compiler. If any problems are found, please let me know.
Ian D.
-- Patch Begins Here --
diff --git a/lisp/w3.el b/lisp/w3.el
index b33623d..16aaafe 100644
--- a/lisp/w3.el
+++ b/lisp/w3.el
@@ -69,8 +69,7 @@ See the variable `w3-notify' for the different notification
behaviors."
;; we must not leave a different buffer current.
;; We can't rely on the editor command loop to reselect
;; the selected window's buffer.
- (save-excursion
- (set-buffer buff)
+ (with-current-buffer buff
(make-frame)))
((eq w3-notify 'bully)
(pop-to-buffer buff)
@@ -216,8 +215,7 @@ variable `http-header'."
"Propagate information from <meta http-equiv...> elements to MIME headers.
Operate on BUFFER."
(let (content-type end-of-headers extra-headers)
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(goto-char (point-min))
(mail-narrow-to-head)
(setq content-type (mail-fetch-field "content-type"))
@@ -295,7 +293,7 @@ MUST-BE-VIEWING is the current URL when the timer expires."
(setq uri (match-string 1 uri)))
(setq uri (url-expand-file-name uri (url-view-url t)))))
(w3-setup-reload-timer uri (url-view-url t)
- (string-to-int (or reload "5"))))))
+ (string-to-number (or reload "5"))))))
(defun w3-fetch-redirect-callback (&rest args)
(let (redirect-url errorp)
@@ -378,6 +376,7 @@ MUST-BE-VIEWING is the current URL when the timer expires."
;; url-current-mime-headers headers)
;; (mm-destroy-parts handle)
;; (w3-notify-when-ready (current-buffer)))
+ ;; Need something in here to load the urls into the history buffer.
((equal (car-safe (mm-handle-type handle))
"application/x-elisp-parsed-html")
;; Also need to special-case pre-parsed representations of HTML.
@@ -419,6 +418,7 @@ With prefix argument, use the URL of the hyperlink under
point instead."
(while (= (string-to-char url) ? )
(setq url (substring url 1)))
+ (w3-history-push (url-view-url t) url)
(or target (setq target w3-base-target))
(if (stringp target)
(setq target (intern (downcase target))))
@@ -438,7 +438,7 @@ With prefix argument, use the URL of the hyperlink under
point instead."
(cond
((= (string-to-char url) ?#)
(w3-relative-link url))
- ((and (interactive-p) current-prefix-arg)
+ ((and (called-interactively-p 'any) current-prefix-arg)
(w3-download-url url))
(t
(let ((x (url-view-url t))
@@ -547,14 +547,13 @@ the cdr is the 'next' node."
(defun w3-document-information (&optional buff)
"Display information on the document in buffer BUFF."
(interactive)
- (if (interactive-p)
+ (if (called-interactively-p 'any)
(let ((w3-notify 'friendly))
(if (get-buffer "Document Information")
(kill-buffer (get-buffer "Document Information")))
(w3-fetch "about:document"))
(setq buff (or buff (current-buffer)))
- (save-excursion
- (set-buffer buff)
+ (with-current-buffer buff
(let* ((url (url-view-url t))
(cur-links w3-current-links)
(title (buffer-name))
@@ -574,7 +573,7 @@ the cdr is the 'next' node."
(if (equal '(0 . 0) lastmod)
(setq lastmod nil)
(setq lastmod (current-time-string lastmod))))
- (setq url-current-mime-type "text/html")
+ ;;(setq url-current-mime-type "text/html")
(insert "\
Content-Type: text/html\n
<html>
@@ -588,20 +587,20 @@ Content-Type: text/html\n
<tr><td>Location:</td><td>" url "</td></tr>")
(if size (insert "\
<tr><td>Size:</td><td>" (url-pretty-length (if (stringp size)
- (string-to-int size)
+ (string-to-number size)
size)) "</td></tr>"))
(insert "\
<tr><td>Last Modified:</td><td>" (or lastmod "None Given") "</td></tr>\n")
(when hdrs
(setq hdrs (delete (assq 'last-modified hdrs) hdrs))
(setq hdrs (delete (assq 'content-length hdrs) hdrs))
- (setq hdrs (mapcar (lambda (pair)
- (cons (symbol-name (car pair))
- (cdr pair)))
- hdrs)))
- (let* ((maxlength (car (sort (mapcar (lambda (x)
- (length (car x)))
- hdrs)
+ (setq hdrs (mapc (lambda (pair)
+ (cons (symbol-name (car pair))
+ (cdr pair)))
+ hdrs)))
+ (let* ((maxlength (car (sort (mapc (lambda (x)
+ (length (car x)))
+ hdrs)
'>)))
(fmtstring (format "\
<tr><td align=right>%%%ds:</td><td>%%s</td></tr>" maxlength)))
@@ -623,17 +622,17 @@ Content-Type: text/html\n
"\n")))
(when links
;; collapse `rel' and `rev' components
- (setq links (apply 'append (mapcar 'cdr links)))
+ (setq links (apply 'append (mapc 'cdr links)))
;; extract
- (setq links (mapcar
+ (setq links (mapc
(lambda (elt)
(cons (or (plist-get (cadr elt) 'title)
(car elt))
(plist-get (cadr elt) 'href)))
links))
- (let* ((maxlength (car (sort (mapcar (lambda (x)
- (length (car x)))
- links)
+ (let* ((maxlength (car (sort (mapc (lambda (x)
+ (length (car x)))
+ links)
'>)))
(fmtstring
(format
@@ -653,9 +652,9 @@ Content-Type: text/html\n
(setq links (cdr links)))))
(if info
- (let* ((maxlength (car (sort (mapcar (lambda (x)
- (length (car x)))
- info)
+ (let* ((maxlength (car (sort (mapc (lambda (x)
+ (length (car x)))
+ info)
'>)))
(fmtstring (format
" <tr><td>%%%ds:</td><td>%%s</td></tr>"
@@ -692,8 +691,7 @@ With prefix arg, insert the url under point."
(read-string "Link text: " (buffer-name))))))
(setq buff (read-buffer "Insert into buffer: " nil t))
(if buff
- (save-excursion
- (set-buffer buff)
+ (with-current-buffer buff
(insert str))
(message "Cancelled."))))
@@ -836,7 +834,7 @@ If there is no link under point, this will try using
content-charset))
(let ((url-source t))
;; Fixme: this needs a callback -- which?
- (url-retrieve url)))
+ (url-retrieve url nil)))
((equal "HTML Source" format)
(setq content-type (concat "text/html; charset="
content-charset))
@@ -846,7 +844,7 @@ If there is no link under point, this will try using
(erase-buffer)
(insert x))
;; Fixme: this needs a callback -- which?
- (url-retrieve url)))
+ (url-retrieve url nil)))
((and under (equal "PostScript" format))
(setq content-type "application/postscript")
(w3-fetch url)
@@ -873,7 +871,7 @@ If there is no link under point, this will try using
content-charset))))
(buffer-string))))
(funcall url-mail-command)
- (mail-subject)
+ ;;(mail-subject)
(if (and (boundp 'mime/editor-mode-flag) mime/editor-mode-flag)
(insert format " from <URL: " url ">")
(insert format " from <URL: " url ">\n"
@@ -892,7 +890,7 @@ If there is no link under point, this will try using
(insert "\n"))
(insert (format "<base href=\"%s\">" url))))
;; Fixme: not defined.
- (mail-to)))
+ (message-send)))
(defun w3-internal-use-history (hist-item)
;; Go to the link in the history
@@ -904,8 +902,7 @@ If there is no link under point, this will try using
(let ((x (buffer-list))
(found nil))
(while (and x (not found))
- (save-excursion
- (set-buffer (car x))
+ (with-current-buffer (car x)
(setq found (string= (url-view-url t) url))
(if (not found) (setq x (cdr x)))))
(cond
@@ -923,7 +920,7 @@ If there is no link under point, this will try using
(w3-find-specific-link (substring url 1 nil)))))
;; Fixme: url-maybe-relative not defined.
(url (url-maybe-relative url)) ; Get the link
- (t (message "Couldn't understand whats in the history.")))))
+ (t (message "Couldn't understand what's in the history.")))))
(defun w3-relative-link (url)
(if (equal "#" (substring url 0 1))
@@ -1105,8 +1102,7 @@ even though the MIME type is nil or listed in
`w3-mime-list-for-code-conversion'
(defun w3-log-bad-html (type desc)
"Log bad HTML to the buffer specified by w3-debug-buffer."
(if w3-debug-html
- (save-excursion
- (set-buffer (get-buffer-create w3-debug-buffer))
+ (with-current-buffer (get-buffer-create w3-debug-buffer)
(goto-char (point-max))
(insert (make-string (1- (window-width)) w3-horizontal-rule-char) "\n")
(cond
@@ -1174,7 +1170,7 @@ even though the MIME type is nil or listed in
`w3-mime-list-for-code-conversion'
url-version
url)))
(if (and url (string= url "file:nil")) (setq url nil))
- (mapcar
+ (mapc
(function
(lambda (x)
(if (not (and (boundp x) (symbol-value x)))
@@ -1254,7 +1250,7 @@ If optional argument HERE is non-nil, insert info at
point."
url-version)))
(if here
(insert version-string)
- (if (interactive-p)
+ (if (called-interactively-p 'any)
(message "%s" version-string)
version-string))))
@@ -1296,8 +1292,7 @@ Otherwise just as `display-buffer', and using this
function."
(if (not (eq 'tty (device-type)))
(let ((f (window-frame (display-buffer (find-file-noselect file)))))
(set-mouse-position f 1 0)
- (raise-frame f)
- (unfocus-frame))
+ (raise-frame f))
(display-buffer (find-file-noselect file))))
(defun w3-default-local-file()
@@ -1443,8 +1438,7 @@ as high as possible in w3-explicit-conversion-tree"
(let ((make-backup-files nil)
(version-control nil)
(require-final-newline t))
- (save-excursion
- (set-buffer (get-buffer-create " *w3-tmp*"))
+ (with-current-buffer (get-buffer-create " *w3-tmp*")
(erase-buffer)
(insert "(setq w3-explicit-conversion-tree\n '"
(prin1-to-string w3-explicit-conversion-tree)
@@ -1470,8 +1464,7 @@ as high as possible in w3-explicit-conversion-tree"
(if mega
(mapcar
(lambda (x)
- (save-excursion
- (set-buffer (get-buffer x))
+ (with-current-buffer (get-buffer x)
(if (eq major-mode 'w3-mode)
(w3-quit nil))))
(buffer-list))
@@ -1655,8 +1648,7 @@ No arg means whole window full. Arg is number of lines
to scroll."
(if (and (eq class 'html)
(not w3-debug-html))
nil
- (save-excursion
- (set-buffer (get-buffer-create "*W3-WARNINGS*"))
+ (with-current-buffer (get-buffer-create "*W3-WARNINGS*")
(goto-char (point-max))
(save-excursion
(insert (format "(%s/%s) %s\n" class (or level 'warning) message)))
@@ -2077,9 +2069,7 @@ With optional ARG, move across that many fields."
(url (url-view-url t)))
(if (not todo)
(error "No HTML errors on this page! Amazing, isn't it?"))
- (save-excursion
- (set-buffer
- (get-buffer-create (concat "HTML Errors for: " (or url "???"))))
+ (with-current-buffer (get-buffer-create (concat "HTML Errors for: " (or
url "???")))
(setq buffer (current-buffer))
(erase-buffer)
(while todo
@@ -2094,8 +2084,7 @@ With optional ARG, move across that many fields."
(set (make-local-variable 'font-lock-keywords-only) nil)
(set (make-local-variable 'font-lock-keywords-case-fold-search) nil)
(set (make-local-variable 'font-lock-syntax-table) nil)
- (set (make-local-variable 'font-lock-beginning-of-syntax-function)
- 'beginning-of-line)
+ (set (make-local-variable 'syntax-begin-function) 'beginning-of-line)
(run-hooks 'w3-display-errors-hook))
(w3-notify-when-ready buffer)))
@@ -2107,7 +2096,7 @@ Current keymap is:
\\{w3-mode-map}"
(interactive)
(w3-do-setup)
- (if (interactive-p)
+ (if (called-interactively-p 'any)
(w3-preview-this-buffer)
;; This code used to keep a few buffer-local variables around so
;; that we could be a nice major mode and kill all the local
-- Patch Ends Here --
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [W3-dev] w3.el Patch,
Ian D <=