From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ALlaGeEFhGLY2QAAbAwnHQ (envelope-from ) for ; Tue, 17 May 2022 22:30:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CFhpGOEFhGLTDQEAG6o9tA (envelope-from ) for ; Tue, 17 May 2022 22:30:25 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (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) by aspmx1.migadu.com (Postfix) with ESMTPS id 357623926D for ; Tue, 17 May 2022 22:30:25 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4BD685F748; Tue, 17 May 2022 20:30:22 +0000 (UTC) Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37]) by mail.notmuchmail.org (Postfix) with ESMTPS id 1DB715F5E2 for ; Tue, 17 May 2022 20:30:19 +0000 (UTC) Received: from guru.guru-group.fi (unknown [IPv6:2a02:2380:1:9:5054:ff:feb7:a4bc]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id DE6E41B00240; Tue, 17 May 2022 23:30:17 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1652819418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ypoIl3JtWgyb+XPTM6QiyK4bpi8ysP67/XNoy5U3EEA=; b=YIqh7oZ/iJEP+Iw5crwcPjgVjEjajddi/xgiY84c4N34UJVdfrWhwSLX6HnuW1nUHZrc2x 1T4GWlm77mphB02jT3/2HiTyVEI0mrCUa6TkNxDNa5oXJtMxP33kcv5tzVVkIjb50FwJXm MdIz6Ryyv32nDBbjpzMmqK0HZ6rr1JU5Dc2Usl8VSge0qeeponUswNcywENt6szmD/pG3O xFzdDq/VP3Cms1yoZzjJiX/KDr56t8S9mQAvPFn235WQxB1CD/GDmJUfEahX+DJ67URoWl DNLNlfjR+YQ/rTr8dqZRuZeMVRjz93Iui8GU4Fsw6SUKmjgWJcesgFYStQWnjg== From: Tomi Ollila To: jao , notmuch@notmuchmail.org Subject: Re: [PATCH v2 1/1] emacs: notmuch-show-header-line: allow format strings and functions In-Reply-To: <20220516022039.551596-2-jao@gnu.org> References: <20220516022039.551596-1-jao@gnu.org> <20220516022039.551596-2-jao@gnu.org> User-Agent: Notmuch/0.36+7~g75125c5 (https://notmuchmail.org) Emacs/27.1 X-Face: HhBM'cA~ MIME-Version: 1.0 ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1652819418; a=rsa-sha256; cv=none; b=h4LamT/zP0lWu0UWdxrwPHtJhlAO65HG4jryqrXk15FSNBS+D/Etxxhp1PA052Mn5FNBHI F4PS4l3mQfAqFNdgBSNRVwb/GV2YjewZLuzW8CAjevkmM3BLm28uUiwI+2KqT6Ylt8YLYI oz1x1nNpdmi01wHCE65YEmZAyI7qPGTixIBfIv8y/rMutIrW4icqYktrf/1yN8Ivu0KAzM BfiIIccLPa4GrgfAu55oFvzQon73TnJLndQ3CjuFGmYJfZ+LII0qzezGjgzWvSZ+o9D74p TWg0OmG5vvpac3hKaX0dUFwE4Qxaq5KxC6OfJ669/cGNEeSoEjPkcGc05cD3ig== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1652819418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ypoIl3JtWgyb+XPTM6QiyK4bpi8ysP67/XNoy5U3EEA=; b=LTKia28VxiRz9T9iNjw+f6dCQLkoN6A3cyFIIjRfP8hRuBGhnOil5i1TyflcbuntIY3iWs ew+MtzwVM2mcvdU+JKYAX7a0SfeyPyGeZ1pWXpgIOXpg+ajU6pI9Hw7WHYbMdzmgMHyGpt kgs99VPUYzpj0pHIOP0GZJF5f+tXkIlZU5hNlmm00Lt4nD3HQNXeCqxMpIeSGB/4wdz5eV GGp/Kfot33cKSeR1tmeDRjbC/Iy+6koLfZxh8rpThNhv5rmtzVQU3EIvlkxEIip5KlYI9r O7/VFpjj2jg+9h+pjCQ2bFDDWCYpRTmvPBcXAktOW2UnFiFYKJ43zWgW61mpGQ== Message-ID-Hash: DXDZ4WQ7BPJQXNBVGGHFVJOVEKOW7JYH X-Message-ID-Hash: DXDZ4WQ7BPJQXNBVGGHFVJOVEKOW7JYH X-MailFrom: tomi.ollila@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; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652819425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=ySop8k72CHYi/i41dKNYIhYu8thN6jQp+OdwlbFPEZM=; b=h4djp46hPRDWQ6iQmLqCcG4+aTIS7UjNU5YquBgYwjarb4gUwDm/t3xmyX/Q0872WCgHrU E0i+9TLMCtHNL6if6FjgeHw3B1JwPb4i5NlyQU7osgdZZfnNb9Yg6A6b3ArrZUqa/lAPBY Z/+IGjM4FGVm/qPzdNwNoKR5IrKACMqSXcKben/GWX3Aqyj8RtPbMby9cM5uuuliBYoyzp u1otgb393QOZFDHdraSYvrvcLaIHnPP+CrXjin4LGvx56eCoTd5WFokZLNI9HAAVIcjlDN XcMKpYcmGHFfiHedo3hwLSzK++x9+wUTzSrkXzUXpdYM2CcglJ8WkeUiSc9Z/g== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1652819425; a=rsa-sha256; cv=fail; b=KgdEaiK72vlZnFiXPyFD+AgzviPh3iJhE24kd5H2ToNJdRQF9IPEcbMRSYDTdOiMJMOiR6 va1eg81rVzz9lULrCTSF+YhnWQ937I630sU+i9Y7YXJ/KgiTOYKYFDlM+xS8BvgPPBG060 0l6V0pT1RbT4jjZPiGiaozvJy2rrsYF3C4eVVxck52ENdrgDYWfwOufLIvAPtId8K9Nacj X3qrg1C5qGb9M/GLc3ouJwy7KqRyH2L1s1Pw+E6DLZOb68pjnzWIqrLYB1sESRlvGH1AXm H1ijctX+uBlz7bvKV36g+zjZke9UwCpLnefuSeTmGz3buubh1bgYuRqHZm8lzA== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b="YIqh7oZ/"; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 2.02 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=lahtoruutu header.b="YIqh7oZ/"; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 357623926D X-Spam-Score: 2.02 X-Migadu-Scanner: scn0.migadu.com X-TUID: KmtEbpGEdSKQ On Mon, May 16 2022, jao@gnu.org wrote: > If a string value is assigned to notmuch-show-header-line, it's used > as a format string to be passed passed to format-spec with `%s` > substituted by the message's subject. If a function is given, it's > called with the subject as argument, and its return value used as > header line. > > As before, t means displaying the subject and nil not using any header > line. > > Signed-off-by: jao > --- > emacs/notmuch-show.el | 37 ++++++++++++++++++++++++++++++------- > 1 file changed, 30 insertions(+), 7 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 7c1f02c9..79599480 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -85,8 +85,26 @@ visible for any given message." > :group 'notmuch-show) > > (defcustom notmuch-show-header-line t > - "Show a header line with the current message's subject." > - :type 'boolean > + "Show a header line in notmuch show buffers. > + > +If t (the default), the header line will contain the current > +message's subject. > + > +If a string, this value is interpreted as a format string to be > +passed to `format-spec` with `%s` as the substitution variable > +for the message's subject. E.g., to display the subject trimmed > +to a maximum of 80 columns, you could use \"%>-80s\" as format. > + > +If you assign to this variable a function, the function will be > +called with the subject as argument and its return value used as > +the header line. > + > +Finally, if this variabale is set to nil, no header is > +displayed." > + :type '(choice (const :tag "No header" ni) > + (const :tag "Subject" t) > + (string :tag "Format") > + (function :tag "Function")) > :group 'notmuch-show) > > (defcustom notmuch-show-relative-dates t > @@ -1351,11 +1369,16 @@ If no messages match the query return NIL." > (lambda () (notmuch-show-set-prop :orig-tags (notmuch-show-get-tags)))) > ;; Set the header line to the subject of the first message. > (when notmuch-show-header-line > - (setq header-line-format > - (replace-regexp-in-string "%" "%%" > - (notmuch-sanitize > - (notmuch-show-strip-re > - (notmuch-show-get-subject)))))) > + (let* ((s (replace-regexp-in-string "%" "%%" > + (notmuch-sanitize > + (notmuch-show-strip-re > + (notmuch-show-get-subject))))) > + (h (cond ((stringp notmuch-show-header-line) > + (format-spec notmuch-show-header-line `((?s . ,s)))) > + ((functionp notmuch-show-header-line) > + (funcall notmuch-show-header-line s)) > + (notmuch-show-header-line s)))) > + (setq header-line-format h))) To me it looks like some lines are indented with tabs and some spaces (noticed as indentation looked weird to me and then started moving cursor at the beginning of line -- there is probably a way to highlight tabs in notmuch show buffer but...) Otherwise it looks good to me (took a bit to match cond CLAUSES...) Tomi > (run-hooks 'notmuch-show-hook) > (if state > (notmuch-show-apply-state state) > -- > 2.36.1