summaryrefslogtreecommitdiffstats
path: root/blog/blog-2012-05-02-2109.org
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-06-21 21:24:54 +0200
committerGravatar Tom Willemsen2012-06-21 21:24:54 +0200
commitc90daec5f4a91cf1041a5a61411d860ea4329ece (patch)
treecd8932e1dd5dacdc183a91b55ca4d5c7580e9d36 /blog/blog-2012-05-02-2109.org
downloadorgweb-c90daec5f4a91cf1041a5a61411d860ea4329ece.tar.gz
orgweb-c90daec5f4a91cf1041a5a61411d860ea4329ece.zip
Initial commit
Diffstat (limited to 'blog/blog-2012-05-02-2109.org')
-rw-r--r--blog/blog-2012-05-02-2109.org41
1 files changed, 41 insertions, 0 deletions
diff --git a/blog/blog-2012-05-02-2109.org b/blog/blog-2012-05-02-2109.org
new file mode 100644
index 0000000..defa8dd
--- /dev/null
+++ b/blog/blog-2012-05-02-2109.org
@@ -0,0 +1,41 @@
+#+TITLE: Ask for selection in emacs
+#+DESCRIPTION: Something I came across
+
+I came across an email on one of the emacs mailing lists today, where
+someone asked how to ask a user for input whilst providing
+completions. The first answer he got was to try ~tmm-prompt~, so I
+looked into it a little.
+
+I use ~mu4e~ as my primary email program, but since it isn't designed
+(seemingly) for use with multiple accounts I've got some wrapper
+functions that set some variables according to my liking and then
+start ~mu4e~. This works very well, but it's a pain to have to use
+~M-x view-ryu-mail~ or ~M-x view-ninthfloor-mail~ and such, so I wrote
+a function to read a string from the minibuffer, which I then bound to
+the ~<XF86Mail>~ key, this turned it into, for example ~<XF86Mail>
+ryu~ and ~<XF86Mail> ninthfloor~ and so on, but this doesn't have any
+completion or notification of my options.
+
+So after looking at ~tmm-prompt~ I came up with the following:
+
+#+BEGIN_SRC emacs-lisp
+(defvar oni:mailbox-map
+ '(("ryulash.org" . "ryu")
+ ("ninthfloor" . "ninthfloor"))
+ "A mailbox map for use with `tmm-prompt'.")
+
+(defun view-ryu-mail ()...)
+(defun view-ninthfloor-mail ()...)
+
+(defun view-mu ()
+ (interactive)
+ (let* ((tmm-completion-prompt "Choose a mailbox\n")
+ (inbox (tmm-prompt oni:mailbox-map)))
+ (funcall (intern (concat "view-" inbox "-mail")))))
+#+END_SRC
+
+I've left out the definitions and some mail accounts for brevity.
+
+~tmm-prompt~ is usually used when using the text-mode menu with ~M-`~,
+but it works very well here too. This changes mailbox selection to,
+for example ~<XF86Mail> r~ or ~<XF86Mail> n~.