# -*- ~/.mutt/keybind -*-
# Keyboard bindings for mutt.
#
# Command bind :
# Syntax: bind <map> <key> <function>
# Values for <map>:
# generic, alias, attach, browser, editor, index, compose, pager, pgp, postpone
# Special values for <key>: \t, <tab>, \r, \n, \e, <esc>, <up>, <down>,
# 	<left>, <right>, <pageup>, <pagedown>, <backspace>, <delete>,
#	<insert>, \n, <home>, <end>, <space>, <f1>,...,<f10>
#
# Take care, there are some defaults hardcoded in keymap.c:km_init()
# Most defaults (Op*) are defined in functions.h.
#
# (When in w3m, type a colon (:) to have w3m convert strings that look like URLs to links.)
# I find this especially useful for viewing messages such as the Slashdot Headlines
# that contain links to other articles, so I use w3m as the pager for these messages
# by using folder-hooks...


# Generic key bindings.
bind 	generic "<"     first-entry
bind 	generic ">"     last-entry
bind 	generic <home>  first-entry
bind 	generic <end>   last-entry
bind 	generic <left>  previous-entry
bind 	generic <right> next-entry
macro 	generic <f1> 	"! less /usr/local/doc/mutt/manual.txt\n"  	"Show Mutt documentation"
macro   generic ,f	"! fetchmail\n"					"Fetch new mails"
macro 	generic \e0    	":unset display_filter\n"			"Display filter off"
macro 	generic \e1    	":set display_filter='mutt.to-filter.pl | mutt.display-filter.pl'" "Display filter on"
bind	generic " "	tag-entry
bind	generic	<insert>	tag-entry

#
# index, OpMain, MENU_MAIN
# (Main Index)
#

bind	index	<up>	previous-entry
bind	index	<left>	previous-entry
bind	index	<down>	next-entry
bind	index	<right>	next-entry
bind	index	<delete> delete-message
macro	index	<return> ":set weed\n<display-message>" 		"Display message with header weeding switched on"
macro 	index	<space>	"v<return>"					"Display message via attachments menu"
macro 	index   <f1> 	"! less /usr/local/doc/mutt/manual.txt\n"  	"Show Mutt documentation"
bind	index	^	first-entry
bind	index	°	last-entry
# bind	index	*	flag-message
bind	index	'#'	tag-entry
bind	index	=	noop
bind	index	"{"	previous-thread
bind	index	"}"	next-thread
bind	index	\t	next-unread
bind	index	,\t	previous-unread
bind 	index 	,& 	break-thread
bind 	index 	- 	collapse-thread
bind 	index 	+ 	collapse-thread
bind 	index 	_ 	collapse-all
bind 	index 	* 	collapse-all

macro	index	a	"\eC~/msg.txt\n\n!mutt.addy.add.pl\n"			"add current addy to address book"
macro	index	A	":set pipe_decode\n| mutt.aliasfrommail.py\n:source ~/.mutt/aliases\n:unset pipe_decode\n" "Create new alias from the current message"
macro	index	\ea	"!$EDITOR ~/.mutt/aliases\n:source ~/.mutt/aliases\n" 	"Edit aliases file and reload it"

macro 	index 	,b	"| mutt.netscape %s\n"					"view message in Opera"
macro	index	\eb	":set pipe_decode\n| urlview\n:unset pipe_decode\n" 	"call urlview to extract URLs out of a message"
macro 	index 	\eB 	"| w3m\n" 						"call w3m to extract URLs out of a message"
macro 	index 	\cb	"| spamassassin --report\n.<flag-message>"		"Submit message to spam-databases and train Bayes (and flag it)"
macro	index 	,\cb	"| formail -x From: | addysort >> ~/whitelist/blacklist" "Add Sender to local blacklist"

macro	index	,c	"| spam.nadc.pl -mvD\n"				"Write spam-complaint using nadc"
macro	index	\ec	"| spam.adcomplain.pl -mv\n" 			"Write spam-complaint using adcomplain"
macro	index	\eC	"| spam.ricochet.pl\n" 				"Write spam-complaint using ricochet"

macro	index	\ee	":unset weed\n:unset display-filter\n<resend-message>"	"Edit and resend message with full headers"

macro   index	,f	"! fetchmail\n."				"Fetch new mails"
macro 	index 	\ef	"| view-x-face\n"              			"View the X-Face (if there is one)."

bind	index	G	group-reply

macro	index	h	":unset weed\n<display-message>" 		"Display message with complete header"
macro 	index 	\eh 	"| mailhops.pl | less -c\n"    			"View the path of the mail."

#macro 	index 	\el    	":set invpipe_decode\n| linkify | w3m -T text/html\n:set inv pipe_decode\n" "View the message in w3m."

bind	index	n	search-next
macro	index	,n	"T~N\nN\ct.*\n"					"Un-New-ize all messages in current folder"

macro	index	p	":set weed\n<print-message>j"			"Print message without headers"
bind	index	P	recall-message
# macro	index	\cp	":unset weed\n<print-message>\n:set weed\n"	"Print message with headers"
macro	index	\cp	":unset display_filter\n:unset weed\n| fmt --prefix='>' -s -w80 | fmt -s -w80 | a2ps -B -4j -d -X iso15 --pretty-print=mail\n:set weed\n:set display_filter='mutt.to-filter.pl | mutt.display-filter.pl'\n"	"Print message with headers"

bind	index	Q	query
bind	index	\eq	query

bind	index	R	resend-message
macro	index	,r	":source ~/.mutt/main\n" 			"Reload mutt configuration"
macro	index	\er	"| gpgfetchkeys\n<exit><display-message>" 	"Request used keys from keyserver"
macro	index	\eR	"| gpgfetchkeys -f\n<exit><display-message>" 	"Request used keys from keyserver"
macro 	index 	\cr     "<clear-flag>r"					"Mark as un-replied"

bind	index	S	copy-message
macro	index 	,s	"| mutt.sigtrace.pl"				"Trace signatures"
macro	index	\es	"| spam.handling.pl\n" 				"Submit this messsage to spam databases using spam.handling"
bind	index	\cs	resend-message

macro	index	\eu	"| uudeview -\n"				"UUdecode Mail(s)"
macro 	index 	,u	",x"						"Tag all undetected spam (then press Ctrl-b to blacklist/learn it)"

bind	index	V	show-version
macro	index	\ev	"| gpg -v -o - | less -c\n" 			"View PGP key with signatures"
macro 	index 	\eV    	"| gpg --verify\n"                  		"Verify a PGP/GPG signature."

#bind	index	w	previous-page					"Page up like in less"
#macro 	index	W	":set invsmart_wrap invmarkers\n" 		"Toggle wrap stuff"
macro	index	\cw	"| sa-learn --ham --no-rebuild --single \n| formail -x From: | addysort | spam.whitelist.sh\n" 	"Add Sender to Whitelist(s) and train Bayes"

bind	index	x	sync-mailbox
macro	index	,x	"T ~d <14d !~F !~h X-Spam-Flag \n"		"Tag all unflagged messages of the past two weeks without X-SpamFlag"
macro 	index 	\cx\cs 	"| cat > ~/"                   			"Save message as textfile"
macro 	index 	,\cx	"| cat > /var/CD/Temp"				"Save message as textfile in CD/Temp"

macro 	index 	y	"<sync-mailbox><change-folder>?<toggle-mailboxes>" "'-y' screen"

#bind	index	???	read-subthread
#bind	index	???	tag-subthread
#bind	index	???	undelete-subthread
#bind	index	???	decrypt-copy
#bind	index	???	decrypt-save
#bind	index	???	search-opposite
#bind	index	???	current-top
#bind	index	???	current-middle
#bind	index	???	current-bottom




#
# pager, OpPager, MENU_PAGER
# (Message Pager)
#

macro	pager	\e\e0	":set pager_index_lines=4\n:macro pager I \\e\\e1 toggle\\ pager_index_lines\n" "internal"
macro	pager	\e\e1	":set pager_index_lines=0\n:macro pager I \\e\\e0 toggle\\ pager_index_lines\n" "internal"

bind	pager	<up>		previous-line
bind	pager	<down>		next-line
bind	pager	<pageup>	previous-page
bind	pager	<pagedown>	next-page
bind	pager	<home>		top
bind	pager	<end>		bottom
bind	pager	<left>		previous-entry
bind	pager	<right>		next-entry
bind	pager	<delete> 	delete-message
macro 	pager	<space>	"v<return>"					"Display message via attachments menu"
macro 	pager   <f1> 	"! less /usr/local/doc/mutt/manual.txt\n"  	"Show Mutt documentation"
bind	pager	^	top
bind	pager	°	bottom
bind	pager	*	flag-message
macro	pager	\;	"<exit><tag-prefix>"		"Goto index and enter tag-prefix"
#bind	pager	'#'	tag-entry
bind	pager	=	noop
bind	pager	"{"	previous-thread
bind	pager	"}"	next-thread
bind	pager	\t	next-unread
bind 	pager 	,\t	previous-unread
bind 	pager 	'"'	skip-quoted


macro 	pager 	\e0      ":unset display_filter; exec exit\n:exec display-message\n" "Display filter off"
macro 	pager 	,t       ":unset display_filter; exec exit\n:exec display-message\n" "Display filter off"
macro	pager 	\e1      ":set display_filter='mutt.to-filter.pl | mutt.display-filter.pl'; exec exit\n:exec display-message\n" "Display filter on"
macro	pager 	,T       ":set display_filter='mutt.to-filter.pl | mutt.display-filter.pl'; exec exit\n:exec display-message\n" "Display filter on"
macro 	pager 	\e2    	":set pager_index_lines=2\n"	"PIL 2"
macro 	pager 	\e3    	":set pager_index_lines=3\n" 	"PIL 3"
macro 	pager 	\e4    	":set pager_index_lines=4\n" 	"PIL 4"
macro 	pager 	\e5    	":set pager_index_lines=5\n" 	"PIL 5"
macro 	pager 	\e6    	":set pager_index_lines=6\n" 	"PIL 6"
macro 	pager 	\e7    	":set pager_index_lines=7\n" 	"PIL 7"
macro 	pager 	\e8    	":set pager_index_lines=8\n" 	"PIL 8"
macro 	pager 	\e9    	":set pager_index_lines=9\n" 	"PIL 9"

macro	pager	a	"\eC~/msg.txt\n\n!mutt.addy.add.pl\n"			"add current addy to address book"
macro	pager	A	":set pipe_decode\n|mutt.aliasfrommail.py\n:source ~/.mutt/aliases\n:unset pipe_decode\n" "Create new alias from the actual message"
macro	pager	\ea	"!$EDITOR ~/.mutt/aliases\n:source ~/.mutt/aliases\n" 	"edit aliases file and reload it"

macro 	pager 	,b	"| mutt.netscape %s\n"					"view message in Opera"
macro	pager	\eb	":set pipe_decode\n| urlview\n:unset pipe_decode\n" 	"call urlview to extract URLs out of a message"
macro 	pager 	\eB 	"| w3m\n" 						"call w3m to extract URLs out of a message"
macro 	pager 	\cb	"| spamassassin --report\n.<flag-message>"		"Submit message to spam-databases and train Bayes (and flag it)"
macro	pager 	,\cb	"| formail -x From: | addysort >> ~/whitelist/blacklist" "Add Sender to local blacklist"

macro	pager	,c	"| spam.nadc.pl -mvD\n" 			"Write spam-complaint using nadc"
macro	pager	\ec	"| spam.adcomplain.pl -mv\n" 			"Write spam-complaint using adcomplain"
macro	pager	\eC	"| spam.ricochet.pl\n" 				"Write spam-complaint using ricochet"

bind	pager	d	delete-message

macro	pager	\ee	":unset weed\n:unset display-filter\n<resend-message>"	"Edit and resend message with full headers"

macro   pager	,f	"! fetchmail\n"					"Fetch new mails"
macro	pager	\ef	"| view-x-face\n" 				"View the X-Face (if there is one)"
macro	pager	\cf	"<forget-passphrase><exit><display-message>" 	"Forget passphrase and redisplay message"

bind	pager	G	group-reply

macro	pager	I	"\e\e1" 					"toggle PIL (4/0)"

macro 	pager 	\eh 	"| mailhops.pl | less -c\n"    			"View the path of the mail."

macro	pager	l	"<exit><limit>" 				"Goto index and limit"
#macro 	pager 	\el    	":set invpipe_decode\n| linkify | w3m -T text/html\n:set inv pipe_decode\n" "View the message in w3m."

bind	pager	n	search-next

macro	pager	p	":set weed\n<print-message>j"			"Print message without headers"
bind	pager	P	recall-message
macro	pager	\cp	":unset display_filter\n:unset weed\n| fmt --prefix='>' -s -w80 | fmt -s -w80 | a2ps -B -4j -d -X iso15 --pretty-print=mail\n:set weed\n:set display_filter='mutt.to-filter.pl | mutt.display-filter.pl'\n"	"Print message with headers"

# "mutt.to-filter.pl | mutt.display-filter.pl | fmt --prefix='>' -s -w80 | fmt -s -w80 | a2ps -B -4j -X iso15 --pretty-print=mail"

macro	pager	Q	"<exit><query>" 				"Go to index and start a query."
macro	pager	\eq	"<exit><query>" 				"Go to index and start a query."

bind	pager	R	resend-message
macro	pager	,r	":source ~/.mutt/main\n" 			"Reload mutt configuration"
macro	pager	\er	"| gpgfetchkeys\n<exit><display-message>" 	"Request used keys from keyserver"
macro	pager	\eR	"| gpgfetchkeys -f\n<exit><display-message>" 	"Request used keys from keyserver"
macro 	pager 	\cr     "<clear-flag>r"					"Mark as un-replied"

bind	pager	S	copy-message
macro	pager 	,s	"| mutt.sigtrace.pl"				"Trace signatures"
macro	pager	\es	"| spam.handling.pl\n" 				"Submit this messsage to spam databases using spam.handling"
macro	pager	\eS	"| spam.myreporting\n" 				"Submit this messsage to spam databases using my reporting"
bind	pager	\cs	resend-message

bind	pager	t	display-toggle-weed

macro	pager	\eu	"| uudeview -\n" 				"uudecode mail"

bind 	pager	V	show-version
macro	pager	\ev	"| gpg -v -o - | less -c\n" 			"View PGP key with signatures"
macro 	pager 	\eV    	"| gpg --verify\n"                  		"Verify a PGP/GPG signature."

#bind	pager	w	previous-page					"Page up like in less"
macro 	pager	W	":set invsmart_wrap invmarkers\n" 		"Toggle wrap stuff"
macro	pager	\cw	"| sa-learn --ham --no-rebuild --single \n| formail -x From: | addysort | spam.whitelist.sh\n" 	"Add Sender to Whitelist(s) and train Bayes"

macro	pager	x	"<exit><sync-mailbox>" 				"Goto index and sync mailbox"
macro 	pager	\cx\cs	"| cat > ~/"                       		"Save message as textfile"
macro 	index 	,\cx	"| cat > /var/CD/Temp"				"Save message as textfile in CD/Temp"
macro	index	,x	"T ~d <14d !~F !~h X-Spam-Flag \n"		"Tag all unflagged messages of the past two weeks without X-SpamFlag"

macro 	pager	y	"<sync-mailbox><change-folder>?<toggle-mailboxes>"   "'-y' screen"

#bind	pager	???	next-subthread
#bind	pager	???	read-subthread
#bind	pager	???	undelete-subthread
#bind	pager	???	search-opposite
#bind	pager	???	previous-new
#bind	pager	???	half-up
#bind	pager	???	half-down
#bind	pager	???	decrypt-copy
#bind	pager	???	decrypt-save



#
# attach, OpAttach+OpGeneric, MENU_ATTACH
# (View Attachments Menu)
#
macro 	attach 	,b	"| mutt.netscape %s\n"					"view message in Opera"
macro	attach	\eb	":set pipe_decode\n| urlview\n:unset pipe_decode\n" 	"Call urlview to extract URLs out of a message"
macro 	attach 	\eB 	"| w3m\n" 						"Call w3m to extract URLs out of a message"
bind	attach	G	group-reply
bind	attach	i	exit
macro	attach	\el	"| less -c\n" 				"View plaintext using less"
bind	attach	p	print-entry
bind	attach	Q	exit
macro	attach	\eu	"| uudeview -\n"			"uudecode attachment"
bind	attach	v	view-attach

#bind	attach	???	search-opposite
#bind	attach	???	current-top
#bind	attach	???	current-middle
#bind	attach	???	current-bottom



#
# compose, OpCompose+OpGerneric, MENU_COMPOSE
# (Composing Menu, shows Attachments beforesending)
#

bind	compose	<insert> 	attach-file
bind	compose	<delete>	detach-file
macro	compose \ed	"<pgp-menu>a0xBD8B050D\n\n" 		"Sign with DSA key"
macro 	compose \ef	":toggle fcc_attach\r:set ?fcc_attach\r"	"Don't keep a copy of attachments (have them on the hdd anyway)"
macro	compose	\el	"| less -c\n" 				"View plain message using less"
macro	compose	\cp	"Fpgp +clearsig=on -fast\ny" 		"PGP sign mail without MIME"
macro	compose	Q	"<exit>n"				"exit and abandon message"
macro	compose \er	"<pgp-menu>a0xDD08DD6D\n\n" 		"Sign with RSA key"
#macro	compose	S	"Fpgp +clearsig=on -fast\ny^T^Uapplication/pgp; format=text; x-action=sign\n" \
#								"PGP sign mail with oldstyle MIME"
bind	compose \et	toggle-recode
bind	compose	v	view-attach

#bind	compose	???	search-opposite
#bind	compose	???	current-top
#bind	compose	???	current-middle
#bind	compose	???	current-bottom
#bind	compose \n	send-message



#
# browser, OpBrowser+OpGeneric, MENU_FOLDER
# (File-Browser. Shows files in a directory)
#
bind	browser	C	check-new
bind	browser " "	tag-entry
bind	browser	<insert>	tag-entry
#bind	browser	???	search-opposite
#bind	browser	???	current-top
#bind	browser	???	current-middle
#bind	browser	???	current-bottom



#
# alias, OpGeneric, MENU_ALIAS
# (Lists all aliases)
#
bind 	alias   <space>	tag-entry
bind 	alias   \r	select-entry
#bind	alias	???	search-opposite
#bind	alias   ???	current-top
#bind	alias   ???	current-middle
#bind	alias   ???	current-bottom



#
# pgp, OpPgp+OpGeneric, MENU_PGP
# (Lists all matching PGP Keys from Keyring)
#
bind	pgp	\cn	search-next
bind	pgp	v	view-name
#bind	pgp	???	search-opposite
#bind	pgp     ???	current-top
#bind	pgp     ???	current-middle
#bind	pgp     ???	current-bottom



#
# query, OpQuery, MENU_QUERY
# (Lists all matching Query results)
#
bind	query	Q	query
bind	query	\eq	query
#bind	query	???	search-opposite
#bind	query	???	current-top
#bind	query	???	current-middle
#bind	query	???	current-bottom



#
# <undef>, OpPost, MENU_POST
# (Postpone-Menu, lists all postponed messages)
# *not* yet configurable!!!
#
#bind	postpone	???	search-opposite
#bind	postpone	???	current-top
#bind	postpone	???	current-middle
#bind	postpone	???	current-bottom



#
# editor, OpEditor, MENU_EDITOR
# (Command line editor)
#
bind	editor	<delete> delete-char
#bind	editor	\cq	complete-query

######################## end of file ######################################