From mboxrd@z Thu Jan 1 00:00:00 1970 From: emacs-orgmode@dunsmor.com Subject: [PATCH] Stable key assignment for org-fast-tag-selection Date: Wed, 12 Jan 2011 14:34:36 -0600 Message-ID: <8739oxc143.fsf@riotblast.dunsmor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=55316 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pd7Oy-0007iM-71 for emacs-orgmode@gnu.org; Wed, 12 Jan 2011 15:34:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pd7Ow-0000mX-OB for emacs-orgmode@gnu.org; Wed, 12 Jan 2011 15:34:40 -0500 Received: from deathroller.dunsmor.com ([98.129.169.48]:38752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pd7Ow-0000mQ-Kk for emacs-orgmode@gnu.org; Wed, 12 Jan 2011 15:34:38 -0500 Received: from riotblast.dunsmor.com (65-36-72-143.dyn.grandenetworks.net [65.36.72.143]) by deathroller.dunsmor.com (Postfix) with ESMTP id B44598C307 for ; Wed, 12 Jan 2011 14:34:15 -0600 (CST) 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: emacs-orgmode@gnu.org I noticed that the code to "automatically assign a character" in the org-fast-tag-selection function assigns a different character depending on whether or not the tag exists in the current heading. To see the problem, do the following steps: - Eval (setq org-use-fast-tag-selection t) - Eval (setq org-fast-tag-selection-single-key "expert") - Create a heading with tags :a1:a2: - Create another heading with tags :a1:a2: - Type "C-c a", "C-c a", "C-c a", "C-c a" - Notice how it changes from a1 to a2 Below is a patch to make the character assignment stable, given that all of the same tags exist in the file each time it's run. (The tabs messed up the indentation in the git-diff output.) Regards, Jason diff --git a/lisp/org.el b/lisp/org.el index b2b08ae..fd49f3e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12947,7 +12947,8 @@ possibly with grouping information. TODO-TABLE is a similar table with TODO keywords, should these have keys assigned to them. If the keys are nil, a-z are automatically assigned. Returns the new tags string, or nil to not change the current settings." - (let* ((fulltable (append table todo-table)) + (let* ((table (sort table (lambda (a b) (string< (car a) (car b))))) + (fulltable (append table todo-table)) (maxlen (apply 'max (mapcar (lambda (x) (if (stringp (car x)) (string-width (car x)) 0))