* using format-alist
@ 2014-12-20 5:43 bob.hepple
2014-12-20 23:37 ` bob.hepple
0 siblings, 1 reply; 2+ messages in thread
From: bob.hepple @ 2014-12-20 5:43 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: using format-alist
2014-12-20 5:43 using format-alist bob.hepple
@ 2014-12-20 23:37 ` bob.hepple
0 siblings, 0 replies; 2+ messages in thread
From: bob.hepple @ 2014-12-20 23:37 UTC (permalink / raw)
To: help-gnu-emacs
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?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-20 23:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-20 5:43 using format-alist bob.hepple
2014-12-20 23:37 ` bob.hepple
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).