From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id eCScHEUGtWauaAEAe85BDQ:P1 (envelope-from ) for ; Thu, 08 Aug 2024 17:54:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id eCScHEUGtWauaAEAe85BDQ (envelope-from ) for ; Thu, 08 Aug 2024 19:54:13 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SUF1jqVn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1723139653; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=IVAueY66He0UmLUSHLhuCWyNyHEzIpkTM7pfed5NJqo=; b=ClrMDkJipfsdEPYaLorT9Ou0zSeI8eLlM8+SJSFARwho79e8EojliK8CkeiUkCZr4gXNe+ lDcakcSNt/gWCD04pg8NuLdOXPTKRekDIKypkv3rzl7UQDqwIMq4ABvFruIcB3KhJPV4N+ vC/2GpeCkwYEpd+B/kBAKQUVNVL4x9he5vA67BIXxNvzast3m3UbDe1r6+4WwQda+57/vS y6F6KFKWTOs5HWEuJJj7Xfr2i6enempXNFwXEQGM8UwpVSEwzw0mlVAxyfxAhNDcwXbrdZ GGEmafyqz5Tc/l0PBCcKOw7Tzx/jhoFuJx2DklSp7aepJszoUrrAJYkSJL2Ffg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1723139653; a=rsa-sha256; cv=none; b=jJhyE9OcHXB3wcXtTBEcihwtAKgukYkg63g1fakiI/A0SKDEYU7n1b3YvZg/fHHbQl0XyV Y5Kfx7bEQ/rE9ts5+bo1mXzhjxrZorPuOe//AwlVeYocy9UTKtpb1erfzebWongoGoYgSd 7YyeKOJbx8TqMGwIB0q40RkFvwtB9rpmhX/sNN1xD64FtwJpbUKsh00OB31TAG3rEsMyIC cxq9v7Mw9AQvpEODBDfEdW98FG7fw7Zu1+/iVvHEP3YKNzJI2HH9znUHjSIQSCJUAS9pCf Dh9wGie9Qu/nC2Tvags8uHDiQ+ZqnjzfmK+31tBStNZNPTKUqJFqkedRbb6cjA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SUF1jqVn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" 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 0F5147CC74 for ; Thu, 08 Aug 2024 19:54:13 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sc7KM-0007ct-Us; Thu, 08 Aug 2024 13:53:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sc7KL-0007cV-CD for emacs-orgmode@gnu.org; Thu, 08 Aug 2024 13:53:29 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sc7KI-0003mg-GT for emacs-orgmode@gnu.org; Thu, 08 Aug 2024 13:53:28 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52f04150796so1573331e87.3 for ; Thu, 08 Aug 2024 10:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723139603; x=1723744403; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=IVAueY66He0UmLUSHLhuCWyNyHEzIpkTM7pfed5NJqo=; b=SUF1jqVnwDbXGRO3mLmGtgIsY8Kc998wmjYFqYwlQem6wwDNcGtsCD6ixdX2S9HMUT OI2yISSkLhl3UwgCHsuMspkny6kGIwo2bVOVkvyW7bUqTEqQWVrdW5pfU9RoMv8xtMZL C9nOY2K8gTO/74KibxpfwmCxW0E5W+rMtnyzZ+dXiHbfLY6qwAmFdlT7GEN6z/6+uQWE uP/5btEJ8q1Sv20RKDQY2BLBNMcC+qX/9mzCPLNPdWh8eMX6IL23EDUMmeySo31QK6ly HQFwsm24yCw+iQqCGpiBd0qu7yuwTKw1IgWA1P7MwddJl2ofgzB9V9zRKyuionUZT9rM GB+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723139603; x=1723744403; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=IVAueY66He0UmLUSHLhuCWyNyHEzIpkTM7pfed5NJqo=; b=PYrSCXc8sVLp3Ybvqw1rqekY+3h/MsffVOKvYB3bzgVdfN9ARcOgT2pYsKDAXe9qQ8 fltm5yCEHzFVdCx9LJzYq57VYnb84sLV4v0wcstGAK/wepzBG1GZQNIPHf5ykggHIwUT oG/HB8StGb+sW4Akt894xop2/Ll8ru3VXDnKjhosDO1ggwNQme12cDT8H62UWF/oc/rU onKtjWPN/zJYFm+hksp4UwwshGcLHTHW437R9fEtHhj2VzpJzYfEhMTZQgGC7yqVQgpc cTybVrk+ryQrnyR0HRNnPtzYaCJk/tGSgLYsst9tYfgOu7JKZFqLvydmxk8JK2o39oUF 82Ww== X-Gm-Message-State: AOJu0YyrKkdHbxa5+gommZ3YJFCROu+iMtuY12y3nnS0orf0ilZOQRjc rLUtIdAktyjdCnwJOM8xDQKLoi0S9He7rQqUd+wtIZrTwrtc8kbMM7jciQ== X-Google-Smtp-Source: AGHT+IHSoiqFqfYvLcmXviFBrzUue8+7nftgAN5vdEnPwVvc3TNlxMSsK8xMaZKt8gLb6IN+K2Hjbw== X-Received: by 2002:a05:6512:31ca:b0:530:e1f6:6eca with SMTP id 2adb3069b0e04-530e5891bf0mr1990313e87.37.1723139602700; Thu, 08 Aug 2024 10:53:22 -0700 (PDT) Received: from windows (83.6.108.108.ipv4.supernova.orange.pl. [83.6.108.108]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-530de478b8asm709805e87.254.2024.08.08.10.53.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 10:53:22 -0700 (PDT) From: =?utf-8?Q?S=C5=82awomir?= Grochowski To: emacs-orgmode@gnu.org Subject: [FR] org-colview.el, add annotation for functions summary-types Date: Thu, 08 Aug 2024 19:53:21 +0200 Message-ID: <87plqiewa6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=slawomir.grochowski@gmail.com; helo=mail-lf1-x129.google.com 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.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -6.27 X-Spam-Score: -6.27 X-Migadu-Queue-Id: 0F5147CC74 X-Migadu-Scanner: mx11.migadu.com X-TUID: u86gIJIWU/N5 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Dear all, When the user wants to add a new column (or edit an existing one), he executes the command `org-columns-new'. Then he can enter or select a few 'column attributes' (see in manual https://orgmode.org/org.html#Column-attributes-1). One of the attributes is "SUMMARY-TYPE". This attribute can be selected from the list of very enigmatic symbols such as "+", "$", "X" which do not convey any information to the user. So, I have prepared a solution that will address this issue. For each symbol, the 'docstring' of the function assigned to that symbol will be displayed. For example: "+ -- Compute the sum of VALUES." "$ -- Compute the sum of VALUES, with two decimals." What do you think about this solution? I also included a question in the commit message regarding the function `org-columns--first-line-docstring' that I created. Patch below: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-lisp-org-colview.el-add-annotation-for-summary-types.patch Content-Description: patch >From 1725dddfc6e574737f1b79f2ba93d5fa6b09cffb Mon Sep 17 00:00:00 2001 From: Slawomir Grochowski Date: Sat, 3 Aug 2024 19:53:25 +0200 Subject: [PATCH] lisp/org-colview.el: add annotation for summary-types * org-colview.el (org-columns--first-line-docstring): add function that retrieves the first line of function's docstring. I have not found a function that would do such a simple thing, it seems to me that such functionality is often used but there is no special function for it? I couldn't find one, so I wrote my own. But it is a general-purpose function and should not be located in org-colview. (org-columns--summary-types-annotate): add function that return annotation for one of the summary-type function in `org-columns-summary-types-all'. (org-columns-new): refactor: extract variable (append org-columns-summary-types org-columns-summary-types-default) to `org-columns-summary-types-all' because it is used in two places. --- lisp/org-colview.el | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index ed4d1ee16..50fb72121 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -953,6 +953,24 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column format." (goto-char (car entry)) (org-columns--display-here (cdr entry))))))))) +(defun org-columns--first-line-docstring (fun) + "Return the first line of the documentation string of FUN." + (let* ((docstring (documentation fun)) + (first-line (car (split-string docstring "\n")))) + first-line)) + +(defun org-columns--summary-types-annotate (fun) + "Return annotation for one of the FUN in `org-columns-summary-types-all'. + +If FUN is not empty, retrieves the first line of the docstring for FUN +from the `org-columns-summary-types-all', formats it, and decorates it +with the `completions-annotations` face." + (when (not (string-empty-p fun)) + (format " -- %s" + (propertize (org-columns--first-line-docstring + (cdr (assoc fun org-columns-summary-types-all))) + 'face 'completions-annotations)))) + (defun org-columns-new (&optional spec &rest attributes) "Insert a new column, to the left of the current column. Interactively fill attributes for new column. When column format @@ -980,15 +998,18 @@ details." (number-to-string (nth 2 spec)))))) (and (org-string-nw-p w) (string-to-number w))) (org-string-nw-p - (completing-read - "Summary: " - (delete-dups - (cons '("") ;Allow empty operator. - (mapcar (lambda (x) (list (car x))) - (append - org-columns-summary-types - org-columns-summary-types-default)))) - nil t (nth 3 spec))) + (let* ((completion-extra-properties + '(:annotation-function org-columns--summary-types-annotate)) + (org-columns-summary-types-all (append + org-columns-summary-types + org-columns-summary-types-default))) + (completing-read + "Summary: " + (delete-dups + (cons '("") ;Allow empty operator. + (mapcar (lambda (x) (list (car x))) + org-columns-summary-types-all))) + nil t (nth 3 spec)))) (org-string-nw-p (read-string "Format: " (nth 4 spec)))))))) (if spec -- 2.30.2 --=-=-= Content-Type: text/plain Content-Disposition: inline Regards, -- Slawomir Grochowski --=-=-=--