From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id IHzqMhbnOWNH0AAAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 21:31:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id OG3XMhbnOWNvBQAAauVa8A (envelope-from ) for ; Sun, 02 Oct 2022 21:31:34 +0200 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 4B8451F9B3 for ; Sun, 2 Oct 2022 21:31:34 +0200 (CEST) Received: from localhost ([::1]:54258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1of4gW-0003Dx-J5 for larch@yhetil.org; Sun, 02 Oct 2022 15:31:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1of4g2-0003Dk-HE for emacs-orgmode@gnu.org; Sun, 02 Oct 2022 15:31:02 -0400 Received: from relay.itccanarias.org ([62.174.94.111]:50632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1of4fy-00070N-MP for emacs-orgmode@gnu.org; Sun, 02 Oct 2022 15:31:00 -0400 Received: from localhost (localhost [127.0.0.1]) by relay.itccanarias.org (Postfix) with ESMTP id 315934A105 for ; Sun, 2 Oct 2022 20:30:47 +0100 (WEST) X-Virus-Scanned: Debian amavisd-new at itccanarias.org Received: from relay.itccanarias.org ([127.0.0.1]) by localhost (gwmail-tf.corp.itccanarias.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xOlBXiReUDAc for ; Sun, 2 Oct 2022 20:30:45 +0100 (WEST) Received: from Erasure.corp.itccanarias.org (erasure.corp.itccanarias.org [10.141.187.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by relay.itccanarias.org (Postfix) with ESMTPS id B4A9B4A103 for ; Sun, 2 Oct 2022 20:30:45 +0100 (WEST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.itccanarias.org B4A9B4A103 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline DKIM-Signature: v=1; a=rsa-sha256; d=itccanarias.org; s=default; c=relaxed/relaxed; t=1664739045; h=from:subject:to:date:message-id; bh=wd1c/itE9NWfQq1+rvsUIknQhBa4B0NVnhSOYnYay6o=; b=dRwE09oK4VJLPCq3/HhuqUIN7S7dRyMjBLN04yt99IWYfu4ji7QRfQqmWwW4UQ46zNX55lzSxxP 4avpb9qdKnFo80AAtcUHNiE+TCdZ2lyDni6iqCWX3yRgZUKAIB2XX2WPZSHVTDCuzKkcD/T77NkwF Bthzq302RaRkPO9LxpoHjdZYkh5OnHOPrY35WcqAdq1vYkL2lOKE2ClN60dsWjDR1wOaUp4Cbudbr xygGcjN0bTrOFeboC7ghRsyWR7cf6JF77XKGbbKltlfBgnVZPZtCAMeccV9TX33tfs1qGxYmkH3r6 MDyv93jVFRoTW88mwOt3L6VDxGoZdXfyIXBQ== Received: from itccanarias.org (10.141.153.189) by Erasure.corp.itccanarias.org (10.141.187.131) with Microsoft SMTP Server (TLS) id 14.3.498.0; Sun, 2 Oct 2022 20:30:44 +0100 Date: Sun, 2 Oct 2022 20:30:38 +0100 From: Eduardo Suarez To: Subject: Planning links to tasks Message-ID: <20221002193038.GA12424@itccanarias.org> MIME-Version: 1.0 Received-SPF: pass client-ip=62.174.94.111; envelope-from=eduardo@itccanarias.org; helo=relay.itccanarias.org 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, 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664739094; 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=wd1c/itE9NWfQq1+rvsUIknQhBa4B0NVnhSOYnYay6o=; b=kLDqcrDQNAfpbTl/uAsxc5MfTuB7pLDvI89BhrM8/qswMnbcO2h3V++NxSco+WCOw3NfyA 9XxRT/tK7JdN6F5eJQ2LU7WP0zeVIZnkMYug+QKQ5eX4Qb+hoRasYXz6E/+yTW8SCGWLBa qL4C4jCh2qoK15GFbWxxUOnKw6YoebtEgSf0D31pJ7IZL9uvbausz0AqIAxbQN+a/BsWRh i3O4MdVPolBkkeI1qBNaXeeB17jCWZcz5ahUZMxF8G8J79ZFBcYigP9WqNYdjSPxvQ4mhW LIcu15RFMikSa2UmqJ5nWs0dOz8fcIn0WGqh1xyaJzIUMudTaxOIpxjkTggoRQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664739094; a=rsa-sha256; cv=none; b=oJFAQXaVvoFzO2Jj+oNauofaX29CwzB0JbyS3DlpOMHhwhmps0DhxotAqTdQCNtFbvwvGu wpIc6a/s4q9oX0jLjMG5D6p/9SHsYhEeSSHfJqNi4zA5X2fqq3yORVHSMo9w8OndYJ92N8 tSp7c2C/KDb6cFz/aqNdSrXYzLNuMpo4dZ47N92H0u3U+wK2IKKabLmOrY9SN52zZrqVqD P7s5QvElmQgz3hp89CaB8XOwNUxVdijgKIr6qg4+X8rJn00AQRXCYiGsCCPI61vHXImjfS 4t1glhHrHs0EHAnsOxuPR+exlQyvPQpJE9/PSIWlVdJrlU3Odf8wEs0iNw8TRA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=itccanarias.org header.s=default header.b=dRwE09oK; dmarc=pass (policy=quarantine) header.from=itccanarias.org; 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" X-Migadu-Spam-Score: -7.84 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=itccanarias.org header.s=default header.b=dRwE09oK; dmarc=pass (policy=quarantine) header.from=itccanarias.org; 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" X-Migadu-Queue-Id: 4B8451F9B3 X-Spam-Score: -7.84 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0DpVffKhpXXj This mail is related to 'Manual Ordering and Dynamic Priority' thread. https://lists.gnu.org/archive/html/emacs-orgmode/2022-09/msg00091.html Hi, I have just implemented an approach to creating a hierarchy of links to tasks, so the hierarchy can be thought of a dependency tree (something like a Gantt but with no dates). This approach may be suitable if your org hierarchy is not already based on todo dependencies, and there are too many tasks to review them often. The idea is to be able to: - easily add an item to a plain list in a section named (e.g.) "Planning/Unplanned tasks", consisting of a link to a task in the same buffer (=org-plk-insert=), - move by text editing this list item into a hierarchy of items in a section named (e.g.) "Planning/Planned tasks", so hierarchy means dependency (somehow). BEGIN ORG SAMPLE ... * Planning ** Planned tasks - [[#task4][My task 4 header]] - [[#task5][My task 5 header]] - [[#task1][My task 1 header]] - [[#task2][My task 2 header]] - [[#task7][My task 7 header]] - [[#task6][My task 6 header]] - [[#task3][My task 3 header]] ** Planned tasks - [[#task8][My task 8 header]] - [[#task9][My task 9 header]] END ORG SAMPLE When planning: - go to "Planning/Planned tasks", and click on any task link, modify whatever (todo keyword, tags, timestamps) and get back with 'org-mark-ring-goto' to continue your planning. - Once finished, update all link descriptions to tasks (=edu/org-plk-update-descriptions=). In the code below, I have set a custom description for the links so I can see more details about the tasks. I have also added a suffix to the description so I can check whether a link is a planning link or not. A capture template is required, and an ID property before storing the link, which can be set automatically with: (setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id) I'm not an (e)lisp coder, so any comments about the code (or whatever) are welcome. Some improvements would be great: - update link description at point, - nice looking planning links (fontify?, have no idea), - use another flag for planning link instead of suffix, - check for planning links duplicates. CODE BEGIN HERE ;;; Code: ;; Create an org-capture-template like this: ;; ;; ("xp" ;; "Planning Link" ;; item ;; (file+olp buffer-name "Planning" "Unplanned") ;; ;; Insert date timestamp to keep track of link creation ;; "%<%Y%m%d> [[%L][%(edu/org-plk-insert-last-description)]]" ;; :immediate-finish t ;; :jump-to-captured t) (defcustom edu/org-plk-suffix " (plk)" "Custom suffix for Planning Links" :group 'edu :type 'string) (defcustom edu/org-plk-template-keys "xp" "Custom templates keys to insert a Planning Link" :group 'edu :type 'string) (defvar edu/org-plk-last-description "" "Last description for Planning Link") (defun edu/org-plk-format-description () "Format description for Planning Link" (let* ((components (org-heading-components)) (todo (nth 2 components)) (priority (nth 3 components)) (headline (nth 4 components)) (tags (nth 5 components)) (scheduled (org-entry-get nil "SCHEDULED")) (deadline (org-entry-get nil "DEADLINE"))) (format "[%s/%c/%c%c] %s %s%s" (or todo "") (or priority ?-) (if scheduled ?S ?-) (if deadline ?D ?-) headline (or tags "::") edu/org-plk-suffix))) (defun edu/org-plk-description-from-id (target-id) "Planning link description from Link ID" (catch 'found (org-map-entries ;; break on first element found #'(throw 'found (edu/org-plk-format-description)) (format "ID=\"%s\"" target-id)))) (defun edu/org-plk-p (link &optional shift) "Predicate to check if link is a Planning Link" (let ((shift (or shift 0))) (and (string= (org-element-property :type link) "id") (string-suffix-p edu/org-plk-suffix (buffer-substring (+ shift (org-element-property :contents-begin link)) (+ shift (org-element-property :contents-end link))))))) ;; based on 'us/update-internal-link-descriptions' ;; https://stackoverflow.com/a/71508831 (defun edu/org-plk-update-descriptions () "Update all Planning Link descriptions in buffer" (interactive) (save-excursion (let ((shift 0)) ;; map over all links in the buffer (org-element-map (org-element-parse-buffer) 'link (lambda (link) (when (edu/org-plk-p link shift) ;; filter-in plk's (let* ((new-desc-text (edu/org-plk-description-from-id (org-element-property :path link))) ;; shifted because of previous description updates in this run (old-desc-start (+ shift (org-element-property :contents-begin link))) (old-desc-end (+ shift (org-element-property :contents-end link)))) ;; replace description (goto-char old-desc-start) (delete-region old-desc-start old-desc-end) (insert new-desc-text) ;; update shift (setq shift (+ shift (- (length new-desc-text) (- old-desc-end old-desc-start))))))))))) (defun edu/org-plk-insert () "Create Planning Link for heading at point" (interactive) (org-store-link nil nil) (setq edu/org-plk-last-description (edu/org-plk-format-description)) (org-capture nil edu/org-plk-template-keys) ) (defun edu/org-plk-insert-last-description () "Last Planning Link Description (as a function)" edu/org-plk-last-description) CODE ENDS HERE