From 12ec4f4b67435c173e9190d64c582c7ae80002c4 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 4 May 2009 16:06:33 +0200 Subject: [PATCH] Remember: Force selection of a valid template Scot Beker writes: > I have org-remember working successfully (I can't believe that it took > me so long to experiment with it. It has made a huge difference in my > work). > > But if, after calling the extension with C-c r, I type a "wrong" tag > selector (e.g. I mistype a right one), I get > (1) the error message 'no template' (good) > (2) a remember buffer without a bullet point, with the point at the > very top of the file (sure, what do I expect?) > (3) but, having realized my mistake, I can't get out of it gracefully. > I can't abort (C-c C-k), and can't (C-c C-c). > I get the error message "Args out of range 0, 1" > > Any idea whether I've set something up wrong or if org just has no > mercy on those who can't manage to type one of the selected values? > Otherwise, org-remember works well. This situation is now avoided by forcing the selection of a valid template. --- lisp/ChangeLog | 3 +++ lisp/org-remember.el | 39 +++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d3c3b089e..9091e6798 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2009-05-04 Carsten Dominik + * org-remember.el (org-select-remember-template): For the + selection of a valid template. + * org-latex.el (org-export-region-as-latex): Supply the force-no-subtree argument. (org-export-as-latex): Provide better limits when exporting the diff --git a/lisp/org-remember.el b/lisp/org-remember.el index 60d7563ee..6e4d7d226 100644 --- a/lisp/org-remember.el +++ b/lisp/org-remember.el @@ -318,6 +318,7 @@ RET at beg-of-buf -> Append to file as level 2 headline (append (list (nth 1 x) (car x)) (cddr x)) (append (list (car x) "") (cdr x)))) (delq nil pre-selected-templates2))) + msg (char (or use-char (cond ((= (length templates) 1) @@ -328,22 +329,32 @@ RET at beg-of-buf -> Append to file as level 2 headline (string-to-char org-force-remember-template-char) org-force-remember-template-char)) (t - (message "Select template: %s" - (mapconcat - (lambda (x) - (cond - ((not (string-match "\\S-" (nth 1 x))) - (format "[%c]" (car x))) - ((equal (downcase (car x)) - (downcase (aref (nth 1 x) 0))) - (format "[%c]%s" (car x) - (substring (nth 1 x) 1))) - (t (format "[%c]%s" (car x) (nth 1 x))))) - templates " ")) - (let ((inhibit-quit t) (char0 (read-char-exclusive))) + (setq msg (format + "Select template: %s" + (mapconcat + (lambda (x) + (cond + ((not (string-match "\\S-" (nth 1 x))) + (format "[%c]" (car x))) + ((equal (downcase (car x)) + (downcase (aref (nth 1 x) 0))) + (format "[%c]%s" (car x) + (substring (nth 1 x) 1))) + (t (format "[%c]%s" (car x) (nth 1 x))))) + templates " "))) + (let ((inhibit-quit t) char0) + (while (not char0) + (message msg) + (setq char0 (read-char-exclusive)) + (when (and (not (assoc char0 templates)) + (not (equal char0 ?\C-g))) + (message "No suche template \"%c\"" char0) + (ding) (sit-for 1) + (setq char0 nil))) (when (equal char0 ?\C-g) (jump-to-register remember-register) - (kill-buffer remember-buffer)) + (kill-buffer remember-buffer) + (error "Abort")) char0)))))) (cddr (assoc char templates)))))