From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: My Python solution to generating unique Ids in headlines Date: Wed, 04 Mar 2009 18:59:43 -0500 Message-ID: <13242.1236211183@alphaville.usa.hp.com> References: <200903042320.n24NKDmD007471@mail11.syd.optusnet.com.au> Reply-To: nicholas.dokos@hp.com Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lf111-0005pD-WE for emacs-orgmode@gnu.org; Wed, 04 Mar 2009 19:00:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lf111-0005nr-F6 for emacs-orgmode@gnu.org; Wed, 04 Mar 2009 19:00:43 -0500 Received: from [199.232.76.173] (port=54153 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lf111-0005ne-6Z for emacs-orgmode@gnu.org; Wed, 04 Mar 2009 19:00:43 -0500 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:5748) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lf110-00059E-PS for emacs-orgmode@gnu.org; Wed, 04 Mar 2009 19:00:42 -0500 In-Reply-To: Message from Charles Cave of "Thu, 05 Mar 2009 10:20:13 +1100." <200903042320.n24NKDmD007471@mail11.syd.optusnet.com.au> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: charles_cave@optusnet.com.au Cc: emacs-orgmode@gnu.org Charles Cave wrote: > ... > print "[#%s]" % val > > > ... > > ESC-1 ESC-! nextnum RET Ctl-D > > The Ctrl D is needed to remove a carriage return (not sure why it is > there. Try import sys sys.stdout.write("[%d]" % val) instead of print. It should work on Windows as well (but I have not tested it there). > > Can someone give me Lisp code equivalent of > the command sequene above? I know it is something to do > with (shell command .... ) > (shell-command "nextnum" t) It may be necessary to specify a complete path to the command. > > The end result now looks like > > *** Post to org-mode list about next sequential [#315] :COMPUTER: > > Once I have Lisp code to implement the command sequence I will have > a satisfactory solution to generating the unique id when I need it. > But I still don't understand why you need an external program: what is wrong with (insert (format "[%s]" (org-id-new)))? Are the IDs too ugly or is there some other problem? The trouble with unique IDs in files is that it's easy for them to get out of sync (leading to non-uniqueness), e.g. if there are two processes trying to get a unique id at the same time. Nick