Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 214 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/nggallery.php on line 152 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/nggallery.php on line 174 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/nggallery.php on line 175 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/nggallery.php on line 208 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/autoload.php on line 8 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/autoload.php on line 9 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/autoload.php on line 10 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/autoload.php on line 11 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/autoload.php on line 12 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/autoload.php on line 13 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/router/module.router.php on line 22 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_settings/module.nextgen_settings.php on line 26 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/mvc/module.mvc.php on line 14 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/mvc/module.mvc.php on line 30 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/mvc/module.mvc.php on line 33 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ajax/module.ajax.php on line 23 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/dynamic_stylesheet/module.dynamic_stylesheet.php on line 24 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/dynamic_thumbnails/module.dynamic_thumbnails.php on line 22 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_admin/module.nextgen_admin.php on line 28 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_admin/module.nextgen_admin.php on line 31 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_gallery_display/module.nextgen_gallery_display.php on line 29 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 870 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_basic_tagcloud/module.nextgen_basic_tagcloud.php on line 26 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/module.ngglegacy.php on line 41 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/nggallery.php on line 237 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/nggallery.php on line 255 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/nggallery.php on line 257 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/on-this-day/OnThisDay.php on line 465 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 214 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/organize-series/orgSeries.php on line 92 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/organize-series/orgSeries.php on line 93 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/organize-series/orgSeries.php on line 94 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 23 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 24 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 25 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 26 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 27 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 28 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 29 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/redirection/redirection.php on line 30 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 214 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 214 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 214 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/w3-total-cache/w3-total-cache.php on line 50 Warning: require(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 219 Warning: require(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-settings.php on line 220 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-includes/functions.php on line 2905 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/wordpress-seo/wp-seo-main.php on line 94 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/wordpress-seo/wp-seo-main.php on line 269 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-includes/script-loader.php on line 566 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-includes/script-loader.php on line 51 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/wordpress-seo/wp-seo-main.php on line 94 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-blog-header.php on line 16 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-includes/template-loader.php on line 74 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-includes/template.php on line 501 Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/themes/sacha-v3/header.php on line 1 Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/wordpress-seo/wp-seo-main.php on line 94 July 20, 2008 - sacha chua :: living an awesome life

July 20, 2008

Bulk view

Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/themes/sacha-v3/date.php on line 121

Emacs: Smarter interactive prompts with Org remember templates

Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939 Warning: include_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/plugins/nextgen-gallery/pope/lib/class.component_registry.php on line 939

Paul Lussier wanted to know how to interactively prompt for a value and use that value multiple times in org-remember-templates. His example is:

(setq org-link-abbrev-alist
      '(("RT" . "https://rt/Ticket/Display.html?id=")))

(setq org-remember-templates
      '(("Tasks" ?t "* TODO %?\n  %i\n  %a"            "~/organizer.org")
        ("Appts" ?a "* Appointment: %?\n%^T\n%i\n  %a" "~/organizer.org")
        ("RT"    ?R "* [[RT:%^{Number}][%^{Number}/%^{Description}]]" "~/org/rt.org")))

The version of Org on my system prompts for Number twice. We want to store the value in an associative list somewhere so that if Org encounters another prompt with the same text, it’ll use the stored value. Here’s a diff that’ll do the trick.

diff -u /home/sachac/elisp/org/org.el /tmp/buffer-content-4571Oz1
--- /home/sachac/elisp/org/org.el	2008-07-20 11:28:54.000000000 -0400
+++ /tmp/buffer-content-4571Oz1	2008-07-20 11:42:06.000000000 -0400
@@ -12822,38 +12822,52 @@
 	    (org-set-local 'org-remember-default-headline headline))
 	;; Interactive template entries
 	(goto-char (point-min))
-	(while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t)
-	  (setq char (if (match-end 3) (match-string 3))
-		prompt (if (match-end 2) (match-string 2)))
-	  (goto-char (match-beginning 0))
-	  (replace-match "")
-	  (cond
-	   ((member char '("G" "g"))
-	    (let* ((org-last-tags-completion-table
-		    (org-global-tags-completion-table
-		     (if (equal char "G") (org-agenda-files) (and file (list file)))))
-		   (org-add-colon-after-tag-completion t)
-		   (ins (completing-read
-			 (if prompt (concat prompt ": ") "Tags: ")
-			 'org-tags-completion-function nil nil nil
-			 'org-tags-history)))
-	      (setq ins (mapconcat 'identity
-				  (org-split-string ins (org-re "[^[:alnum:]]+"))
-				  ":"))
-	      (when (string-match "\\S-" ins)
+	(let (interactive-entries lookup)
+	  (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([guUtT]\\)?" nil t)
+	    (setq char (if (match-end 3) (match-string 3))
+		  prompt (if (match-end 2) (match-string 2))
+		  lookup (assoc prompt interactive-entries))
+	    (goto-char (match-beginning 0))
+	    (replace-match "")
+	    (cond
+	     ((member char '("G" "g"))
+	      (let* ((org-last-tags-completion-table
+		      (org-global-tags-completion-table
+		       (if (equal char "G") (org-agenda-files) (and file (list file)))))
+		     (org-add-colon-after-tag-completion t)
+		     (ins (if lookup
+			      (cdr lookup)
+			    (completing-read
+			     (if prompt (concat prompt ": ") "Tags: ")
+			     'org-tags-completion-function nil nil nil
+			     'org-tags-history))))
+		(if (null lookup)
+		    (setq interactive-entries (cons (cons prompt ins) interactive-entries)))
+		(setq ins (mapconcat 'identity
+				     (org-split-string ins (org-re "[^[:alnum:]]+"))
+				     ":"))
+		(when (string-match "\\S-" ins)
 		(or (equal (char-before) ?:) (insert ":"))
 		(insert ins)
 		(or (equal (char-after) ?:) (insert ":")))))
-	   (char
-	    (setq org-time-was-given (equal (upcase char) char))
-	    (setq time (org-read-date (equal (upcase char) "U") t nil
-				      prompt))
-	    (org-insert-time-stamp time org-time-was-given
-				   (member char '("u" "U"))
-				   nil nil (list org-end-time-was-given)))
-	   (t
-	    (insert (read-string
-		     (if prompt (concat prompt ": ") "Enter string"))))))
+	     (char
+	      (setq org-time-was-given (equal (upcase char) char))
+	      (setq time (if lookup (cdr lookup) (org-read-date (equal (upcase char) "U") t nil
+								prompt)))
+	      (if (null lookup)
+		  (setq interactive-entries (cons (cons prompt time) interactive-entries))
+		(org-insert-time-stamp time org-time-was-given
+				       (member char '("u" "U"))
+				       nil nil (list org-end-time-was-given))))
+	     (t
+	      (let ((text
+		     (if lookup
+			 (cdr lookup)
+		       (read-string
+			(if prompt (concat prompt ": ") "Enter string")))))
+		(insert (or text ""))
+		(if (null lookup)
+		    (setq interactive-entries (cons (cons prompt text) interactive-entries))))))))
 	(goto-char (point-min))
 	(if (re-search-forward "%\\?" nil t)
 	    (replace-match "")

Have fun!

Warning: include(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-content/themes/sacha-v3/date.php on line 121

Emacs: BBDB: Modifying the record creation process

You might want to add fields to the record creation process in M-x bbdb-create. In addition to asking for name, company, e-mail address, addresses, phone numbers, and notes, you may want to make sure you remember to put in birthdates or other information. If you want to prompt for custom fields after the regular BBDB creation form, modify this simple example to suit your needs:

(defadvice bbdb-read-new-record (after wicked activate)
  "Prompt for the birthdate as well."
  (bbdb-record-putprop ad-return-value 'birthdate
		       (bbdb-read-string "Birthdate (YYYY.MM.DD): ")))

Thanks to Kaleb Yilma for the question!

Warning: require_once(): Unable to allocate memory for pool. in /var/www/sachachua.com/blog/wp-includes/template.php on line 501