[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: recentre anchor at top of window
- From: Kevin Ryde <user42@xxxxxxxxxx>
- Date: Sat, 13 Jun 2009 07:48:01 +1000
- X-ml-name: emacs-w3m
- X-mail-count: 10917
- References: <87vdp2rhef.fsf@xxxxxxxxx> <b4mbpqro832.fsf@xxxxxxx> <8763gyzyac.fsf@xxxxxxxxx> <b4miqkxo141.fsf@xxxxxxx> <87vdort2ho.fsf@xxxxxxxxx>
Since nobody else has commented I assume I'm the only user of this
feature :-). I'd like to wind it back a bit along the lines I said
before, to just recentre on programmatic goto and link following, not
tab, per below.
2009-06-13 Kevin Ryde <user42@xxxxxxxxxx>
* w3m.el (w3m-view-recenter): Only nil,t,integer, not a cons.
(w3m-search-name-anchor, w3m-view-this-url-1): No arg to w3m-recenter.
(w3m-next-anchor, w3m-previous-anchor, w3m-next-form,
w3m-previous-form, w3m-next-image, w3m-previous-image): Don't
recenter, leave recentering just for following a link, not Tab etc
within the buffer.
(w3m-recenter): Remove NAME arg, believe don't need to differentiate
URLs with an anchor or not since with no anchor `point' is at the
start of the buffer and can't be recentered anyway.
Use C-u style "(recenter '(4))" for the `t' middle-of-screen case.
No need for code to avoid redisplay, `recenter' doesn't redisplay in
the integer or C-u cases.
--- w3m.el 13 Jun 2009 07:22:17 +1000 1.1445
+++ w3m.el 13 Jun 2009 07:25:59 +1000
@@ -1317,20 +1317,20 @@
:group 'w3m
:type '(integer :size 0))
-(defcustom w3m-view-recenter '(t . 1)
- "Argument passed to `recenter' that runs when visiting a link.
-Valid values include an integer, t and nil, and cons of them.
-T means run `recenter' with no argument. Nil means don't perform it.
-If it is cons, the car is used for an ordinary link, and the cdr is
-used for a name link, i.e., the case where the url string ends up with
-\"#NAME\"."
- :group 'w3m
- :type (let ((val '((const :format "%t " t) (const :format "%t " nil)
- (integer :format "%{%t%}: %v\n" :value 1 :size 1))))
- `(radio ,@val
- (cons :format "%{Cons%}:\n%v"
- (radio :format "%v" ,@val)
- (radio :format "%v" ,@val)))))
+(defcustom w3m-view-recenter 1
+ "Recenter window contents when going to an anchor.
+An integer is passed to `recenter', for instance the default 1
+ means put the anchor on the second line of the screen.
+t means `recenter' with no arguments, which puts it in the middle
+ of the screen.
+nil means don't recenter, let the display follow point in the
+ usual way."
+ :group 'w3m
+ ;; radio items in the same order as in the docstring, and `integer' first
+ ;; because it's the default
+ :type '(radio (integer :format "%{%t%}: %v\n" :value 1 :size 1)
+ (const :format "%t\n" t)
+ (const :format "%t\n" nil)))
(defcustom w3m-use-form t
"*Non-nil means make it possible to use form extensions. (EXPERIMENTAL)"
@@ -6366,7 +6366,7 @@
(nthcdr (1+ (car w3m-name-anchor-from-hist))
w3m-name-anchor-from-hist)))))
(when found
- (w3m-recenter t))
+ (w3m-recenter))
found))
(defun w3m-parent-page-available-p ()
@@ -6654,7 +6654,7 @@
(save-excursion
(goto-char pos)
(w3m-refontify-anchor)))))
- (w3m-recenter (string-match "#.+\\'" url))))))
+ (w3m-recenter)))))
(defun w3m-view-this-url (&optional arg new-session)
"Display the page pointed to by the link under point.
@@ -7073,9 +7073,7 @@
(setq arg (1- arg))
(if (member (w3m-anchor-sequence) w3m-goto-anchor-hist)
(setq arg (1+ arg))
- (push (w3m-anchor-sequence) w3m-goto-anchor-hist)))
- (if (/= st (point))
- (w3m-recenter)))
+ (push (w3m-anchor-sequence) w3m-goto-anchor-hist))))
(w3m-horizontal-on-screen)
(w3m-print-this-url)))
@@ -7129,9 +7127,7 @@
(setq arg (1- arg))
(if (member (w3m-anchor-sequence) w3m-goto-anchor-hist)
(setq arg (1+ arg))
- (push (w3m-anchor-sequence) w3m-goto-anchor-hist)))
- (if (/= st (point))
- (w3m-recenter)))
+ (push (w3m-anchor-sequence) w3m-goto-anchor-hist))))
(w3m-horizontal-on-screen)
(w3m-print-this-url)))
@@ -7168,9 +7164,7 @@
(setq arg (1- arg))
(if (member (w3m-action (point)) w3m-goto-anchor-hist)
(setq arg (1+ arg))
- (push (w3m-action (point)) w3m-goto-anchor-hist)))
- (if (/= st (point))
- (w3m-recenter)))
+ (push (w3m-action (point)) w3m-goto-anchor-hist))))
(w3m-horizontal-on-screen)
(w3m-print-this-url)))
@@ -7209,9 +7203,7 @@
(setq arg (1- arg))
(if (member (w3m-action (point)) w3m-goto-anchor-hist)
(setq arg (1+ arg))
- (push (w3m-action (point)) w3m-goto-anchor-hist)))
- (if (/= st (point))
- (w3m-recenter)))
+ (push (w3m-action (point)) w3m-goto-anchor-hist))))
(w3m-horizontal-on-screen)
(w3m-print-this-url)))
@@ -7250,9 +7242,7 @@
(setq arg (1- arg))
(if (member (w3m-image (point)) w3m-goto-anchor-hist)
(setq arg (1+ arg))
- (push (w3m-image (point)) w3m-goto-anchor-hist)))
- (if (/= st (point))
- (w3m-recenter)))
+ (push (w3m-image (point)) w3m-goto-anchor-hist))))
(w3m-horizontal-on-screen)
(w3m-print-this-url)))
@@ -7291,9 +7281,7 @@
(setq arg (1- arg))
(if (member (w3m-image (point)) w3m-goto-anchor-hist)
(setq arg (1+ arg))
- (push (w3m-image (point)) w3m-goto-anchor-hist)))
- (if (/= st (point))
- (w3m-recenter)))
+ (push (w3m-image (point)) w3m-goto-anchor-hist))))
(w3m-horizontal-on-screen)
(w3m-print-this-url)))
@@ -8503,26 +8491,13 @@
0))))
(set-window-hscroll (selected-window) 0)))
-(defun w3m-recenter (&optional name)
- "Recenter the link according to `w3m-view-recenter'.
-Non-nil value for NAME means use the cdr of `w3m-view-recenter'."
- (let ((val (if (consp w3m-view-recenter)
- (if name
- (cdr w3m-view-recenter)
- (car w3m-view-recenter))
- w3m-view-recenter)))
- (when (and val (eq (window-buffer) (current-buffer)))
- ;; A version of `recenter' that does not redisplay the frame.
- (let ((height (w3m-static-if (featurep 'xemacs)
- (1- (window-height))
- (- (window-height) 1 (if header-line-format 1 0)))))
- (save-excursion
- (when (zerop (forward-line (if (integerp val)
- (if (< val 0)
- (- 0 height val)
- (- val))
- (- (/ height 2)))))
- (set-window-start nil (point))))))))
+(defun w3m-recenter ()
+ "Recenter according to `w3m-view-recenter'."
+ (when (and w3m-view-recenter
+ (eq (window-buffer) (current-buffer)))
+ (recenter (if (eq t w3m-view-recenter)
+ '(4) ;; per "C-u C-l" to recenter in middle
+ w3m-view-recenter)))) ;; otherwise an integer
(defun w3m-beginning-of-line (&optional arg)
"Make the beginning of the line visible and move the point to there."