[emacs-w3m:13426] Re: bugs related to tabs
Boruch Baum <[email protected]>
| Newsgroups | gmane.emacs.w3m |
|---|---|
| Message-ID | <[email protected]> |
On 2019-05-24 13:08, Katsumi Yamaoka wrote: > I realized those three bugs all started with the commit 1870402: > ,---- > | commit 1870402fd2c46ff47c115d3aa7cd455935ec96c8 > | Author: Boruch Baum <[email protected]> > | Date: Mon Apr 15 10:15:58 2019 -0400 > | > | BUGFIX: allow new tabs to be loaded in background > `---- I can confirm this now, and can provide an explanation, solution and patch. In that commit 1870402, I introduced using the emacs function `clone-buffer' in order to greatly speed up processing. That function seems to correctly copy a source buffer's local variables to the new buffer, and seems to correctly set the major mode (see there); however, for some reason those actions either don't seem to be applied or fully applied. The attached version of w3m-copy-buffer explicitly performs those actions (presumably a second time, but now it seems to stick), and seems from my testing (now with a gui-enabled emacs) to fix the bugs. A simple way to see what buffer-local variables should be copied is to evaluate function (buffer-local-variables) from a w3m buffer. Choosing to persist and fix the above commit (1870402...) will fix the bugs mentioned in the commit message and retain the performance boost of using function clone-buffer. For me, a question remains whether to post to the emacs developers a bug-report against that function (ie. clone-buffer), because it isn't doing what it says it should, even though the code indicates that is. What this following patched version of `w3m-copy-buffer' does is just repeat line-by-line verbatim what `clone-buffer' should already have done to the source buffer's local variables. (defun w3m-copy-buffer (&optional buffer new-name background empty last) "Copy an emacs-w3m BUFFER, and return the new buffer. If BUFFER is nil, the current buffer is assumed. If NEW-NAME is nil, a name is created based upon the name of the current buffer. If BACKGROUND is non-nil, do not switch to the new buffer copy. When (and only when) this function is called interactively, this value is determined by `w3m-new-session-in-background', but can be inverted by calling this function with a prefix argument. If EMPTY is non-nil, an empty buffer is created, but with the current buffer's history and settings. If LAST is non-nil, the new buffer will be buried as the final w3m buffer; otherwise, it will be sequenced next to the current buffer." (interactive (list nil nil (if current-prefix-arg (not w3m-new-session-in-background) w3m-new-session-in-background))) (unless buffer (setq buffer (current-buffer))) (unless new-name (setq new-name (buffer-name buffer))) (when (string-match "<[0-9]+>\\'" new-name) (setq new-name (substring new-name 0 (match-beginning 0)))) (cond (empty (let ((coding w3m-current-coding-system) (images w3m-display-inline-images) (init-frames (when (w3m-popup-frame-p) (copy-sequence w3m-initial-frames))) (new (w3m-generate-new-buffer new-name (not last)))) (w3m-history-store-position) (with-current-buffer new (w3m-history-copy buffer) (setq w3m-current-coding-system coding w3m-initial-frames init-frames w3m-display-inline-images (if w3m-toggle-inline-images-permanently images w3m-default-display-inline-images))) (when (not background) (w3m-popup-buffer new)) new ; return value for this function )) (t ; ie. (not empty) (let ((lvars (buffer-local-variables)) new) (with-current-buffer buffer (setq new (clone-buffer new-name))) (set-buffer new) ;; Begin: This next should not be necessary, as it is a ;; duplicate of code existing in function ;; clone-buffer. ; (w3m-mode) (mapc (lambda (v) (condition-case () ;in case var is read-only (if (symbolp v) (makunbound v) (set (make-local-variable (car v)) (cdr v))) (error nil))) lvars) ;; End: This next should not be necessary (if (not background) (switch-to-buffer new)) new ; return value for this function )))) -- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0