help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ** Q: HOW TO MANIPULATE STRINGS IN A FILE WITH A LISP FUNCTION **


From: Barry Margolin
Subject: Re: ** Q: HOW TO MANIPULATE STRINGS IN A FILE WITH A LISP FUNCTION **
Date: Tue, 17 Sep 2002 17:49:37 GMT

In article <address@hidden>,
gnuist <address@hidden> wrote:
>My problem is very simple for an emacs guru. More than one solution is
>very welcome.
>
>I have a list of numbers in a file as follows:
>
>ABC98789
>DDE90898889
>FRE9090909
>
>that is, first three letters and then a string of numbers and nothing else.
>
>I want to write a lisp function (not a macro) that can read the first
>three letter substring into a variable and the rest of the substring into
>another variable. Then I want to use these substrings to generate my
>final string. I know that can be done using the "insert" command. The problem
>is how to put the text strings in a file into a variable? I know setq can
>do this but then if I construct the string in sexp such as:
>
>(setq letters-variable "ABC")

(defun my-function (string)
  (let ((letters (substring str 0 3))
        (numbers (substring str 3)))
    (insert (format "The letters are %s, the numbers are %s."
                    letters numbers))))

>how do I eval it? I have tried eval-last-sexp IN THE LISP FUNCTION
>and it gives some strange result in the minibuffer when the function is run.

The minibuffer will show the return value of the expression.  It would help
if you described what you expected to happen and what actually happened,
rather than the vague "some strange result".

It seems like you need to learn Lisp.  The Emacs Lisp manual should be a
good place to start.

-- 
Barry Margolin, address@hidden
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]