Commits

Christian Ebert committed 084358e

pybrowser: detect program names reliably

- cygwin: might be called *.exe
- gopher clients might also contain a path

Comments (0)

Files changed (1)

muttils/pybrowser.py

             u.urlobject(search=False)
             self.weburl_re = u.url_re
 
+    def appname(self):
+        '''Extracts (text)browser name from /path/to/name(.exe).'''
+        return os.path.splitext(os.path.basename(self.ui.app))[0]
+
     def fixurl(self, url, cygpath):
         '''Adapts possibly short url to pass as browser argument.'''
         if not self.weburl_re or self.weburl_re.match(url):
             url = urlregex.webschemecomplete(url)
-            if url.startswith('gopher://') and self.ui.app not in gophers:
             gophers = 'lynx', 'firefox'
+            if url.startswith('gopher://') and self.appname() not in gophers:
                 # use gateway when browser is not gopher capable
                 url = url.replace('gopher://',
                                   'http://gopher.floodgap.com/gopher/gw?')
         textbrowsers = 'w3m', 'lynx', 'links', 'elinks'
         app, tb, notty, screen = '', False, False, False
         if self.ui.app is not None:
-            app = os.path.basename(self.ui.app)
+            app = self.appname()
             tb = app in textbrowsers
             if tb:
                 notty = not util.termconnected()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.