From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YMqeLAHdLF/6AwAA0tVLHw (envelope-from ) for ; Fri, 07 Aug 2020 04:48:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id KJqIKAHdLF+FZwAAB5/wlQ (envelope-from ) for ; Fri, 07 Aug 2020 04:48:01 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 31AAD9403EC for ; Fri, 7 Aug 2020 04:48:00 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3EA8728DE9; Fri, 7 Aug 2020 00:47:50 -0400 (EDT) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 1FC3A2711E for ; Fri, 7 Aug 2020 00:47:47 -0400 (EDT) Received: from mithlond.arda (mobile-access-6df022-134.dhcp.inet.fi [109.240.34.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: tlikonen) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 82E271B00B28; Fri, 7 Aug 2020 07:47:42 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1596775662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TWwt2E7wZaUucMWhpLfHa7MQWdtsABQLhir1UwnjsOw=; b=hTdGxdUAHuz1my/0hBFpWdykX7JBiRHgrU7pxZgafkSLIIZhG+m9RHbyBSc1sAQOQEMCtD s54xnwOdCyPv+YXEtM5hXVrJlBAVivO/7KX1odcAyNL+P0hVRIV829vjI48WZ2m/AqxaEG 4hF3maK5pVhRLpsUOAOVOph7PiUbPCEFE+yzpljtpHTcpBzZZWOJRvc6nsm2d2yvlUNKmZ mxtx7uQKjhYWKTuCdI4OCSskIP1JQTOq9M9Nyveam4RjN52JklD+k8+CoDnNEpNBC7adcT JohE7WsBPcHpwgQ7G6T55C7x8lrKINCsnFUdNYV2z4fRkPtuesRXjvdlCgBsJA== From: Teemu Likonen To: notmuch@notmuchmail.org Cc: David Bremner , David Edmondson , Teemu Likonen Subject: [PATCH v5] Emacs: Ensure left-to-right display for message headers Date: Fri, 7 Aug 2020 07:46:41 +0300 Message-Id: <20200807044641.3745-1-tlikonen@iki.fi> X-Mailer: git-send-email 2.20.1 In-Reply-To: <874kpfq14z.fsf@iki.fi> References: <874kpfq14z.fsf@iki.fi> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1596775662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TWwt2E7wZaUucMWhpLfHa7MQWdtsABQLhir1UwnjsOw=; b=Kd1sI/vFAmPCkjPCQNXW4VytANs9gbNaClKbYeWiPgZYO+JY1unaLHV3ELJEbDQu+cSrI4 Y7yAKyvmd+IOElHo6ptMTtmPRqSZVBwIzbbmM38x9R6e5i/a3pjz1I0LgcEVUe/79wQguB shvSTS7ygcN4vEIjFVPM9JYCoLcjdY4pvEkfm8ZKGNTchVByfZ7kZwC3PiPd8tCCI9HrSw gki81Q3bQWk+JOYfctzzs/iniOgK/lZN/++CTGIbtqH3es5/GnenUOkJzKL/wLVVN4XZCj XuMVS6c0geuJfWjeNm0KKVKxpG3Z4ioY1L72K+UvV+aotnFBM9bo0rUJhDwdNQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1596775662; a=rsa-sha256; cv=none; b=uNC8Jjxj5qm8v3Zvr6a+qTKyt54HL4bpmz4OQn1gtCmWTV6ziRnfjtzcKR8y9/D5AVO32J YDibN8jQIwZhh1zUM10XuqF3dip13CDZNFKNqKajOUrqA8buWjT92gTCCDihSDjA2h3XL+ JhihpsYaeJHLA/KekNWvbVJvqq0rCCn35aUgD84YB0OT7o6BWpTqnQLhBpQ+6cGoOMGk8H v8l3iK752mfhuBG+UJPrpozvXF2hKmwO5A327lcbqz6i0WxcSWUCl3vIGEBOuAHKLCraSc /OC+2LlKYdLvsBAljsZd7WeXV6WNWlMBC4X/4ejGft89Q92gD8pKLzAlUde/Ew== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=tlikonen smtp.mailfrom=tlikonen@iki.fi Message-ID-Hash: DTL3VFBYC75OQZDQTGQTS6FD347B7KEV X-Message-ID-Hash: DTL3VFBYC75OQZDQTGQTS6FD347B7KEV X-MailFrom: tlikonen@iki.fi X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=iki.fi header.s=lahtoruutu header.b=hTdGxdUA; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 3.03 X-TUID: 5gR1PIROtLeK In notmuch-show buffer insert invisible U+200E LEFT-TO-RIGHT MARK character at the beginning of message header paragraph if the From header contains a right-to-left character. This ensures that the header paragraph is always rendered in left-to-right mode. See Emacs Lisp reference manual section "(elisp) Bidirectional Display" for more info. --- emacs/notmuch-show.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) As the commit description says this version inserts U+200E LEFT-TO-RIGHT MARK only if the first header line (From header) contains a right-to-left character. This version is probably friendlier to the current test files which don't expect to see U+200E LEFT-TO-RIGHT MARK in the output. diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index c9170466..0eb27e33 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -466,10 +466,16 @@ unchanged ADDRESS if parsing fails." (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a message at DEPTH in the current thread." - (let ((start (point))) + (let ((start (point)) + (from (notmuch-sanitize + (notmuch-show-clean-address (plist-get headers :From))))) + (when (string-match "\\cR" from) + ;; If the From header has a right-to-left character add + ;; invisible U+200E LEFT-TO-RIGHT MARK character which forces + ;; the header paragraph as left-to-right text. + (insert (propertize (string ?\x200e) 'invisible t))) (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth)) - (notmuch-sanitize - (notmuch-show-clean-address (plist-get headers :From))) + from " (" date ") (" -- 2.20.1