[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch for bug in w3m-generate-new-buffer
- From: Vladimir Sedach <vas@xxxxxxxxxx>
- Date: Thu, 08 Feb 2018 02:51:35 -0800
- X-ml-name: emacs-w3m
- X-mail-count: 12892
Hello,
There was a serious bug introduced on 2017-10-13 to
w3m-generate-new-buffer: new buffers would always get number 1, there
would be duplicate buffers with number 1. You can verify this by opening
a new w3m buffer (via w3m-search-new-session, for example) when multiple
w3m buffers are already open, and trying to use w3m-previous-buffer.
This bug also masked a problem with the new LAST parameter to
w3m-copy-buffer in w3m-view-this-url-1.
A patch is attached.
Thank you,
Vladimir
Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1700
diff -u -p -r1.1700 w3m.el
--- w3m.el 21 Jan 2018 23:05:45 -0000 1.1700
+++ w3m.el 8 Feb 2018 10:44:12 -0000
@@ -7192,7 +7192,7 @@ launches the current session, i.e., the
(parent (current-buffer)))
(setq pos (point-marker)
buffer (w3m-copy-buffer
- nil nil nil empty w3m-new-session-in-background t))
+ nil nil nil empty w3m-new-session-in-background nil))
(when w3m-new-session-in-background
(set-buffer buffer))
(setq w3m-parent-session-buffer parent)
Index: w3m-util.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-util.el,v
retrieving revision 1.185
diff -u -p -r1.185 w3m-util.el
--- w3m-util.el 5 Feb 2018 01:26:09 -0000 1.185
+++ w3m-util.el 8 Feb 2018 10:44:12 -0000
@@ -446,33 +446,23 @@ An argument of nil means kill the curren
(defun w3m-generate-new-buffer (name &optional next)
"Create and return a buffer with a name based on NAME.
Make the new buffer the next of the current buffer if NEXT is non-nil."
- (when (string-match "<[0-9]+>\\'" name)
- (setq name (substring name 0 (match-beginning 0))))
- (let* ((w3m-fb-mode nil)
- (buffers (w3m-list-buffers))
- (regexp (concat "\\`" (regexp-quote name) "\\(?:<[0-9]+>\\)?\\'"))
- (siblings (delq nil
- (mapcar
- (lambda (buffer)
- (when (string-match regexp (buffer-name buffer))
- buffer))
- buffers)))
- youngers cur number num)
- (if (and next
- (setq youngers (cdr (memq (setq cur (current-buffer)) siblings))))
- (progn
- (setq number (1+ (w3m-buffer-number cur))
- num (+ 1 (length youngers)
- (w3m-buffer-number (car (reverse youngers)))))
- (dolist (buffer (reverse youngers))
- (w3m-buffer-set-number buffer (setq num (1- num))))
- (setq num number)
- (dolist (buffer youngers)
- (w3m-buffer-set-number buffer (setq num (1+ num))))
- (generate-new-buffer (format "%s<%d>" name number)))
- (if (setq number (w3m-buffer-number (car (nreverse siblings))))
- (generate-new-buffer (format "%s<%d>" name (1+ number)))
- (generate-new-buffer name)))))
+ (if w3m-use-title-buffer-name
+ (let* ((tailbufs (let ((w3m-fb-mode nil))
+ (let ((all-w3m-buffers (w3m-list-buffers)))
+ (if next
+ (memq (current-buffer) all-w3m-buffers)
+ (last all-w3m-buffers)))))
+ (new-buffer-number (w3m-buffer-number (car tailbufs))))
+ (when (string-match "\\*w3m\\*\\(<\\([0-9]+\\)>\\)?\\'" name)
+ (setq name "*w3m*"))
+ (if (and tailbufs new-buffer-number)
+ (let ((n (1+ new-buffer-number)))
+ (dolist (buf (cdr tailbufs))
+ (w3m-buffer-set-number buf (setq n (1+ n))))
+ (generate-new-buffer
+ (format "%s<%d>" name (1+ new-buffer-number))))
+ (generate-new-buffer name)))
+ (generate-new-buffer name)))
(defun w3m-buffer-name-lessp (x y)
"Return t if first arg buffer's name is less than second."
Index: ChangeLog
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/ChangeLog,v
retrieving revision 1.3645
diff -u -p -r1.3645 ChangeLog
--- ChangeLog 5 Feb 2018 01:26:08 -0000 1.3645
+++ ChangeLog 8 Feb 2018 10:44:12 -0000
@@ -1,3 +1,12 @@
+2018-02-08 Vladimir Sedach <vas@xxxxxxxxxx>
+
+ * w3m.el (w3m-view-this-url-1): Fix LAST parameter to w3m-copy-buffer
+ to make new buffer go after the current buffer, as intended in revision
+ 1.1691 on 2017-10-13
+
+ * w3m-util.el (w3m-generate-new-buffer): Fix bug introduced in revision
+ 1.3628 on 2017-10-13 where new buffers were always assigned number 1.
+
2018-02-05 Katsumi Yamaoka <yamaoka@xxxxxxx>
* w3m-util.el (w3m-string-match-url-components)