From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OPlhJiLFPl9ORwAA0tVLHw (envelope-from ) for ; Thu, 20 Aug 2020 18:46:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8OJVIiLFPl+xEwAA1q6Kng (envelope-from ) for ; Thu, 20 Aug 2020 18:46:58 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 39FFA9403C5 for ; Thu, 20 Aug 2020 18:46:58 +0000 (UTC) Received: from localhost ([::1]:42476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8paT-0000kK-7f for larch@yhetil.org; Thu, 20 Aug 2020 14:46:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8pVl-0003C6-FI for emacs-orgmode@gnu.org; Thu, 20 Aug 2020 14:42:05 -0400 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]:33057) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k8pVi-0003Xe-3y for emacs-orgmode@gnu.org; Thu, 20 Aug 2020 14:42:05 -0400 Received: by mail-qv1-xf2d.google.com with SMTP id dd12so1420213qvb.0 for ; Thu, 20 Aug 2020 11:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=ntUPB2ZZmbnu2DehorW93cXLn8Zd68I/Zr1CLR1tSsQ=; b=nn/dLLYnkQtaP1WxWqaOO7FyMsFSCJRO2pL6JRwtmE0ghvQF4sJkm1dhC0FpJ2yr6v UnGFXCC7GP01kprod2uS0AcL7mdDo2AkLxed729nY1woQKArps5IXcg+yWPwSZ/TjvAd zgzIk3hPrHEvJKkV6OGgLgglS/f6pRDsBujvhQP4+kCjTIhsxz79RzbAeOdiyxFfo04d VPFAE543JT1LD8aFTwTo11D/5SYKD+Q0oBTUW9uQPyNEr+dMThX9gEZuUZq+F3bOlCkS o9a4LPMKXJfeZj7He5zKUmGo4Cvz2W97uyEuyM8I1ZcrteGyKngHprHo4DdtJ0tNg3lC oAiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=ntUPB2ZZmbnu2DehorW93cXLn8Zd68I/Zr1CLR1tSsQ=; b=jkBsHW7FJ3CPHl8sVzI10A1kagE+Pb69jPvV/FLJEmSKlPa4trDODG8/6j8HlEj9/a YHLC9FOHUk1XYUCoIs5xXAbSy8kMIMoJSUsxO6qitPEamc0m5EDip190P3KFlnvg8ABR wV6WLTHsi0ZiAr3XjzZitjpSWlurn0n80WpJmNHIunMO83CWZA1KVE3XQZe0JTo1zy+A llYnlkX6rpMEq8xRVvHFRYkSF6wc0Wb/a5ZmXD9M1lppoLwLN75K0M0AFMxiNKXYOW1Q KL4z2ngwWR+4zlEgqwuPrucvxlMRbkjSC40fOoR7960FyfvEmYqw572qAcOb8oQ58d+h Sdkw== X-Gm-Message-State: AOAM530nWWLdnPStboaL7wxo0zdhRUZ0YuQ08RHdng8mtVVrZU0arULr BnUzsk7CTWYRLxXP0dM18uhuc5Dtdu4YDg== X-Google-Smtp-Source: ABdhPJyeogO43pLXyCCwxJY/S9jwvQtqSIFR8APs7iWHrHQ4/pBF/DgNswZgv5Icxry4z1qbHrohdg== X-Received: by 2002:ad4:444e:: with SMTP id l14mr161490qvt.111.1597948919887; Thu, 20 Aug 2020 11:41:59 -0700 (PDT) Received: from arch ([2601:8b:c300:1024:1266:d0ff:1635:f964]) by smtp.gmail.com with ESMTPSA id s5sm3035403qke.120.2020.08.20.11.41.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 11:41:58 -0700 (PDT) User-agent: mu4e 1.5.5; emacs 28.0.50 From: No Wayman To: emacs-orgmode@gnu.org Subject: [PATCH] org-habit: custom consistency graph placement [9.3.7 (release_9.3.7-716-g6d5cab @ /home/n/.emacs.d/straight/build/org/)] Date: Thu, 20 Aug 2020 14:41:57 -0400 Message-ID: <87k0xt5fd6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qv1-xf2d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=nn/dLLYn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: incLggsv7H41 --=-=-= Content-Type: text/plain; format=flowed I like seeing a month long habit consistency graph, but this usually overwrites most of the information on each agenda habit line unless the window is particularly wide. The attached patch adds a customizable option to place the graph. I'm using it now to place each habit's graph on a new line below the habit at `org-habit-graph-column'. It makes this sort of customization very simple, e.g. (setq org-habit-insert-graph-function (lambda (graph) (goto-char (point-at-eol)) (insert "\n") (move-to-column org-habit-graph-column t) (insert graph))) Would love to see it included in org-habit. Thanks, Nicholas Vollmer --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-habit-add-custom-option-for-placing-consistency-grap.patch Content-Description: org-habit-insert-graph-function >From 6d5cabcbe15e67873a7ce489e59cff642357d8e6 Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Thu, 20 Aug 2020 13:46:49 -0400 Subject: [PATCH] habit: add custom option for placing consistency graph * lisp/org-habit.el (org-habit-insert-consistency-graphs): Add `org-habit-insert-graph-function' defcustom. Allow user to control consistency graph placement with a customizable function. See `org-habit-insert-graph-function` docstring for an example. --- lisp/org-habit.el | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index f76f0f213..64d265448 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -104,6 +104,24 @@ means of creating calendar-based reminders." :package-version '(Org . "9.3") :safe (lambda (v) (or (integerp v) (null v)))) +(defcustom org-habit-insert-graph-function nil + "Function called to place each consistency graph. +It must accept the graph string as its sole argument. +It is invoked with point on the current habit's line in the agenda buffer. + +For example, to insert graphs on a new line below the habit: + + (setq org-habit-insert-graph-function + (lambda (graph) + (goto-char (point-at-eol)) + (insert \"\\n\") + (move-to-column org-habit-graph-column t) + (insert graph))) + +If nil, the graph is inserted on the current habit's line at `org-habit-graph-column'." + :group 'org-habit + :type 'function) + (defface org-habit-clear-face '((((background light)) (:background "#8270f9")) (((background dark)) (:background "blue"))) @@ -430,17 +448,19 @@ current time." (while (not (eobp)) (let ((habit (get-text-property (point) 'org-habit-p))) (when habit - (move-to-column org-habit-graph-column t) - (delete-char (min (+ 1 org-habit-preceding-days - org-habit-following-days) - (- (line-end-position) (point)))) - (insert-before-markers - (org-habit-build-graph - habit - (time-subtract moment (days-to-time org-habit-preceding-days)) - moment - (time-add moment (days-to-time org-habit-following-days)))))) - (forward-line))))) + (let ((graph (org-habit-build-graph + habit + (time-subtract moment (days-to-time org-habit-preceding-days)) + moment + (time-add moment (days-to-time org-habit-following-days))))) + (if (functionp org-habit-insert-graph-function) + (save-excursion (funcall org-habit-insert-graph-function graph)) + (move-to-column org-habit-graph-column t) + (delete-char (min (+ 1 org-habit-preceding-days + org-habit-following-days) + (- (line-end-position) (point)))) + (insert-before-markers graph)))) + (forward-line)))))) (defun org-habit-toggle-habits () "Toggle display of habits in an agenda buffer." -- 2.28.0 --=-=-=--