Package: w3m
Version: 0.5.3-36build2
Severity: normal
Tags: patch

Dear Maintainer,

w3m ought to obey the MarkAllPages option from the command line (or the
config file) and automatically mark all URL-like strings as links.
Instead, it currently does nothing. This is a problem because w3m is
intended to be a pager for text files as well as a browser.

Fortunately, the patch is simple and included below.

To test, try:

  echo file://`pwd`/bar > foo
  echo http://debian.org > bar
  cat foo | w3m -o mark_all_pages=1

With mark_all_pages=1, you should see the URLs as links that
you can open using Enter. 

Here is the patch that fixes w3m so that the MarkAllPages option works
as originally intended. 
----------------------------------------------------------------------

diff --git a/buffer.c b/buffer.c
index 3b2352a..e70cffe 100644
--- a/buffer.c
+++ b/buffer.c
@@ -47,6 +47,8 @@ newBuffer(int width)
 #ifdef USE_M17N
     n->auto_detect = WcOption.auto_detect;
 #endif
+    n->check_url = MarkAllPages; /* use default from -o mark_all_pages */
+    n->need_reshape = 1;        /* always reshape new buffers to mark URLs */
     return n;
 }
 
diff --git a/display.c b/display.c
index f1d6f99..e62d07f 100644
--- a/display.c
+++ b/display.c
@@ -497,6 +497,10 @@ displayBuffer(Buffer *buf, int mode)
        save_current_buf = buf;
     }
 #endif
+    if (mode == B_FORCE_REDRAW &&  (buf->check_url & CHK_URL) ) {
+       chkURLBuffer(buf);
+       displayBuffer(buf, B_NORMAL);
+    }
 }
 
 static void

----------------------------------------------------------------------




-- System Information:
Debian Release: buster/sid
  APT prefers cosmic-updates
  APT policy: (500, 'cosmic-updates'), (500, 'cosmic-security'), (500, 'cosmic')
Architecture: i386 (i686)

Kernel: Linux 4.18.0-7-generic (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages w3m depends on:
ii  libc6      2.28-0ubuntu1
ii  libgc1c2   1:7.6.4-0.4
ii  libgpm2    1.20.7-5
ii  libssl1.1  1.1.0h-4ubuntu1
ii  libtinfo6  6.1+20180210-4ubuntu1
ii  zlib1g     1:1.2.11.dfsg-0ubuntu2

Versions of packages w3m recommends:
ii  ca-certificates  20180409

Versions of packages w3m suggests:
pn  cmigemo       <none>
ii  curl          7.61.0-1
ii  dict          1.12.1+dfsg-8
pn  dict-wn       <none>
pn  dictd         <none>
ii  libsixel-bin  1.8.2-1
ii  man-db        2.8.4-2
ii  mime-support  3.60ubuntu1
ii  mpv           0.29.0-1ubuntu2
ii  w3m-el        1.4.569+0.20170110-4
pn  w3m-img       <none>
ii  wget          1.19.5-1ubuntu1
ii  xdg-utils     1.1.3-1ubuntu1
ii  xsel          1.2.0+git9bfc13d.20180109-1

-- no debconf information
diff --git a/buffer.c b/buffer.c
index 3b2352a..e70cffe 100644
--- a/buffer.c
+++ b/buffer.c
@@ -47,6 +47,8 @@ newBuffer(int width)
 #ifdef USE_M17N
     n->auto_detect = WcOption.auto_detect;
 #endif
+    n->check_url = MarkAllPages; /* use default from -o mark_all_pages */
+    n->need_reshape = 1;        /* always reshape new buffers to mark URLs */
     return n;
 }
 
diff --git a/display.c b/display.c
index f1d6f99..e62d07f 100644
--- a/display.c
+++ b/display.c
@@ -497,6 +497,10 @@ displayBuffer(Buffer *buf, int mode)
        save_current_buf = buf;
     }
 #endif
+    if (mode == B_FORCE_REDRAW &&  (buf->check_url & CHK_URL) ) {
+       chkURLBuffer(buf);
+       displayBuffer(buf, B_NORMAL);
+    }
 }
 
 static void

Reply via email to