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

error upon load and tab navigation [PATCH included]

1] For I don't know how long, I've been getting the following errors
   logged to my *Messages* buffer when loading emacs-w3m via M-x w3m,
   and when tabbing through links / forms / images on a page.

  #+BEGIN_SRC conf
  w3m-replace-in-string: Wrong type argument:
  arrayp, nil Error in post-command-hook (w3m-check-current-position):
  (wrong-type-argument arrayp nil)

2] In the attached patch, please notice that I also removed a check
   for the existence of function `replace-regexp-in-string' and
   removed an option to alias a command to function

   My guess is that code was written at some point in the ancient past
   before `replace-regexp-in-string' became a standard part of emacs,
   and when there did exist a function called `replace-in-string'.
   That hasn't been the case since at least four years[1].

3] There are several cases similar to #2 above in `w3m-util.el' for
   which I'd be happy to provide patches if you agree that this is
   desirable. Some examples:

   3.1] line 1390: function `substring-no-properties' is defined in 'C
        source code'.

   3.2] line 1404: function `compare-strings' is defined in 'C
        source code'.

   3.3] line 1427: variable `header-line-format' is defined in 'C
        source code'.

   3.4] line 1440: function `read-number' is defined in `subr.el'

[1] https://stackoverflow.com/questions/17325713/looking-for-a-replace-in-string-function-in-elisp

CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0


CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0
--- w3m-util-orig.el	2017-07-09 23:45:06.546318328 -0400
+++ w3m-util.el	2017-07-10 00:53:54.709999784 -0400
@@ -1360,20 +1360,16 @@
       (list 'region-active-p)
     (list 'and 'transient-mark-mode 'mark-active)))
-  (cond
-   ((fboundp 'replace-regexp-in-string)
-    (defun w3m-replace-in-string  (string regexp newtext &optional literal)
+(defun w3m-replace-in-string  (string regexp newtext &optional literal)
       ;;(replace-regexp-in-string regexp newtext string nil literal)))
       ;; Don't call the symbol function `replace-regexp-in-string' directly
       ;; in order to silence the byte-compiler when an Emacs which doesn't
       ;; provide it is used.  The following form generates exactly the same
       ;; byte-code.
-      (funcall (symbol-function 'replace-regexp-in-string)
+  (when (arrayp string)
+        (funcall (symbol-function 'replace-regexp-in-string)
 	       regexp newtext string nil literal)))
-   (t
-    (defalias 'w3m-replace-in-string 'replace-in-string))))
 (defun w3m-replace-regexps-in-string (string &rest regexps)
   "In STRING replace an alist of REGEXPS."
--- ChangeLog	2017-07-10 01:27:57.477588698 -0400
+++ ChangeLog-new	2017-07-10 01:27:04.771595909 -0400
@@ -1,3 +1,10 @@
+2017-07-10  Boruch Baum  <boruch_baum@xxxxxxx>
+	* w3m-util.el (w3m-replace-in-string): Account for possiblity of nil
+	string, remove reference to obsolete emacs function
+	`replace-in-string', account for universal availability of emacs
+	function `replace-regexp-in-string'.
 2017-07-05  Katsumi Yamaoka  <yamaoka@xxxxxxx>
 	* w3m-form.el (w3m-form-input-textarea-mode-hook): Fix mismatched paren;