aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-11-16 23:19:53 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-11-16 23:20:27 +0800
commit9aaf93f3643d974b6ad21ad324605a10589a59d0 (patch)
treef0ce4d7bf206e7c5ca698b8f52164fb6ff15eb2c
parent14fa48864a6af7766d53141a2b8711db13d77fd2 (diff)
web_config: improve abbreviations support
* Fetch abbreviations by reading the variable directly. * Use space separators for writing new abbreviations. Work on #731.
-rwxr-xr-xshare/tools/web_config/webconfig.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py
index 60d3b30d..eae7de8c 100755
--- a/share/tools/web_config/webconfig.py
+++ b/share/tools/web_config/webconfig.py
@@ -687,16 +687,11 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
return result
def do_get_abbreviations(self):
- out, err = run_fish_cmd('abbr -s')
- lines = (x for x in out.rstrip().split('\n'))
- # Turn the output into something we can use
- abbrout = (line[len('abbr -a '):].strip('\'') for line in lines)
- abbrs = [re.split('[ =]', x, maxsplit=1) for x in abbrout]
-
- if abbrs[0][0]:
- result = [{'word': x, 'phrase': y} for x, y in abbrs]
- else:
- result = []
+ out, err = run_fish_cmd('echo -n -s $fish_user_abbreviations\x1e')
+
+ lines = (x for x in out.rstrip().split('\x1e'))
+ abbrs = (re.split('[ =]', x, maxsplit=1) for x in lines if x)
+ result = [{'word': x, 'phrase': y} for x, y in abbrs]
return result
def do_remove_abbreviation(self, abbreviation):
@@ -707,7 +702,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
return True
def do_save_abbreviation(self, abbreviation):
- out, err = run_fish_cmd('abbr -a \'%s=%s\'' % (abbreviation['word'], abbreviation['phrase']))
+ out, err = run_fish_cmd('abbr -a \'%s %s\'' % (abbreviation['word'], abbreviation['phrase']))
if err:
return err
else: