|
|
Up |
  |
Author: srinik001srinik001 Date: Apr 21, 2008 19:28
Hello,
I would really appreciate some help on this. I am trying to do just
about everything with Emacs (and Emacs Lisp) these days. One of the
things I need to do in my job is to create XML files. I thought I
would use Emacs rather than some other editor/tool.
So, I am trying to write a tool that will enable me to write specific
XML files by prompting me to enter values. Here is how I am trying to
do it.
First, I set a variable that will provide a "grammar" for my file that
Emacs will help me write. An example is the following : of course, my
actual problem is not about generating English sentences; this is just
for illustration.
(setq grammar '((sentence <- subject predicate)
(subject <- article noun)
(predicate <- verb)))
I expect to generate functions that look like this:
|
| Show full article (1.67Kb) |
| 15 Comments |
|
  |
Author: srinik001srinik001 Date: Apr 21, 2008 22:19
Oops... I got the subject wrong. Instead of
" Using setq to obtain a symbol from a list, so that I can assign a
function to it", it should read, "Using setq to assign value to the
result of a function". Sorry about that.
Regards,
SK
|
| |
| no comments |
|
  |
Author: Barry MargolinBarry Margolin Date: Apr 22, 2008 05:54
In article
y18g2000pre.googlegroups.com>,
srinik001@hotmail.com wrote:
> Oops... I got the subject wrong. Instead of
>
> " Using setq to obtain a symbol from a list, so that I can assign a
> function to it", it should read, "Using setq to assign value to the
> result of a function". Sorry about that.
Use set instead of setq.
--
Barry Margolin, barmar@ alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|
| |
| no comments |
|
  |
Author: Ted ZlatanovTed Zlatanov Date: Apr 22, 2008 08:22
On Mon, 21 Apr 2008 19:28:03 -0700 (PDT) srinik001@ hotmail.com wrote:
s> So, I am trying to write a tool that will enable me to write specific
s> XML files by prompting me to enter values. Here is how I am trying to
s> do it.
You may want to look at the various templating packages available, in
case one of them does what you want. Check out skeleton.el in
particular ( http://www.emacswiki.org/cgi-bin/wiki/SkeletonMode for some
examples) since any element of the template can itself be a template.
That will probably save you a lot of time.
Anytime you find yourself auto-generating functions you should wonder if
your data structure could be better (sometimes the answer is 'no' :)
Ted
|
| |
| no comments |
|
  |
Author: Pascal BourguignonPascal Bourguignon Date: Apr 22, 2008 11:33
Ted Zlatanov lifelogs.com> writes:
> On Mon, 21 Apr 2008 19:28:03 -0700 (PDT) srinik001@ hotmail.com wrote:
>
>> So, I am trying to write a tool that will enable me to write specific
>> XML files by prompting me to enter values. Here is how I am trying to
>> do it.
>
> You may want to look at the various templating packages available, in
> case one of them does what you want. Check out skeleton.el in
> particular ( http://www.emacswiki.org/cgi-bin/wiki/SkeletonMode for some
> examples) since any element of the template can itself be a template.
> That will probably save you a lot of time.
>
> Anytime you find yourself auto-generating functions you should wonder if
> your data structure could be better (sometimes the answer is 'no' :)
Well, I wouldn't be so categoric. You could start by writting an
"interpreter" of your data, but generating lisp is like implementing
the "compiler", so I don't see much difference. It's so easy to do it
in lisp, that you can go directly to the "compiler".
|
| Show full article (1.24Kb) |
| no comments |
|
  |
Author: Pascal BourguignonPascal Bourguignon Date: Apr 22, 2008 12:55
> Hello,
>
> I would really appreciate some help on this. I am trying to do just
> about everything with Emacs (and Emacs Lisp) these days. One of the
> things I need to do in my job is to create XML files...
|
| Show full article (7.34Kb) |
| no comments |
|
  |
Author: Timothy HobbsTimothy Hobbs Date: Apr 22, 2008 20:11
Pascal Bourguignon informatimago.com> writes:
> but it's probably better to but these function in a hash-table than in
> the value slots of the symbols.
I am curious, why would this be better? I find that when an elisp program defines functions outside of the standard lisp symbols reading and modifying them becomes difficult or impossible. In the simplest scenario, simply finding out how functionality is implemented, I cannot use C-h f to jump to the doc string and ultimately, through that handy little hyperlink, source code. In a more involved case, I cannot advise, or redefine the function.
> Finally, emacs is not modal. It would not be very emacs-like to do
> M-x xml-insert/document RET and to be prompted for half a hour to
> insert a whole document. Instead, you could do something like
> customize-variable. Try for example M-x customize-variable RET
> lisp-source-modes RET Most of the buffer is read-only, and there are
> left some area you can edit. There are some buttons, to insert or
> remove repeatitive areas. You could have a look at the sources of
> customize-variable to see how it's done and implement your structural
> editor like this.
I just thought I would endose msf-abbrev-mode here.
Thank you
Timothy Hobbs
|
| |
| no comments |
|
  |
Author: Barry MargolinBarry Margolin Date: Apr 22, 2008 21:06
In article gnu.org>,
Timothy Hobbs gmail.com> wrote:
> Pascal Bourguignon informatimago.com> writes:
>> but it's probably better to but these function in a hash-table than in
>> the value slots of the symbols.
> I am curious, why would this be better? I find that when an elisp program
> defines functions outside of the standard lisp symbols reading and modifying
> them becomes difficult or impossible. In the simplest scenario, simply
> finding out how functionality is implemented, I cannot use C-h f to jump to
> the doc string and ultimately, through that handy little hyperlink, source
> code. In a more involved case, I cannot advise, or redefine the function.
Most of these things are unlikely to be done for dynamically-generated
functions that are internal to an application like this. There's no
source code for that "handy little hyperlink" to point to, because the
function was created on the fly.
|
| Show full article (1.17Kb) |
| no comments |
|
  |
Author: srinik001srinik001 Date: Apr 22, 2008 21:40
On Apr 22, 5:54 am, Barry Margolin alum.mit.edu> wrote:
> In article
> y18g2000pre.googlegroups.com>,
>
> srinik...@hotmail.com wrote:
>> Oops... I got the subject wrong. Instead of
>
>> " Using setq to obtain a symbol from a list, so that I can assign a
>> function to it", it should read, "Using setq to assign value to the
>> result of a function". Sorry about that.
>
> Use set instead of setq.
>
> --
> Barry Margolin, bar...@ alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***
|
| Show full article (2.24Kb) |
| no comments |
|
  |
Author: Kevin RodgersKevin Rodgers Date: Apr 22, 2008 22:10
> Oops... I got the subject wrong. Instead of
>
> " Using setq to obtain a symbol from a list, so that I can assign a
> function to it", it should read, "Using setq to assign value to the
> result of a function". Sorry about that.
Use set instead of setq:
|
| Show full article (1.06Kb) |
| no comments |
|
|
|
|