Permalink
Browse files

w3m.el (w3m-about-header): Show info of image where point stays.

w3m-hist.el (w3m-history-store-position): Don't trust column position that Emacs tells if there's an image.
 (w3m-history-restore-position): Revert 2011-10-21 change.
  • Loading branch information...
1 parent 60ca71c commit 0f4c021b7e3d9b8233f9afffaab733c4c057bc4d yamaoka committed Feb 10, 2012
Showing with 55 additions and 19 deletions.
  1. +10 −0 ChangeLog
  2. +30 −15 w3m-hist.el
  3. +15 −4 w3m.el
View
10 ChangeLog
@@ -1,3 +1,13 @@
+2012-02-10 Katsumi Yamaoka <yamaoka@jpl.org>
+
+ * w3m-hist.el (w3m-history-store-position): Don't trust column position
+ that Emacs tells if there's an image.
+ (w3m-history-restore-position): Revert 2011-10-21 change.
+
+2012-02-10 Kevin Ryde <user42@zip.com.au>
+
+ * w3m.el (w3m-about-header): Show info of image where point stays.
+
2012-01-26 Katsumi Yamaoka <yamaoka@jpl.org>
* w3m.el (w3m-mode): Don't make bidi-paragraph-direction bound globally
View
45 w3m-hist.el
@@ -1,6 +1,6 @@
;;; w3m-hist.el --- the history management system for emacs-w3m
-;; Copyright (C) 2001-2011 TSUCHIYA Masatoshi <tsuchiya@namazu.org>
+;; Copyright (C) 2001-2012 TSUCHIYA Masatoshi <tsuchiya@namazu.org>
;; Author: Katsumi Yamaoka <yamaoka@jpl.org>
;; Keywords: w3m, WWW, hypermedia
@@ -626,11 +626,30 @@ Data consist of the position where the window starts and the cursor
position. Naturally, those should be treated as buffer-local."
(interactive)
(when (cadar w3m-history)
- (w3m-history-add-properties
- (list :window-start (window-start)
- :position (cons (count-lines (point-min) (point-at-bol))
- (current-column))
- :window-hscroll (window-hscroll)))
+ ;; Emacs lies about the column number in the results of
+ ;; the functions `current-column', `window-hscroll', etc. if there
+ ;; are images; it is likely larger than the position of the cursor
+ ;; actually visible, and restoring it causes h-scrolling too much.
+ ;; So, we store the position of an image if the cursor follows.
+ (let ((column (current-column))
+ (hscroll (window-hscroll))
+ pos)
+ (when (cond ((bobp) nil)
+ ((get-text-property (point) 'w3m-image) nil)
+ ((get-text-property (1-(point)) 'w3m-image)
+ (goto-char (1- (point))))
+ ((setq pos (previous-single-property-change
+ (point) 'w3m-image nil (point-at-bol)))
+ (unless (= pos (point-at-bol))
+ (goto-char (1- pos)))))
+ (setq pos (current-column))
+ (move-to-column column)
+ (setq hscroll (max (- hscroll (- column pos)) 0)
+ column pos))
+ (w3m-history-add-properties
+ (list :window-start (window-start)
+ :position (cons (count-lines (point-min) (point-at-bol)) column)
+ :window-hscroll hscroll)))
(when (w3m-interactive-p)
(message "The current cursor position saved"))))
@@ -641,22 +660,18 @@ it works although it may not be perfect."
(interactive)
(when (cadar w3m-history)
(let ((start (w3m-history-plist-get :window-start))
- position window image)
+ position window)
(cond ((and start
(setq position (w3m-history-plist-get :position)))
(when (<= start (point-max))
(goto-char (point-min))
(forward-line (car position))
- (setq window (get-buffer-window (current-buffer) 'all-frames)
- image (text-property-not-all (point) (point-at-eol)
- 'w3m-image nil))
+ (setq window (get-buffer-window (current-buffer) 'all-frames))
(when window
(set-window-start window start)
- (unless image
- (set-window-hscroll
- window (or (w3m-history-plist-get :window-hscroll) 0))))
- (unless image
- (move-to-column (cdr position)))
+ (set-window-hscroll
+ window (or (w3m-history-plist-get :window-hscroll) 0)))
+ (move-to-column (cdr position))
(let ((deactivate-mark nil))
(run-hooks 'w3m-after-cursor-move-hook))))
((w3m-interactive-p)
View
19 w3m.el
@@ -9950,15 +9950,26 @@ non-ASCII characters."
(let ((time (w3m-last-modified url)))
(if time (current-time-string time) "")))
- (let (anchor anchor-title)
+ (let (anchor anchor-title
+ image-url image-alt image-size)
(with-current-buffer w3m-current-buffer
(when (equal url w3m-current-url)
- (setq anchor (w3m-anchor))
- (setq anchor-title (w3m-anchor-title))))
+ (setq anchor (w3m-anchor)
+ anchor-title (w3m-anchor-title)
+ image-url (w3m-image)
+ image-alt (w3m-image-alt)
+ image-size (w3m-get-text-property-around 'w3m-image-size))))
(if anchor
(insert "\nCurrent Anchor: " anchor))
(if anchor-title
- (insert "\nAnchor Title: " anchor-title)))
+ (insert "\nAnchor Title: " anchor-title))
+ (if image-url
+ (insert "\nImage: " image-url))
+ (if image-alt
+ (insert "\nImage Alt: " image-alt))
+ (if image-size
+ (insert (format "\nImage Size: %sx%s"
+ (car image-size) (cdr image-size)))))
(let ((ct (w3m-arrived-content-type url))
(charset (w3m-arrived-content-charset url))

0 comments on commit 0f4c021

Please sign in to comment.