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 8KH/BLk7P1+8FwAA0tVLHw (envelope-from ) for ; Fri, 21 Aug 2020 03:12:57 +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 mKHUALk7P18zFAAA1q6Kng (envelope-from ) for ; Fri, 21 Aug 2020 03:12:57 +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 28B269404CF for ; Fri, 21 Aug 2020 03:12:55 +0000 (UTC) Received: from localhost ([::1]:43344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8xU5-0004eL-PP for larch@yhetil.org; Thu, 20 Aug 2020 23:12:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8xTf-0004eA-1W for emacs-orgmode@gnu.org; Thu, 20 Aug 2020 23:12:27 -0400 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]:43919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k8xTc-0008KV-TJ for emacs-orgmode@gnu.org; Thu, 20 Aug 2020 23:12:26 -0400 Received: by mail-qk1-x743.google.com with SMTP id 2so301274qkf.10 for ; Thu, 20 Aug 2020 20:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=6z3kgD6iYvCNjIx6f6j118tm1HU+HZITSCZElkOAxQE=; b=OA46wNAyL8vWgGWpvBuQ1v+LZQLlaKm/XkJTbVmlybqyxmcG6JtgsL4LBZAbc4icQK bnYGDWu6w8WKx2qLbVVt1jOSfWh8dtKswDf9yhKJacI6qVhexihruzbz2p1/+2CsxAtw sisVsNcb3oWgiGzzYVpc45Od9JqshjuFVBBPgi9ibh2UDH29adWFSUtXWZ2rP2c8pY54 o6q0CSz7z8W8ISd+Rstvs+Xa8q/5ndVRmx8k5IqMJjrABOt4I58hB3RX6dnBSNYVtJmh BTDzsoHu9vfngz3qSGYpy+LE/Uy+UGaAk8+0MJ36tD94fwKw5eNDGySeaRWKKmVeZDNl 0KPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=6z3kgD6iYvCNjIx6f6j118tm1HU+HZITSCZElkOAxQE=; b=lxU9MTD/qTVo1c1U93gDHDRgP4JlbtH/v1BHXZE2x9tnp11WpIZe3GGoDk/iNwG5Pw spXu32oOf2hE6g1RPX40EaoiTUXhrbAD6WWRxIn7a7kNs5HPptJvyFaeuLsvYUYux05O CybOkYgRAuIHAgIw39lcYpYinI9921gjGLj2Ez9MGbVnFuAHgI1/073aRnNU9H/zIq1j jc2HljRlAu3GmBlvPb+BJXB8ntVAoyJDjZLBJXQ0AxyYNI14yaFQtvlGoVKr6FW5+jX0 HOrHwgx1Sjk0oExl7FlKPYlWxxl4Io09oiRgyLKqeMUL37YJNRbSFHxXHLbxQ5e69zon 21gQ== X-Gm-Message-State: AOAM530iUKrPonp3CiQcH6RHosKztdngLAdlwbH150a9GDKl7kDfA+p5 yVJ0NH2eVexpi/xjR66O5AFQEsmw5EmmhA== X-Google-Smtp-Source: ABdhPJwNA6FsRVEjQokX5nqkRMvvUT73zPiKC972KLHMfE2Zsbo6HDEsOWlt2OQLxBx2HMgeXJ3wWg== X-Received: by 2002:a37:87c3:: with SMTP id j186mr979912qkd.480.1597979543079; Thu, 20 Aug 2020 20:12:23 -0700 (PDT) Received: from arch ([2601:8b:c300:1024:1266:d0ff:1635:f964]) by smtp.gmail.com with ESMTPSA id g136sm493562qke.82.2020.08.20.20.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 20:12:21 -0700 (PDT) References: <87k0xt5fd6.fsf@gmail.com> <87tuwxyou6.fsf@gmail.com> <87tuwx3q91.fsf@localhost> User-agent: mu4e 1.5.5; emacs 28.0.50 From: No Wayman To: Ihor Radchenko Subject: Re: [PATCH] org-habit: custom consistency graph placement [9.3.7 (release_9.3.7-716-g6d5cab @ /home/n/.emacs.d/straight/build/org/)] In-reply-to: <87tuwx3q91.fsf@localhost> Date: Thu, 20 Aug 2020 23:12:20 -0400 Message-ID: <87ft8gelpn.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::743; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qk1-x743.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: , Cc: emacs-orgmode@gnu.org 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=OA46wNAy; 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: UMxpP6eiTyzb --=-=-= Content-Type: text/plain; format=flowed Ihor Radchenko writes: > As I remember, last time I played with multi-line agenda > entries, there > were issues with org-agenda-next/previous-item. You may consider > checking if your patch breaks those. Thanks for the heads up, Ihor. The patch itself shouldn't break anything and is completely optional behavior, though the example I gave in the docstring does. I ended up faking the newline with the display text-property: (defun +org-habit-graph-on-own-line (graph) "Place org habit consitency graph below the habit." (add-text-properties (line-beginning-position) (line-end-position) `(display ,(concat (when-let ((icon (car (org-agenda-get-category-icon (org-agenda-get-category))))) (format " %s " icon)) (string-trim-left (thing-at-point 'line)) (make-string (or org-habit-graph-column 0) ? ) (propertize graph 'display '(height (+ 1))))))) This works well for me so far. I've revised the docstring attachment in the attached patch. --=-=-= 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.0.0.3 >From 41ee2b974a98e0beac00a8012eab91cec948e6d5 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 | 51 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index f76f0f213..55577f442 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -104,6 +104,33 @@ 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, and is responsible for placing point on the line before the +next habit if point is moved. + +For example, to insert graphs on a new line below each habit: + +\(setq org-habit-insert-graph-function + (lambda (graph) + \"Place org habit consitency on its own line below the habit.\" + (add-text-properties + (line-beginning-position) (line-end-position) + \\=`(display ,(concat + (when-let ((icon (car (org-agenda-get-category-icon + (org-agenda-get-category))))) + + (format \" %s \" icon)) + (string-trim-left (thing-at-point \\='line)) + (make-string (or org-habit-graph-column 0) ? ) + (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 +457,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) + (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 --=-=-=--