all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: use Elisp to improve your Elisp - some code issues
Date: Sun, 02 Aug 2015 18:44:06 +0200	[thread overview]
Message-ID: <87oaiptzc9.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: 87pp353doq.fsf@robertthorpeconsulting.com

Robert Thorpe <rt@robertthorpeconsulting.com> writes:

> Emanuel Berg <embe8573@student.uu.se> writes:
>
>> "Pascal J. Bourguignon" <pjb@informatimago.com>
>> writes:
>>
>>> No.
>>>
>>> I said that if you went beyond those simple case,
>>> your regexp solution would break lamentably.
>>
>> This is an interface to regexps so it sure doesn't go
>> anywhere beyond what can be expressed by regexps.
>
> I agree with Pascal & Marcin.
>
> Why not use the "read" function to read in the code of the file.  Then
> you have everything as a tree.  You can use car and cdr to walk the tree
> and find the relevant function calls.  Then you're in the right place in
> the Chomsky heirachy.

Careful, there's a reason why not to use read and instead to use
forward-sexp and other emacs editing function.

read will drop comments, newlines, indentation, etc.

Since most of the case, you will transform only some form or subform,
you may want to keep the rest of the source file intact.  Therefore
using primarily forward-sexp/down-list/up-list to navigate the source is
better. You may then use read-from-string+buffer-substring to transform
a sexp identified with forward-sexp, to process it, and insert+pp to
format it back into the buffer.


On the other hand, you may consider that comments have nothing to do in
source databases, and that pp is authoritative, and therefore use read
and pp to build an editor that will maintain the source database
automatically for yourself.  Then you always work at the sexp level.

It's probably to be able to work at the sexp level that docstrings were
invented, since even in LISP 1.5, comments existed (in the form of
comment cards).




-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk




  reply	other threads:[~2015-08-02 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.7671.1438302261.904.help-gnu-emacs@gnu.org>
2015-07-31  2:39 ` use Elisp to improve your Elisp - some code issues Pascal J. Bourguignon
2015-08-01  4:09   ` Emanuel Berg
     [not found]   ` <mailman.7712.1438402251.904.help-gnu-emacs@gnu.org>
2015-08-01  8:54     ` Pascal J. Bourguignon
2015-08-01 12:41       ` Emanuel Berg
     [not found]       ` <mailman.7727.1438432975.904.help-gnu-emacs@gnu.org>
2015-08-01 15:59         ` Pascal J. Bourguignon
2015-08-02  0:06           ` Emanuel Berg
2015-08-03  1:23             ` Ian Zimmerman
     [not found]           ` <mailman.7751.1438474104.904.help-gnu-emacs@gnu.org>
2015-08-02  0:44             ` Pascal J. Bourguignon
2015-08-02  1:29               ` Emanuel Berg
2015-08-02 15:36                 ` Robert Thorpe
2015-08-02 16:44                   ` Pascal J. Bourguignon [this message]
2015-08-05 23:40                   ` Emanuel Berg
2015-08-06  0:59                     ` John Mastro
     [not found]                 ` <mailman.7758.1438529790.904.help-gnu-emacs@gnu.org>
2015-08-02 16:25                   ` Rusi
2015-08-01 16:13       ` Michael Heerdegen
2015-07-31 20:24 ` Sam Halliday
2015-08-01  4:20   ` Emanuel Berg
2015-08-01  6:26     ` Marcin Borkowski
     [not found]     ` <mailman.7714.1438410426.904.help-gnu-emacs@gnu.org>
2015-08-01  8:57       ` Pascal J. Bourguignon
2015-08-01 12:48         ` Emanuel Berg
2015-08-01 13:05           ` Marcin Borkowski
2015-08-01 13:14             ` Emanuel Berg
2015-08-01 13:21             ` Emanuel Berg
     [not found]   ` <mailman.7713.1438402953.904.help-gnu-emacs@gnu.org>
2015-08-02 10:42     ` Sam Halliday
2015-08-05 23:21       ` Emanuel Berg
2015-07-31  0:22 Emanuel Berg
2015-07-31  2:30 ` Marcin Borkowski
2015-07-31  7:42   ` Stefan Monnier
2015-07-31 12:11   ` Navy Cheng
2015-08-03  7:56 ` Tassilo Horn

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

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

  git send-email \
    --in-reply-to=87oaiptzc9.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.