From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Inserting output from a program into a buffer Date: Mon, 22 Feb 2010 02:57:46 +0100 Organization: Informatimago Message-ID: <87k4u66nhh.fsf@galatea.lan.informatimago.com> References: <87zl324774.fsf@lion.rapttech.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1266809727 12048 80.91.229.12 (22 Feb 2010 03:35:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Feb 2010 03:35:27 +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 04:35:22 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 1NjODz-00049u-NI for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 03:40:43 +0100 Original-Received: from localhost ([127.0.0.1]:44488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjODz-0003um-5T for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Feb 2010 21:40:43 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-X-Trace: individual.net /LcdnDiUjV/g13tTXJ7ZngqgcZzNtQXqfdeDEWKaNcT1gR/J2s Cancel-Lock: sha1:YjAxN2M0ZTUxNDNlNGNlODU3MDJiNDU3NDg2OWYyNzgwNDk5YzM2Mw== sha1:k7QQUmEQLHe/AQgyNo0LHY7zwj0= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:176957 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:71990 Archived-At: Tim Johnson writes: > On 2010-02-21, Tim X wrote: >>> Thanks >> >> I'm just interested in what the external program you need to call is and >> what it does? >> >> I only mention this as I handle some timeclock/timecard requirements I >> have using existing emacs functionality. Maybe there is an alternative >> way to approach this issue that would give a better result. > Hi Tim: > The following data structure: > [[13:22 13:41][14:50 15:04][15:58 16:03][16:53 16:58]] > Is a nested block or list recognized by the rebol programming > language. Each value: 13:22, 15:04 etc is a value of datatype "time!" > and rebol has the ability of easily doing math on such datatypes. > Regardless of what programming language that I might be working in, > I use this approach to "pipe" such a data structure to a simple > application that I have written. That application then returns > the sum, which is inserted into the buffer. (See my initial post) > > The rebol binary is very easy to install. Small footprint, no > external libraries are necessary. I would be happy to provide > the application as well as the elisp code to manipulate it. > > As for the elisp code, I now have a function that grabs the data > structure and puts it in the kill-ring. > > I now have to ask another question myself, related to this subject. > I'd like to copy _only_ the text at the car of the kill ring to a > variable, for further processing use: > Example: > alt-: (car kill-ring) => > #("[0:58 1:42 0:43 1:41]" 0 20 (fontified t) 20 21 (rear-nonsticky t > fontified t)) > How I can copy the first item > "[0:58 1:42 0:43 1:41]" > from the car of kill-ring into a variable? > Thanks again This is the first item! You can check that: (string= #("[0:58 1:42 0:43 1:41]" 0 20 (fontified t) 20 21 (rear-nonsticky t fontified t)) "[0:58 1:42 0:43 1:41]") --> t What appears as #("[0:58 1:42 0:43 1:41]" 0 20 (fontified t) 20 21 (rear-nonsticky t fontified t)) is a string, with properties. You could get a string without attribute using the function buffer-substring-no-properties instead of buffer-substring. or using gnus-string-remove-all-properties: (defun gnus-string-remove-all-properties (string) (condition-case () (let ((s string)) (set-text-properties 0 (length string) nil string) s) (error string))) but there is no reason to lose time removing them in general. -- __Pascal Bourguignon__