From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Johnson Newsgroups: gmane.emacs.help Subject: Re: Inserting output from a program into a buffer Date: Mon, 22 Feb 2010 13:44:55 -0600 Organization: AkWebsoft Message-ID: References: <87zl324774.fsf@lion.rapttech.com.au> <87k4u66nhh.fsf@galatea.lan.informatimago.com> <87zl316218.fsf@galatea.lan.informatimago.com> Reply-To: tim@johnsons-web.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1266871252 13029 80.91.229.12 (22 Feb 2010 20:40:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Feb 2010 20:40:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Feb 22 21:40:48 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Njf5E-0003rS-1Z for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 21:40:48 +0100 Original-Received: from localhost ([127.0.0.1]:47459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Njf5D-0007fP-G7 for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 15:40:47 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Mon, 22 Feb 2010 13:44:54 -0600 Original-Newsgroups: gnu.emacs.help User-Agent: slrn/0.9.9p1 (Linux) Original-Lines: 63 Original-X-Trace: sv3-5lnLtC5CQcvUwVIJm3LiuWJb/3ed5PigukyoDV2lbmKTww5DvZ1iL9s0WoQ4uhXCypKYx7dj1SlT0kh!09HsgDRkUMr2EHQd3CWGb7nNkEIxzIKFec2bKIj0KprOBO82jXU5qjj9WvtAEGEXrMqPajc= Original-X-Complaints-To: www.supernews.com/docs/abuse.html X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Original-Xref: news.stanford.edu gnu.emacs.help:176992 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72033 Archived-At: On 2010-02-22, Pascal J. Bourguignon wrote: <...> > In general, functions don't modify variables. This would be a bad case > of side effect. In emacs lisp it would be somewhat possible, since all > var)))) > > (Notice that this effect is a design bug in LISP that was detected in > 1960 and corrected in the following years by the introduction of lexical > variables. emacs lisp is somewhat retrograde (or at least conservator) > on this point). > > > Anyways, it is a bad idea to try to modify variables from called > functions. > > > What you really need is to BIND the RESULT of buffer-string and other > functions TO a variable. This is done with LET: > > (let ((string (buffer-substring (point-min) (+ 10 (point-min))))) > (string= "Newsgroups" string)) > > --> t Pascal, the total of what you have written is valuable to me in understand programming elisp. I don't fully follow all of what you say, but I hope that it will soak in. I've now written a function that copies a delimited 'form' (sexp or other data structure) I submit it here for your comments. Your comments will no doubt further enlighten me on your insights. ;; code follows (defun tj-copy-previous-region() "Grab a symmetrically delimited data structure beginning on the same line as the cursor" (interactive) (let ((boundary(point))found end success (origin (point))) (beginning-of-line-text) (if (member (char-after) '(40 91 123)) (progn (setq found (point))) (progn (setq found(re-search-forward "(\\|\\[\\|{" boundary t)) (if found (progn (backward-char 1) (setq found (point))) (message "*** No Opening delimiter found on this line ***")))) (when found (forward-sexp) (setq end (point)) (setq success (buffer-substring found end)) (message "** RESULT: %s ***" success) (goto-char origin)) success)) ;; needs a little more factoring and I note some redundant bindings... > But who I am to say such things, I'm not RMS... :) We all owe RMS a great debt for his contributions and his passionate opinions are well known.... thanks -- Tim tim@johnsons-web.com http://www.akwebsoft.com