Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 0f4c021b7e3d9b8233f9afffaab733c4c057bc4d 1 parent 60ca71c
yamaoka authored

Showing 3 changed files with 55 additions and 19 deletions. Show diff stats Hide diff stats

  1. +10 0 ChangeLog
  2. +30 15 w3m-hist.el
  3. +15 4 w3m.el
10 ChangeLog
... ... @@ -1,3 +1,13 @@
  1 +2012-02-10 Katsumi Yamaoka <yamaoka@jpl.org>
  2 +
  3 + * w3m-hist.el (w3m-history-store-position): Don't trust column position
  4 + that Emacs tells if there's an image.
  5 + (w3m-history-restore-position): Revert 2011-10-21 change.
  6 +
  7 +2012-02-10 Kevin Ryde <user42@zip.com.au>
  8 +
  9 + * w3m.el (w3m-about-header): Show info of image where point stays.
  10 +
1 11 2012-01-26 Katsumi Yamaoka <yamaoka@jpl.org>
2 12
3 13 * w3m.el (w3m-mode): Don't make bidi-paragraph-direction bound globally
45 w3m-hist.el
... ... @@ -1,6 +1,6 @@
1 1 ;;; w3m-hist.el --- the history management system for emacs-w3m
2 2
3   -;; Copyright (C) 2001-2011 TSUCHIYA Masatoshi <tsuchiya@namazu.org>
  3 +;; Copyright (C) 2001-2012 TSUCHIYA Masatoshi <tsuchiya@namazu.org>
4 4
5 5 ;; Author: Katsumi Yamaoka <yamaoka@jpl.org>
6 6 ;; Keywords: w3m, WWW, hypermedia
@@ -626,11 +626,30 @@ Data consist of the position where the window starts and the cursor
626 626 position. Naturally, those should be treated as buffer-local."
627 627 (interactive)
628 628 (when (cadar w3m-history)
629   - (w3m-history-add-properties
630   - (list :window-start (window-start)
631   - :position (cons (count-lines (point-min) (point-at-bol))
632   - (current-column))
633   - :window-hscroll (window-hscroll)))
  629 + ;; Emacs lies about the column number in the results of
  630 + ;; the functions `current-column', `window-hscroll', etc. if there
  631 + ;; are images; it is likely larger than the position of the cursor
  632 + ;; actually visible, and restoring it causes h-scrolling too much.
  633 + ;; So, we store the position of an image if the cursor follows.
  634 + (let ((column (current-column))
  635 + (hscroll (window-hscroll))
  636 + pos)
  637 + (when (cond ((bobp) nil)
  638 + ((get-text-property (point) 'w3m-image) nil)
  639 + ((get-text-property (1-(point)) 'w3m-image)
  640 + (goto-char (1- (point))))
  641 + ((setq pos (previous-single-property-change
  642 + (point) 'w3m-image nil (point-at-bol)))
  643 + (unless (= pos (point-at-bol))
  644 + (goto-char (1- pos)))))
  645 + (setq pos (current-column))
  646 + (move-to-column column)
  647 + (setq hscroll (max (- hscroll (- column pos)) 0)
  648 + column pos))
  649 + (w3m-history-add-properties
  650 + (list :window-start (window-start)
  651 + :position (cons (count-lines (point-min) (point-at-bol)) column)
  652 + :window-hscroll hscroll)))
634 653 (when (w3m-interactive-p)
635 654 (message "The current cursor position saved"))))
636 655
@@ -641,22 +660,18 @@ it works although it may not be perfect."
641 660 (interactive)
642 661 (when (cadar w3m-history)
643 662 (let ((start (w3m-history-plist-get :window-start))
644   - position window image)
  663 + position window)
645 664 (cond ((and start
646 665 (setq position (w3m-history-plist-get :position)))
647 666 (when (<= start (point-max))
648 667 (goto-char (point-min))
649 668 (forward-line (car position))
650   - (setq window (get-buffer-window (current-buffer) 'all-frames)
651   - image (text-property-not-all (point) (point-at-eol)
652   - 'w3m-image nil))
  669 + (setq window (get-buffer-window (current-buffer) 'all-frames))
653 670 (when window
654 671 (set-window-start window start)
655   - (unless image
656   - (set-window-hscroll
657   - window (or (w3m-history-plist-get :window-hscroll) 0))))
658   - (unless image
659   - (move-to-column (cdr position)))
  672 + (set-window-hscroll
  673 + window (or (w3m-history-plist-get :window-hscroll) 0)))
  674 + (move-to-column (cdr position))
660 675 (let ((deactivate-mark nil))
661 676 (run-hooks 'w3m-after-cursor-move-hook))))
662 677 ((w3m-interactive-p)
19 w3m.el
@@ -9950,15 +9950,26 @@ non-ASCII characters."
9950 9950 (let ((time (w3m-last-modified url)))
9951 9951 (if time (current-time-string time) "")))
9952 9952
9953   - (let (anchor anchor-title)
  9953 + (let (anchor anchor-title
  9954 + image-url image-alt image-size)
9954 9955 (with-current-buffer w3m-current-buffer
9955 9956 (when (equal url w3m-current-url)
9956   - (setq anchor (w3m-anchor))
9957   - (setq anchor-title (w3m-anchor-title))))
  9957 + (setq anchor (w3m-anchor)
  9958 + anchor-title (w3m-anchor-title)
  9959 + image-url (w3m-image)
  9960 + image-alt (w3m-image-alt)
  9961 + image-size (w3m-get-text-property-around 'w3m-image-size))))
9958 9962 (if anchor
9959 9963 (insert "\nCurrent Anchor: " anchor))
9960 9964 (if anchor-title
9961   - (insert "\nAnchor Title: " anchor-title)))
  9965 + (insert "\nAnchor Title: " anchor-title))
  9966 + (if image-url
  9967 + (insert "\nImage: " image-url))
  9968 + (if image-alt
  9969 + (insert "\nImage Alt: " image-alt))
  9970 + (if image-size
  9971 + (insert (format "\nImage Size: %sx%s"
  9972 + (car image-size) (cdr image-size)))))
9962 9973
9963 9974 (let ((ct (w3m-arrived-content-type url))
9964 9975 (charset (w3m-arrived-content-charset url))

0 comments on commit 0f4c021

Please sign in to comment.
Something went wrong with that request. Please try again.