[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

[BUGFIXES] w3m session bounds and navigation [PATCH]



The attached patch corrects two bugs in navigating the
w3m-session-select popup window.

1] Currently, running M-x beginning-of-buffer (M-<) or M-x-end-of-buffer
   (M->), (goto-char (point-min)), or (goto-char (point-max)) sends the
   cursor to an undesirable location and makes it impossible to continue
   to navigate.

   There does remain an aesthetic bug in that when performing those
   actions the facespec of the original and final lines are not updated.

2] Currently, navigating forward from the final line cycles the cursor
   back to the first line, but navigating back from the first line
   doesn't do anything.

   This fix also reduces computations by eliminating a loop.

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
Index: ChangeLog
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/ChangeLog,v
retrieving revision 1.3665
diff -b -u -w -r1.3665 ChangeLog
--- ChangeLog	2 May 2018 05:38:10 -0000	1.3665
+++ ChangeLog	9 May 2018 11:18:23 -0000
@@ -1,3 +1,11 @@
+2018-05-09  Boruch Baum  <boruch_baum@xxxxxxx>
+
+	* w3m-session.el (w3m-session-select-list-all-sessions): Fix navigation
+	errors that happen when using functions beginning-of-buffer,
+	end-of-buffer.
+	(w3m-session-select-next): Fix navigation so previous line of first
+	rotates back to last line. Remove unnecessary loop.
+
 2018-05-02  Katsumi Yamaoka  <yamaoka@xxxxxxx>

 	* w3m-image.el (w3m-favicon-usable-p): Relax the criterion.
Index: w3m-session.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-session.el,v
retrieving revision 1.45
diff -b -u -w -r1.45 w3m-session.el
--- w3m-session.el	18 Feb 2018 23:38:58 -0000	1.45
+++ w3m-session.el	9 May 2018 11:18:23 -0000
@@ -558,10 +548,9 @@
 				    w3m-session-number ,num))
 	(setq num (1+ num))
 	(insert (make-string (- max (string-width title)) ?\ ))
-	(insert time "  " url "\n"))
+	(insert time "\n"))
+      (delete-char -1)
       (goto-char (point-min))
-      (goto-char (next-single-property-change
-		  (point) 'w3m-session-number))
       (put-text-property (point)
 			 (next-single-property-change
 			  (point) 'w3m-session-number)
@@ -625,24 +614,16 @@
   "Move the point to the next session."
   (interactive "p")
   (unless arg (setq arg 1))
-  (let ((positive (< 0 arg))
+  (let ((target (1+ (mod (1- (+ arg (line-number-at-pos (point))))
+                     (line-number-at-pos (point-max)))))
 	(inhibit-read-only t))
     (beginning-of-line)
     (put-text-property (point)
 		       (next-single-property-change
 			(point) 'w3m-session-number)
 		       'face 'w3m-session-select)
-    (while (not (zerop arg))
-      (forward-line (if positive 1 -1))
-      (unless (get-text-property (point) 'w3m-session-number)
-	(if positive
-	    (goto-char (next-single-property-change
-			(point-min) 'w3m-session-number))
-	  (goto-char (previous-single-property-change
-		      (point-max) 'w3m-session-number))))
-      (setq arg (if positive
-		    (1- arg)
-		  (1+ arg))))
+    (goto-char (point-min))
+    (forward-line (1- target))
     (beginning-of-line)
     (put-text-property (point)
 		       (next-single-property-change