[emacs-w3m:13442] Re: position of tabs not working?

Boruch Baum <[email protected]>
Newsgroups gmane.emacs.w3m
Message-ID <[email protected]>
On 2019-06-06 04:25, Boruch Baum wrote:
> There exists a feature for w3m-copy-buffer to select whether to position
> a new tab at the end of the list or next to the current one. That
> feature isn't working for me, in that it is always putting new tabs at
> the end of the list. Looking at the code, function w3m-copy-buffer
> passes an arg NEXT to w3m-generate-new-buffer, but that function seems
> to use the arg only partially, and seems to determine where to place a
> new tab based upon the unrelated variable w3m-use-title-buffer-name.
>
> Can someone confirm this?

Following is my current working patched version which seems to fix the
issue and also addresses another problem that when NEXT was non-nil,
buffers would be renamed in the form "*w3m*<n><m>" instead of  "*w3m*<n>".
This second issue was solved by reversing the order of the dolist. There
was a third issue in sequencing that I think I solved by changing the
way the new buffer number is calculated.

(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 next
    (let* ((tailbufs (let ((w3m-fb-mode nil))
		       (let ((all-w3m-buffers (w3m-list-buffers)))
			     (memq (current-buffer) all-w3m-buffers))))
	   (new-buffer-number (w3m-buffer-number (car tailbufs))))
      (when (string-match "\\*w3m\\*\\(<\\([0-9]+\\)>\\)?\\'" name)
	(setq name "*w3m*"))
      (when (and tailbufs new-buffer-number)
	(dolist (buf (reverse (cdr tailbufs)))
	  (w3m-buffer-set-number buf (1+ (w3m-buffer-number buf))))
	(setq name (format "%s<%d>" name (1+ new-buffer-number))))))
  (let ((prev (and (eq major-mode 'w3m-mode) (current-buffer)))
	(new (generate-new-buffer name)))
    (with-current-buffer new
      (w3m-mode)
      (setq w3m-previous-session-buffer prev))
    new))

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.