[Mew-dist 08214] Re: Fw: Mew questions/suggestions

Norio Suzuki nosuzuki at example.com
1999年 3月 19日 (金) 22:36:39 JST


> On Mon, 15 Mar 1999 20:06:23 -0800
> estes at example.com(Robert Estes)  said:


estes> 2) The current interface for viewing html, or resolving urls, using
estes> mew-ext-url and mew-summary-execute-external, would work better if we could 
estes> use the remote access option under netscape, so that we could use an already 
estes> running netscape process if available.

mew-ext-url を変えて既に Netscape のブラウザーが起動しているときにはそ
れに表示させ、起動していないときには起動させるようにしています。ただ、
鯉江さんも既に書いているように、

koie> mew-ext-prog-url-args だと xxx の部分を openURL のなかに仕込めないので
koie> スクリプトをつかっています。

Python で書いたスクリプトを使っています。

.emacs に
; Use gamella.py for URL browser
(setq mew-prog-text/html     "gamella.py")
(setq mew-prog-text/html-arg nil)
(setq mew-ext-prog-url "gamella.py")
(setq mew-ext-prog-url-args nil)

と書いておいて、次のパートのスクリプト(gamella.py)を path の通ったと
ころにインストールします。(ただし、私の使っているブラウザーでは、
new-window が効きません。)
-- 
鈴木教郎
E-Mail: nosuzuki at example.com
-------------- next part --------------
#!/usr/local/bin/python
"""
Norio Suzuki <nosuzuki at example.com>
1998-12-30
Ref.
<URL:http://home.netscape.com/newsref/std/x-remote.html>
"""
import commands, os, re, sys, getopt, string, time
netscape = 'netscape'

def do(command):
    result = commands.getstatusoutput(command)
    return result[0]

def new_netscape(PLACE = ''):
    os.system("%s %s &"% (netscape, PLACE))
    time.sleep(5)

def openURL(URL, raise_window = 0, window = ''):
    if raise_window == 0:
	command = "%s -noraise"%netscape
    else:
	command = "%s -raise"%netscape

    if window != '':
	command = command + " -remote openURL\(%s, new-window\)"%URL
    else:
	command = command + " -remote openURL\(%s\)"%URL

    if do(command) != 0:
	new_netscape(URL)

def openFile(PATH, raise_window = 0):
    import tool

    PATH = tool.expand(PATH)
    if raise_window == 0:
	command = "%s -noraise"%netscape
    else:
	command = "%s -raise"%netscape

    command = command + " -remote openFILE\(%s\)"%PATH
    if do(command) != 0:
	new_netscape(PATH)

def saveAs(file, type = 'HTML', raise_window = 0):
    if raise_window == 0:
	command = "%s -noraise"%netscape
    else:
	command = "%s -raise"%netscape

    if file == '':
	command = command + " -remote saveAs\(\)"
    else:
	command = command + " -remote saveAs\(%s, %s\)"%(file, type)
    do(command)

def mailto(addresses, raise_window = 0):
    if raise_window == 0:
	command = "%s -noraise"%netscape
    else:
	command = "%s -raise"%netscape

    if type(addresses) == type([]):
	addresses = string.join(addresses, ', ')
	command = command + " -remote mailto\(%s\)"%addresses
    elif type(addresses) == type(''):
	command = command + " -remote mailto\(%s\)"%addresses	
    else:
	return
    if do(command) != 0:
	new_netscape()
	do(command)

def addBookmark(URL, title = '', raise_window = 0):
    if raise_window == 0:
	command = "%s -noraise"%netscape
    else:
	command = "%s -raise"%netscape

    if title == '':
	command = command + " -remote addBookmark\(%s\)"%URL
    else:
	command = command + " -remote addBookmark\(%s, \'%s\'\)"%(URL, title)
    if do(command) != 0:
	new_netscape()
	do(command)

def request(message, raise_window = 0):
    """
    pageup, pagedown, back, forward, home
    """
    if message == '':
	return

    if raise_window == 0:
	command = "%s -noraise"%netscape
    else:
	command = "%s -raise"%netscape

    command = command + " -remote %s"%message
    do(command)

if __name__ == '__main__':
    if len(sys.argv) == 1:
	print "Usage: gamella.py (-c request) | (URL|File)"
	print "requests are     pageup, pagedown, back, forward, home"

    else:
	print sys.argv
	(opt, args) = getopt.getopt(sys.argv[1:],'c:')
	for item in opt:
	    if item[0] == '-c':
		request(item[1])
		sys.exit(0)
	if re.match('(http|ftp|wais|gopher)://',args[0]):
	    openURL(args[0])
	elif re.match('mailto:',args[0]):
	    mailto(re.sub('^mailto:','',args[0]))
	else:
	    openFile(args[0])


Mew-dist メーリングリストの案内