unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Inserting output from a program into a buffer
Date: Mon, 22 Feb 2010 02:57:46 +0100	[thread overview]
Message-ID: <87k4u66nhh.fsf@galatea.lan.informatimago.com> (raw)
In-Reply-To: slrnho3hmd.49k.tim@bart.johnson.com

Tim Johnson <tim@johnsons-web.com> writes:

> On 2010-02-21, Tim X <timx@nospam.dev.null> 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__


  reply	other threads:[~2010-02-22  1:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-21  2:45 Inserting output from a program into a buffer Tim Johnson
2010-02-21  3:15 ` Tim Landscheidt
2010-02-21  4:45   ` Tim Johnson
2010-02-21  5:02     ` Barry Margolin
     [not found]       ` <slrnho2o6e.49k.tim@bart.johnson.com>
     [not found]         ` <87zl324774.fsf@lion.rapttech.com.au>
2010-02-22  0:45           ` Tim Johnson
2010-02-22  1:57             ` Pascal J. Bourguignon [this message]
2010-02-22  4:45               ` Tim Johnson
2010-02-22  9:41                 ` Pascal J. Bourguignon
2010-02-22 19:44                   ` Tim Johnson
2010-02-22 23:23                     ` Pascal J. Bourguignon
2010-02-23  0:44                       ` Tim Johnson
2010-02-22 23:06                 ` jpkotta
2010-02-22  7:22             ` Tim X
2010-02-21  6:28     ` tomas

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87k4u66nhh.fsf@galatea.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).