Christian Ebert avatar Christian Ebert committed 6e2a6aa

pybrowser: actually allow $BROWSER on cygwin

Comments (0)

Files changed (1)

muttils/pybrowser.py

                 url = 'file://' + url
         return url
 
+    def cygpath(self, tb):
+        '''Do we have to call cygpath to transform local path to windows file
+        system path?'''
+        if not util.cygwin() or tb:
+            return False
+        app = self.ui.app
+        if app is None:
+            try:
+                app = os.environ['BROWSER']
+            except KeyError:
+                hint = '$BROWSER environment variable required on cygwin'
+                raise util.DeadMan('cannot detect system browser', hint=hint)
+        return app.find('/cygdrive/') == 0 and app.find('/Cygwin/') < 0
+
     def urlvisit(self):
         '''Visit url(s).'''
         textbrowsers = 'w3m', 'lynx', 'links', 'elinks'
-        cygwin = util.cygwin()
-        app, tb, cygpath, notty, screen = '', False, False, False, False
+        app, tb, notty, screen = '', False, False, False
         if self.ui.app is not None:
             app = os.path.basename(self.ui.app)
             tb = app in textbrowsers
             if tb:
                 notty = not util.termconnected()
                 screen = 'STY' in os.environ
-            elif cygwin:
-                # do we have to call cygpath to transform local path to windows
-                # file system path?
-                cygpath = (self.ui.app.find('/cygdrive/') == 0 and
-                           self.ui.app.find('/Cygwin/') < 0)
-        elif cygwin:
-            #cygpath = True # not tested yet, err on safe side
-            hint = 'set the $BROWSER environment variable explicitly on cygwin'
-            raise util.DeadMan('cannot detect system browser', hint=hint)
+        cygpath = self.cygpath(tb)
         if not self.items:
             self.items = [self.ui.configitem('net', 'homepage')]
         self.items = [self.fixurl(url, cygpath) for url in self.items]
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.