From a2f077cf13d307c4d9d862028f459b783ede53cc Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 10 Dec 2012 02:22:18 +0100 Subject: Add some blog posts Also an index page that automatically generates a list of all the posts available. --- site/blog/Ask_for_selection_in_emacs.org | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 site/blog/Ask_for_selection_in_emacs.org (limited to 'site/blog/Ask_for_selection_in_emacs.org') diff --git a/site/blog/Ask_for_selection_in_emacs.org b/site/blog/Ask_for_selection_in_emacs.org new file mode 100644 index 0000000..e2bff35 --- /dev/null +++ b/site/blog/Ask_for_selection_in_emacs.org @@ -0,0 +1,42 @@ +#+TITLE: Ask for selection in Emacs +#+DATE: 2012-05-02 21:09:00 +#+TAGS: emacs elisp coding + +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 ~~ key, this turned it into, for example = ryu= +and = 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 elisp + (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 = r= or = n=. -- cgit v1.2.3-54-g00ecf