No Wayman <iarchivedmywholel...@gmail.com> writes:

As far as org-capture is concerned, support for transparently upgrading the user's templates could easily be added to the `org-capture-upgrade-templates`
function.

It would just be one more case added to the existing pcase statement and would
prevent breakage for users.

See the attached patch which adds the mentioned case.
The docstring for `org-capture-upgrade-templates` could be worded better/more generally. I believe we could also do a better job notifying the user when they have outdated capture syntax. Really we should be recording *which* templates use outdated syntax and pointing them to a solution. These are separate issues, though.

>From 4a133f0c5a7fef18ea1dfb38e2e1539da1db834e Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholel...@gmail.com>
Date: Sun, 15 Aug 2021 12:48:00 -0400
Subject: [PATCH] org-capture.el: Upgrade file+headline template target syntax

* lisp/org-capture.el (org-capture-upgrade-templates): Upgrade
templates which utilize file+headline target syntax to file+heading
---
 lisp/org-capture.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 831c3e1f4..28b3e33f4 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -109,7 +109,8 @@
   "Update the template list to the new format.
 TEMPLATES is a template list, as in `org-capture-templates'. The
 new format unifies all the date/week tree targets into one that
-also allows for an optional outline path to specify a target."
+also allows for an optional outline path to specify a target.
+It also accounts for renaming `headline` to `heading`."
   (let ((modified-templates
 	 (mapcar
 	  (lambda (entry)
@@ -128,6 +129,9 @@ also allows for an optional outline path to specify a target."
 	      (`(,key ,desc ,type (file+weektree+prompt . ,path) ,tpl . ,props)
 	       `(,key ,desc ,type (file+olp+datetree ,@path) ,tpl
 		      :tree-type week :time-prompt t ,@props))
+              ;; Rename "headline" to "heading"
+	      (`(,key ,desc ,type (file+headline . ,file+heading) ,tpl . ,props)
+	       `(,key ,desc ,type (file+heading ,@file+heading) ,tpl ,@props))
 	      ;; Other templates are left unchanged.
 	      (_ entry)))
 	  templates)))
-- 
2.32.0

Reply via email to