@@ -98,6 +98,25 @@ def determine_sender(mail, action='reply'):
9898 return from_value , account
9999
100100
101+ def quote (ui , message = None ):
102+ if not message :
103+ tree = ui .current_buffer .get_selected_messagetree ()
104+ else :
105+ # I'm assuming the message is in the current buffer.
106+ tree = next (tree for tree in ui .current_buffer .messagetrees ()
107+ if tree ._message == message )
108+
109+ quotehook = settings .get_hook ('text_quote' )
110+ if quotehook :
111+ return quotehook (tree .get_current_text ())
112+ else :
113+ quote_prefix = settings .get ('quote_prefix' )
114+ mailcontent = ""
115+ for line in tree .get_current_text ().splitlines ():
116+ mailcontent += quote_prefix + line + '\n '
117+ return mailcontent
118+
119+
101120@registerCommand (MODE , 'reply' , arguments = [
102121 (['--all' ], {'action' : 'store_true' , 'help' : 'reply to all' }),
103122 (['--list' ], {'action' : cargparse .BooleanAction , 'default' : None ,
@@ -142,14 +161,7 @@ async def apply(self, ui):
142161 quotestring = qf (name , address , timestamp , ui = ui , dbm = ui .dbman )
143162 else :
144163 quotestring = 'Quoting %s (%s)\n ' % (name or address , timestamp )
145- mailcontent = quotestring
146- quotehook = settings .get_hook ('text_quote' )
147- if quotehook :
148- mailcontent += quotehook (self .message .accumulate_body ())
149- else :
150- quote_prefix = settings .get ('quote_prefix' )
151- for line in self .message .accumulate_body ().splitlines ():
152- mailcontent += quote_prefix + line + '\n '
164+ mailcontent = quotestring + quote (ui , self .message )
153165
154166 envelope = Envelope (bodytext = mailcontent , replied = self .message )
155167
@@ -346,18 +358,11 @@ async def apply(self, ui):
346358 timestamp = self .message .get_date ()
347359 qf = settings .get_hook ('forward_prefix' )
348360 if qf :
349- quote = qf (name , address , timestamp , ui = ui , dbm = ui .dbman )
361+ quotestring = qf (name , address , timestamp , ui = ui , dbm = ui .dbman )
350362 else :
351- quote = 'Forwarded message from %s (%s):\n ' % (
363+ quotestring = 'Forwarded message from %s (%s):\n ' % (
352364 name or address , timestamp )
353- mailcontent = quote
354- quotehook = settings .get_hook ('text_quote' )
355- if quotehook :
356- mailcontent += quotehook (self .message .accumulate_body ())
357- else :
358- quote_prefix = settings .get ('quote_prefix' )
359- for line in self .message .accumulate_body ().splitlines ():
360- mailcontent += quote_prefix + line + '\n '
365+ mailcontent = quotestring + quote (ui , self .message )
361366
362367 envelope .body = mailcontent
363368
0 commit comments