From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ADzACGYglmPy6QAAbAwnHQ (envelope-from ) for ; Sun, 11 Dec 2022 19:24:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mGndB2YglmPbJgAAG6o9tA (envelope-from ) for ; Sun, 11 Dec 2022 19:24:38 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 80B9516C5A for ; Sun, 11 Dec 2022 19:24:37 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id C32AE5DD5A; Sun, 11 Dec 2022 18:24:34 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 549A95DC06 for ; Sun, 11 Dec 2022 18:24:31 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 3CA455FB9E; Sun, 11 Dec 2022 13:24:30 -0500 (EST) Received: (nullmailer pid 3458671 invoked by uid 1000); Sun, 11 Dec 2022 18:24:28 -0000 From: David Bremner To: jao , notmuch@notmuchmail.org Subject: Re: [PATCH v7 1/1] emacs: notmuch-tree-outline-mode In-Reply-To: <20221104235229.515204-2-jao@gnu.org> References: <20221104235229.515204-1-jao@gnu.org> <20221104235229.515204-2-jao@gnu.org> Date: Sun, 11 Dec 2022 14:24:28 -0400 Message-ID: <87v8mhhk83.fsf@tethera.net> MIME-Version: 1.0 Message-ID-Hash: XJQKFN6DAF3V43LDBEZSXOCAWCVPQYHS X-Message-ID-Hash: XJQKFN6DAF3V43LDBEZSXOCAWCVPQYHS X-MailFrom: david@tethera.net 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 CC: jao 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-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1670783077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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; bh=xrHrJ4+YXFu0mI14IFYmAdhBTJdKRlbjCZ238mXCfV4=; b=P5KNOJUNHUg+ZrmhQTFhOh6m6mS2bepX+VmxHS1lmNta8NbEBp/SDyoEwRqMUowHFaQlRE qkQkbxRA8GB7hTOqXOXKNT6fj+aRAn9sYFmVdgyZiGnv90rl0GBEAjuMb55MoCmP0FJnxA gCdk8sAXwRn5BosVV3pQadvzHjgH64xmkRkhw5Fktdpt3ccPof4kfGk5pYP5jS+4Fot5ms 90V+gqo9+KhZQRAGOn0mxOkugJ5jZWawnMu+naaMdx59ls9EhFZlmsgfVC3pcoqpJAlZVM SwSFgzwefQTPwmtfgwVlnbMjseHcsE0pEQ+sK0mrxTmrwz+o44Y16YMUgi+cDg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670783077; a=rsa-sha256; cv=none; b=EfWicJyr/7hca+mRahoO+UblasK0hLmZhJ0qd4NCrck+4vtkrX9G6bboTqgNCoTfXnwGmv H7l7vWmUWrv/ufGl7vm9+upxZ5e2qBslKNS/LesUMNahO5rfHmuBNmXecWhb2WwG0jZoYy 45dwICi72PwSNSujnFwARQgZB3DmanzI7I9JZ8RT+L3NOAfG09YXP+6DoHI6h4B4u9H3vg sBuw3kaNVwXETs73R1bWDsZ02TdfQtTYpUtHwjl6Xzz49+Yw4bc4RqCfLd+8443lYPhDBq nNOaMSluKK762X59AmAwobhvyj5OMR8tQxqwW266ruhGmxEwc8JdV/v7xVIm3w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.76 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 80B9516C5A X-Spam-Score: -1.76 X-Migadu-Scanner: scn1.migadu.com X-TUID: +0BLTFmu3Eve jao writes: > +(defcustom notmuch-tree-outline-visibility 'hide-others > + "Default state of the forest outline for `notmuch-tree-outline-mode'. > + > +This variable controls the state of a forest initially and after > +a movement command. If set to nil, all trees are displayed while > +the symbol hide-all indicates that all trees in the forest should > +be folded and hide-other that only the first one should be Should be hide-others right? > +unfolded." > + :type '(choice (const :tag "Show all" nil) > + (const :tag "Hide others" hide-others) > + (const :tag "Hide all" hide-all))) > + > +(defcustom notmuch-tree-outline-open-on-next nil > + "Open new messages under point if they are closed when moving to next one. > + > +When this flag is set, using the command > +`notmuch-tree-outline-next' with point on a header for a new > +message that is not shown will open its `notmuch-show' buffer > +instead of moving point to next matching message." > + :type 'boolean) > + I'm curious about your choice of defaults here. At least the second seems like t might make more sense? > +(defun notmuch-tree-outline--set-visibility () > + (when (and notmuch-tree-outline-mode (> (point-max) (point-min))) > + (cond ((eq notmuch-tree-outline-visibility 'hide-others) > + (notmuch-tree-outline-hide-others)) > + ((eq notmuch-tree-outline-visibility 'hide-all) > + (outline-hide-body))))) I wouldn't insist, but cl-case (or even pcase) might be clearer here. > +(add-hook 'notmuch-tree-process-exit-functions #'notmuch-tree-outline--on-exit) Although it is relatively common in emacs code, I'm a bit skeptical of using hooks for things not intended to be customized by the user. Should we just be calling this directly somewhere? > +(defsubst notmuch-tree-outline--level (&optional props) > + (or (plist-get (or props (notmuch-tree-get-message-properties)) :level) 0)) As mentioned in my previous reply, I'm still not 100% clear on why we need both depth and level. > + > +(defsubst notmuch-tree-outline--message-open-p () > + (and (buffer-live-p notmuch-tree-message-buffer) > + (get-buffer-window notmuch-tree-message-buffer) > + (string-match-p (regexp-quote (or (notmuch-tree-get-message-id) "")) What's going with the 'or' here? Are we hiding errors? > + (buffer-name notmuch-tree-message-buffer)))) At first glance, depending on the buffer name seems fragile? > +;;;; Mode definition > +(defvar notmuch-tree-outline-mode-lighter nil > + "The lighter mark for notmuch-tree-outline mode. > +Usually empty since outline-minor-mode's lighter will be active.") I feel like I should know what a "lighter" is in this context, but alas, I don't Finally: According to a quick test, the folding does show up in (visible-buffer-string) (from test/test-lib.el). So it seems feasible to have a few tests with folded output? d