默认情况下,emacs-w3m
个选项卡按字母顺序排列。我更喜欢emacs-w3m
像Firefox一样工作,在Firefox中,新标签页会在当前标签页的右侧或至少按实际访问的顺序创建。
此功能的代码位于w3m-util.el
程序包的emacs-w3m
中,尤其是w3m-list-buffers
函数中。 w3m-list-buffers
有一个可选参数nosort
,当t
导致emacs-w3m
不能按字母顺序对列表进行排序时,该参数是可选的。这比我们想要的要走了一步,但还不完全。在这一点上,我认为放弃确切的行为或Firefox可能很有用,而可以选择按页面到达的时间对emacs-w3m
缓冲区进行排序。为此,我创建了以下两个函数:
(defun w3m-lookup-page-arrival-time (buffer-title)
"Return arrival time for page associated with BUFFER-TITLE."
(nth 3 (find buffer-title (w3m-arrived-load-list)
:key (lambda (x) (nth 1 x))
:test #'equal)))
(defun w3m-buffer-time-lessp (x y)
"Return t if first arg buffer's arrival time is less than second."
(when (bufferp x)
(setq x (w3m-buffer-title x))
(message "w3m-buffer-title: %s" x) ; Looking in *Messages* buffer shows each page visited more than once which seems indicative of a problem which the implementation approach I've taken
(setq x (w3m-lookup-page-arrival-time x)))
(when (bufferp y)
(setq y (w3m-lookup-page-arrival-time (w3m-buffer-title y))))
(time-less-p x y))
上面对message
的调用所提供的输出证明了我们确实可以将w3m-buffer-title
与w3m到达数据库进行比较,但是,它表现不佳,甚至可能不正确因为它们可能是要更新的到达数据库之间的交互,即使我们通过w3m-list-buffers
生成w3m缓冲区列表时使用它来比较到达时间。
上面的代码是通过将对w3m-buffer-name-lessp
中对w3m-list-buffers
的{{1}}的调用替换为w3m-buffer-time-lessp
(其他都不变)来实现的,
(defun w3m-list-buffers (&optional nosort)
"Return a list of buffers in which emacs-w3m sessions are open.
If the optional NOSORT is nil, the list is sorted in the order of
buffer names."
(let ((buffers (buffer-list))
buffer rest)
(save-current-buffer
(while buffers
(set-buffer (setq buffer (pop buffers)))
(when (eq major-mode 'w3m-mode)
(push buffer rest))))
(setq buffers (if nosort
(nreverse rest)
(sort rest #'w3m-buffer-time-lessp
;; #'w3m-buffer-name-lessp
)))
(when (and (boundp 'w3m-fb-mode)
w3m-fb-mode
(if (or w3m-pop-up-frames
(not (memq 'w3m-fb-add w3m-mode-hook)))
;; `w3m-fb-mode' might have been set by something
;; other than the `w3m-fb-mode' function.
(setq w3m-fb-mode nil)
t))
;; Don't just return `w3m-fb-buffer-list' for the selected frame
;; because `buffers' may have been sorted.
(let ((fbs (w3m-fb-frame-parameter w3m-fb-list-buffers-frame
'w3m-fb-buffer-list)))
(setq rest buffers)
(while rest
(unless (memq (setq buffer (pop rest)) fbs)
(setq buffers (delq buffer buffers))))))
buffers))
任何帮助您更接近按到达时间排序的目标或请求每个w3m页面/缓冲区的信息。