From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: [PATCH] New option to create unique, random labels for footnotes. Date: Fri, 11 Mar 2011 08:50:59 -0500 Message-ID: <87y64ji2hj.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=58870 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PylCX-0000NC-FQ for emacs-orgmode@gnu.org; Sun, 13 Mar 2011 09:19:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PylAo-0005a3-80 for emacs-orgmode@gnu.org; Sun, 13 Mar 2011 09:17:31 -0400 Received: from out5.smtp.messagingengine.com ([66.111.4.29]:44385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PylAo-0005Zx-5n for emacs-orgmode@gnu.org; Sun, 13 Mar 2011 09:17:30 -0400 Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.messagingengine.com (Postfix) with ESMTP id EC0EC208F5 for ; Sun, 13 Mar 2011 09:17:29 -0400 (EDT) Received: from archdesk (67-197-63-212.rh2.dyn.cm.comporium.net [67.197.63.212]) by mail.messagingengine.com (Postfix) with ESMTPSA id AFED2440BC8 for ; Sun, 13 Mar 2011 09:17:29 -0400 (EDT) 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: Org Mode * lisp/org-footnote.el: (org-footnote-auto-label): New random option * lisp/org-footnote.el: (org-footnote-new): Create random footnote labels with unique ids --- lisp/org-footnote.el | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 2ce6668..9dbd6be 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -113,12 +113,14 @@ t create unique labels of the form [fn:1], [fn:2], ... confirm like t, but let the user edit the created value. In particular, the label can be removed from the minibuffer, to create an anonymous footnote. +random Automatically generate a unique, random label. plain Automatically create plain number labels like [1]" :group 'org-footnote :type '(choice (const :tag "Prompt for label" nil) (const :tag "Create automatic [fn:N]" t) (const :tag "Offer automatic [fn:N] for editing" confirm) + (const :tag "Create a random label" random) (const :tag "Create automatic [N]" plain))) (defcustom org-footnote-auto-adjust nil @@ -253,16 +255,22 @@ This command prompts for a label. If this is a label referencing an existing label, only insert the label. If the footnote label is empty or new, let the user edit the definition of the footnote." (interactive) - (let* ((labels (org-footnote-all-labels)) + (let* ((labels (and (not (equal org-footnote-auto-label 'random)) + (org-footnote-all-labels))) (propose (org-footnote-unique-label labels)) (label - (if (member org-footnote-auto-label '(t plain)) - propose + (cond + ((member org-footnote-auto-label '(t plain)) + propose) + ((equal org-footnote-auto-label 'random) + (require 'org-id) + (substring (org-id-uuid) 0 8)) + (t (completing-read "Label (leave empty for anonymous): " (mapcar 'list labels) nil nil (if (eq org-footnote-auto-label 'confirm) propose nil) - 'org-footnote-label-history)))) + 'org-footnote-label-history))))) (setq label (org-footnote-normalize-label label)) (cond ((equal label "") -- 1.7.4.1