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

Re: Bug in w3m--get-page-anchors



In [emacs-w3m:13510]
On Fri, 02 Aug 2019 00:18:32 +0200, Michael Heerdegen wrote:
> Recipe: I open some page, say, https://de.wikipedia.org/wiki/Lie-Gruppe (also
> doesn't matter), click on any anchor and get this error:

> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   string-match("\\`cite_.*[0-9]\\'" nil)
>   #f(compiled-function (x) #<bytecode 0x1559a52f6745>)((nil . 29925))
>   cl-remove
[...]
> Note the ill alist `w3m--filter-page-anchors' receives: every second key
> is nil.  It is from `w3m--get-page-anchors': see this loop:

> (while (setq pos (next-single-property-change pos 'w3m-name-anchor))
> 	(push (cons (car (get-text-property pos 'w3m-name-anchor)) pos)
> 	      anchor-list))

> `next-single-property-change' also stops where the propertized text
> ends, I think this is where the nil entries come from.

Fixed in the git master as follows.  Thank you for the reporting.

diff --git a/w3m.el b/w3m.el
index 486e55f1..d6965ba9 100644
--- a/w3m.el
+++ b/w3m.el
@@ -6628,7 +6628,8 @@ used for sites such as wikipedia."
     (when (string-match (car filter) w3m-current-url)
       (setq anchor-list
 	    (cl-remove-if
-	     (lambda (x) (string-match (cdr filter) (car x)))
+	     (lambda (x)
+	       (or (not (car x)) (string-match (cdr filter) (car x))))
 	     anchor-list)))))
 
 (defun w3m--get-page-anchors (&optional sub-sets sort-method)