From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: ** Q: HOW TO MANIPULATE STRINGS IN A FILE WITH A LISP FUNCTION ** Date: Tue, 17 Sep 2002 17:49:37 GMT Organization: Genuity, Woburn, MA Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <9e8ebeb2.0209151930.79f76ae9@posting.google.com> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1032285360 16892 127.0.0.1 (17 Sep 2002 17:56:00 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2002 17:56:00 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17rMZq-0004OI-00 for ; Tue, 17 Sep 2002 19:55:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rMa8-00011B-00; Tue, 17 Sep 2002 13:56:16 -0400 Original-Path: shelby.stanford.edu!nntp.stanford.edu!newsfeed.stanford.edu!paloalto-snf1.gtei.net!crtntx1-snh1.gtei.net!news.gtei.net!paloalto-snr1.gtei.net.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help,gnu.utils.help,comp.unix.shell,comp.unix.programmer Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 43 Original-X-Trace: +r4CDhqkEMk8TCJahyBcS+YEW2f0mrge/Lm5GCpvnfFuNetYyFduQFYiIZSnjuDHe69m7AKYfZN9!qoC+eEvYflhfB+8jV7f3TYeFaCv+jjHzAqh6Zs7yVpwq/i34rJrE/xzFXJODAxG5D2t2dC5QH55M!C/pBrU07p1lN Original-X-Complaints-To: abuse@gte.net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Original-NNTP-Posting-Date: Tue, 17 Sep 2002 17:49:37 GMT Original-Distribution: world Original-Xref: nntp.stanford.edu gnu.emacs.help:104996 gnu.utils.help:4009 comp.unix.shell:132820 comp.unix.programmer:142861 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1551 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1551 In article <9e8ebeb2.0209151930.79f76ae9@posting.google.com>, gnuist 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, barmar@genuity.net 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.