[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using format-alist
From: |
bob . hepple |
Subject: |
Re: using format-alist |
Date: |
Sat, 20 Dec 2014 15:37:30 -0800 (PST) |
User-agent: |
G2/1.0 |
On Saturday, 20 December 2014 15:43:45 UTC+10, bob.h...@gmail.com wrote:
> I'm trying to read a structured text format (gjots) into emacs org-mode - I
> have converters gjots2org and org2gjots and they do the encoding/decoding as
> filters.
>
> I had hoped that format-alist would do what I want but it can't use a file
> extension like *.gjots, so I tried this:
>
> (setq format-alist
> (cons '(gjots "gjots" nil "gjots2org" "org2gjots" t nil)
> format-alist))
> (define-derived-mode gjots-mode org-mode "gjots"
> "Major mode for editing gjots files."
> (call-process-region (point-min) (point-max) "gjots2org" t t) ; convert
> to org-mode
> (set-buffer-modified-p nil)
> (setq buffer-file-format 'gjots)) ; this is supposed to define encoding
> on write!!!
>
> .... to some extent it's working ... but when I save, it's in org-mode
> format, not gjots format.
>
> Anyone got any idea what I'm missing?
>
> Thanks
>
>
>
> Bob
... after some fiddling about and googling to
http://stackoverflow.com/questions/27184316/preprocess-postprocess-a-file-upon-visiting-and-writing-it-in-emacs/27577328#27577328
and
http://stackoverflow.com/questions/27184316/preprocess-postprocess-a-file-upon-visiting-and-writing-it-in-emacs/27577328#27577328
I arrived at this:
(setq format-alist
(cons '(gjots "gjots" nil "gjots2org" "org2gjots" t nil) format-alist))
(define-derived-mode gjots-mode org-mode "gjots"
"Major mode for editing gjots files."
(format-decode-buffer 'gjots))
(autoload 'gjots-mode "gjots-mode" "Major mode to edit gjots files." t)
(setq auto-mode-alist
(cons '("\\.gjots$" . gjots-mode) auto-mode-alist))
Only remaining problems are that I need to do a show-all before saving
(otherwise it gets "Args out of range" error) and it always prompts "Select
coding system (default raw-text):" which is a nuisance.
Any ideas on those last couple of problems?