unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs programming question
Date: Fri, 05 Oct 2012 13:57:08 +0200	[thread overview]
Message-ID: <87r4pdqgh7.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.10325.1349416176.855.help-gnu-emacs@gnu.org

Evan Driscoll <driscoll@cs.wisc.edu> writes:

> Hi,
>
> I want to write an emacs mode to display a particular type of
> file. However, the way I'd like to display the file isn't the literal
> text contents in the file, but rather a (text) rendering of parts of
> the information contained within. Unfortunately, I don't know any
> modes that do something comparable; the closest ones I can think of
> are what you get if you load an image. As a postscript I've included a
> fairly wordy description of what I'm trying to do to set some context;
> It's step (2) in that description that I foresee the most problems
> with.

There are a lot of modes that don't display the literal data.

hexl-mode
forms-mode
etc


As I see it, you have two solutions:

- when you switch to your mode, you can create a new "editing" buffer,
  where the user will give commands, and those commands will update the
  file buffer.

- you can also "parse" the buffer contents and put it in some data
  structures (kept in buffer local variables), and then show in the
  buffer any view of that data you want.  Editing commands will update
  the data structure.  Saving will unparse it into a text file.


There are more variants.  The forms-mode for example, actually use the
forms file to build a meta data structure in the forms buffer, and
actually opens another data file to be edited thru the forms buffer.


> What I want is something to the effect of opening the file normally
> but then (1) saving the contents of the buffer into a lisp variable,
> (2) clearing the buffer, (3) inserting into the buffer some computed
> contents from step (1). (Fortunately, I can set the buffer to
> read-only for my purposes and I don't have to worry about user edits
> to it.)

Indeed, you would define your own commands and key bindings to edit the
data anyways.


> [… some specs …]

Indeed, you can program anything (that's computable).

emacs lisp is a general algorithmic programming language: you can write
any program with it.  As a bonus, you have a big library for text
editing and a lot of libraries for various other things.  Don't let the
libraries obscure your view that emacs lisp is just a programming
language. You have your specifications.  Write the program.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


       reply	other threads:[~2012-10-05 11:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.10325.1349416176.855.help-gnu-emacs@gnu.org>
2012-10-05 11:57 ` Pascal J. Bourguignon [this message]
2012-10-05  3:19 Emacs programming question Evan Driscoll
2012-10-05  9:11 ` Jambunathan K
2012-10-05  9:22   ` Jambunathan K
2012-10-05 12:54 ` Doug Lewan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4pdqgh7.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).