2

I'm starting with Emacs, and testing around I wondered if I could edit my own .docx file from there, just to explore its features and that stuff.

But my surprise is huge when, having the text perfectly displayed in my screen, I can't manage to write over it. Emacs' DocView tells me that it's a read-only document, and that I have to type C-c C-c in order to edit it. That displays me the display (sorry), but I can't see where can I edit it.

Does somebody know anything about this issue? It's the first day I'm trying Emacs, but it seems quite shocking to me it can't deal with docx files.

4

The Office 2007 files are all just zipped .xml files at heart. Just rename the file with a .zip and emacs will know what to do:

mv file.docx file.zip
emacs -nw file.zip

Gives output such as:

M Filemode      Length  Date         Time      File
- ----------  --------  -----------  --------  ------------------------------
  -rw-rw-rw-      3744   1-Jan-1980  00:00:00  [Content_Types].xml
  -rw-rw-rw-       737   1-Jan-1980  00:00:00  _rels/.rels    
  -rw-rw-rw-      3184   1-Jan-1980  00:00:00  word/_rels/document.xml.rels
  -rw-rw-rw-     60108   1-Jan-1980  00:00:00  word/document.xml
  -rw-rw-rw-      1226   1-Jan-1980  00:00:00  word/footer1.xml
  -rw-rw-rw-     15183   1-Jan-1980  00:00:00  word/header3.xml

(...)

  -rw-rw-rw-     23893   1-Jan-1980  00:00:00  word/styles.xml
  -rw-rw-rw-     24646   1-Jan-1980  00:00:00  word/stylesWithEffects.xml
  -rw-rw-rw-       831   1-Jan-1980  00:00:00  word/webSettings.xml
  -rw-rw-rw-       699   1-Jan-1980  00:00:00  docProps/core.xml
- ----------  --------  -----------  --------  ------------------------------
                244649                         34 files

which you can edit as much as you want.

  • I do not need to change the file name. Opening the .docx file is enough. Not sure if it depends on version or OS, I'm using Emacs 24.3.1 on Linux OpenSuse Leap 42.2 64 bit. (editing is still not practical beyond simple corrections as the XML format is not user friendly - better use Open or LibreOffice I guess) – Rolazaro Azeveires Sep 24 '17 at 21:30
2

Emacs is a text editor, Word's .docx is a binary format for a text processing system. Sure, it would be nice if emacs used Word's keyboard shortcuts (or, even much better, the other way around). Alas, it isn't meant to be. You could redefine emacs' keyboard to simulate Word...

  • That's not the point, I mean, why can't I edit .docx files with a text editor? Sounds ironical. – xvlaze Feb 9 '16 at 6:18
  • 2
    @xvlaze, because they aren't text files. They print as text, but include formatting, fonts, sizes, organization in paragraphs, lists, ... Hop over to TeX.SE and look at some of the files discussed there. It is (mostly) LaTeX, another text processing system where you can edit the "source" format as text. It is far from what you see on the page too. – vonbrand Feb 9 '16 at 13:24
  • Oh, I didn't know that! That changes lots of things. I've seen you can access some XML files with DocView, and there's one called something like 'Document', which consists on the document itself merged with code snippets. Is there any way to retrieve this divided document into an editable one without having to get into the 'code jungle'? – xvlaze Feb 9 '16 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.