@@ -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 ,
@@ -143,14 +162,7 @@ async def apply(self, ui):
143162 message = mail , ui = ui , dbm = ui .dbman )
144163 else :
145164 quotestring = 'Quoting %s (%s)\n ' % (name or address , timestamp )
146- mailcontent = quotestring
147- quotehook = settings .get_hook ('text_quote' )
148- if quotehook :
149- mailcontent += quotehook (self .message .accumulate_body ())
150- else :
151- quote_prefix = settings .get ('quote_prefix' )
152- for line in self .message .accumulate_body ().splitlines ():
153- mailcontent += quote_prefix + line + '\n '
165+ mailcontent = quotestring + quote (ui , self .message )
154166
155167 envelope = Envelope (bodytext = mailcontent , replied = self .message )
156168
@@ -347,19 +359,12 @@ async def apply(self, ui):
347359 timestamp = self .message .get_date ()
348360 qf = settings .get_hook ('forward_prefix' )
349361 if qf :
350- quote = qf (name , address , timestamp ,
351- message = mail , ui = ui , dbm = ui .dbman )
362+ quotestring = qf (name , address , timestamp ,
363+ message = mail , ui = ui , dbm = ui .dbman )
352364 else :
353- quote = 'Forwarded message from %s (%s):\n ' % (
365+ quotestring = 'Forwarded message from %s (%s):\n ' % (
354366 name or address , timestamp )
355- mailcontent = quote
356- quotehook = settings .get_hook ('text_quote' )
357- if quotehook :
358- mailcontent += quotehook (self .message .accumulate_body ())
359- else :
360- quote_prefix = settings .get ('quote_prefix' )
361- for line in self .message .accumulate_body ().splitlines ():
362- mailcontent += quote_prefix + line + '\n '
367+ mailcontent = quotestring + quote (ui , self .message )
363368
364369 envelope .body = mailcontent
365370
0 commit comments