2013-08-22 67 views
10

如何使用Emacs编辑Google云端硬盘文本文档并将我的更改反映回Google文档?使用Emacs编辑Google文档?

我发现一个Google command line program,以及gclient,它是Emacsspeak的一部分,但他们似乎需要Linux或Windows,而我在使用Aquamacs的OSX上。或者,也许我只是不明白如何安装它们。

这是可行的吗?

+1

我没有尝试,但你提到的第一个环节 - 代码是用Python编写的,所以是一个很好的机会,它会在OSX上工作。如果不是的话,那么你可能会根据自己的想法找出无效的东西。除非你尝试,否则你不会知道它需要多少努力才能使它起作用。虽然,坦率地说,我会在Org中随意编辑任何需要的内容,然后将其导出为Open Office格式并上传到Google ...除非有很多文件需要处理。 – 2013-08-23 07:38:54

回答

5

googlecl可以从macports安装。然后,您可以使用emacs server使用本地emacs打开文件。

一旦它被安装,你可以按照下面的命令:

$ google docs list   # gets a list of the files 
$ google docs get <FILE> /tmp/edit$$.txt # gets the <FILE> to /tmp/edit$$.tmp 
$ emacsclient /tmp/edit$$.tmp 
$ google docs upload /tmp/edit$$.tmp <FILE> 

然而,我发现,google docs get不工作,以及它应该。

+0

好的,我安装了googlecl。如何使用emacs服务器编辑Google文档? @ vy32 – incandescentman

+0

通过将文件读取到本地文件,使用emacsserver进行编辑,然后将其推回。 – vy32

+1

使用“google docs edit”命令会稍微简单一些。只需将'EDITOR'环境变量设置为您的emacsclient并使用'google docs编辑'。它会自动下载到临时文件并在您终止emacs客户端缓冲区时上传。被警告,这样做会删除谷歌文档中的任何格式。 – manylegged

3

没有必要提取,编辑(emacs),并推回文件。

首先在您的Mac上安装“Google Drive”。 然后您可以直接编辑文件。在〜/ Google \ Drive下查看。

+2

当我尝试在Emacs中编辑我的Google Drive文件时,这些文件是空的,看起来像![this] (http://i.imgur.com/SJTwEEg.png)http://i.imgur.com/SJTwEEg.png – incandescentman

+0

当我尝试在Emacs(foo.txt)中创建一个文本文件时,Google Drive网页界面似乎无法阅读它。 – incandescentman

0

使用GDrive的另一种选择(完全需要掌舵)

(defvar gdocs-folder-id "<gdrive folder for exported docs>" 
"location for storing org to gdocs exported files, use 'gdrive list -t <foldername>' to find the id") 

(defun gdoc-export-buffer() 
    "Export current buffer as google doc to folder irentified by gdocs-folder-id" 
    (interactive) 
    (shell-command 
    (format "gdrive upload --convert --mimetype text/plain --parent %s --file %s" 
     gdocs-folder-id buffer-file-name))) 

(defun gdoc-import-buffer (doc) 
    "Import a file in gdocs-folder-id into current buffer" 
    (interactive 
    (list 
     (completing-read "Choose one: " 
       (split-string 
        (shell-command-to-string 
        (format "gdrive list -q \"'%s' in parents\"" gdocs-folder-id)) "\n")))) 
    (insert (replace-regexp-in-string (string ?\C-m) (string ?\C-j) (shell-command-to-string 
    (format "gdrive download -s --format txt --id %s" (car (split-string doc " ")))))))