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 ms1.migadu.com with LMTPS id EE8PLSa9G2aEMgAAe85BDQ:P1 (envelope-from ) for ; Sun, 14 Apr 2024 13:25:27 +0200 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 EE8PLSa9G2aEMgAAe85BDQ (envelope-from ) for ; Sun, 14 Apr 2024 13:25:26 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=rensoliemans.nl header.s=soverin header.b=afR+CPoy; dmarc=none; 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=1713093926; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ldexEl8EPJT1tA3Yze6Mb47BnEF369ZvC8304MPBG4g=; b=AQlTZw5v1Ujiy7d4lYQEhxQrJrYqKwGz1okVhiHWtjqFSIkWdGeO8RivtdP8t85x1RcbdJ 18LJD5tlkwdktBeX/m/L5rjPnxedrSUMlMuicKdoI6WqsmIF7Af02MQW+3YeLTyrBRZrg0 p0R9HntsWjxLS+rcvfzjxZRwhRpUFLWydx380m8dyClJLVY80OPagSDFK6fuVABhK3Wf93 Jsu59I6hv4XSxBl76kPhdzCBh9RDka6ycVp+vH5zA4Iz9lv0GhnHiCfqpAVsGBaBmRSxkM +MtPjvxrmpEStfO5l+tA3dfA12bSq5HFC/gOu1vW6UAWi8EQLztFV/jzizjOOA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=rensoliemans.nl header.s=soverin header.b=afR+CPoy; dmarc=none; 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-Seal: i=1; s=key1; d=yhetil.org; t=1713093926; a=rsa-sha256; cv=none; b=FYeKUg5R450gJMotCVRRYQRktjm/ntRlQqusCmHOKtQ5kREnaWgWes3couLHAn1qgCIBmp bDo1ebAKV1OOC3K1kXqPGeMDbpHDnh6lWaowuPWMXC7H7yvr8hI4EfhhP4s9nlDEPtjeto z/Szw1fUyqz0htcxOGoFD2/WW8nYG3FKz4dkW101Mi2Oye8appYdkWY17LXPoamZ+RAhfC bkB8+3EcNBarlL2cI2cf1GsTiXf3xxlPeHr2zHxL1h1LXFdyyL+T5Lp0E5L/pI46zgm4KJ YjKznlnaPoOTRa/JLDJ+NRWJCt8Fpv6cuYvUZ3BFrEpDTde9fKngvhFG4sm8VA== 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 4874660627 for ; Sun, 14 Apr 2024 13:25:26 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvxyq-0006hp-A1; Sun, 14 Apr 2024 07:25:04 -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 1rvxyo-0006hG-6b for emacs-orgmode@gnu.org; Sun, 14 Apr 2024 07:25:02 -0400 Received: from outbound.soverin.net ([185.233.34.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvxyi-0006rK-9O for emacs-orgmode@gnu.org; Sun, 14 Apr 2024 07:25:00 -0400 Received: from smtp.soverin.net (c04cst-smtp-sov02.int.sover.in [10.10.4.100]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 4VHSdJ2ykmz1T; Sun, 14 Apr 2024 11:24:52 +0000 (UTC) Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by soverin.net (Postfix) with ESMTPSA id 4VHSdJ1CFhzBd; Sun, 14 Apr 2024 11:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=rensoliemans.nl; s=soverin; t=1713093892; bh=jZ8weI8erDnvJo7z5s5E5gPvTFrmTX2JFCR3wiI3xX4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=afR+CPoygr9ts86L/0c4qZBRYzLtSuI9sHd4N4QRiNivMsWo4O5FoU2yUBEuczQwW 1hAW6njIqJt8PKBULRzv6v05GcPJzIOxr+9GtU0zewH5EiqMVxCoNVsqZm8c8C1iBg lrJNpB7sdkv3zzkt52mirU2MmDv3UgU6cJD5l0KL+2CD2+vHreFCzkWpKpqblZgGBT 7IitnRVmFx27AKrE/fGOYupE+ikqvIa+7FiI/GZPRbEWAnWUi/ubGbruhFpJJ3eKYj QxMMTKG4ovl8s04uoaWTOdjqjTdTZQf9SRwL8RAebvpA58x0YbQOxYstS4m+z5rHJN 16XsVzjY1e99Q== From: Rens Oliemans To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: [PATCH 2/2] org-capture: Allow table-line entry to start without | In-Reply-To: <877chnc0lr.fsf@localhost> References: <87cyrg3qaa.fsf@rensoliemans.nl> <877chnc0lr.fsf@localhost> Date: Sun, 14 Apr 2024 13:24:51 +0200 Message-ID: <87il0krxto.fsf@rensoliemans.nl> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.233.34.18; envelope-from=hallo@rensoliemans.nl; helo=outbound.soverin.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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: -3.98 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -3.98 X-Migadu-Queue-Id: 4874660627 X-TUID: EDpjQeclNu8f * lisp/org-capture.el (org-capture-place-table-line): Prepend table-line begin ('|') if the template does not start with it. * testing/lisp/test-org-capture.el (test-org-capture/table-line): Verify that a template gets prepended with a '|' if it does not start with it. --- lisp/org-capture.el | 15 ++++++++------- testing/lisp/test-org-capture.el | 10 ++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 750778f8b..a56e75fda 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1355,13 +1355,14 @@ may have been stored before." (defun org-capture-place-table-line () "Place the template as a table line." (require 'org-table) - (let ((text - (pcase (org-trim (org-capture-get :template)) - ((pred (string-match-p org-table-border-regexp)) - "| %?Bad template |") - (text (concat text "\n")))) - (table-line-pos (org-capture-get :table-line-pos)) - beg end) + (let* ((template (org-trim (org-capture-get :template))) + (text + (pcase template + ((pred (string-match-p org-table-border-regexp)) + (concat "| " template)) + (text (concat text "\n")))) + (table-line-pos (org-capture-get :table-line-pos)) + beg end) (cond ((org-capture-get :exact-position) (org-with-point-at (org-capture-get :exact-position) diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el index 9ab078193..6c13e8283 100644 --- a/testing/lisp/test-org-capture.el +++ b/testing/lisp/test-org-capture.el @@ -606,6 +606,16 @@ "| 2 |" :immediate-finish t)))) (org-capture nil "t")) (buffer-string)))) + ;; Prepend | when the template does not start with it + (should + (equal "| 1 |\n| 2 |\n" + (org-test-with-temp-text-in-file "| 1 |\n" + (let* ((file (buffer-file-name)) + (org-capture-templates + `(("t" "Table" table-line (file ,file) + "2 |" :immediate-finish t)))) + (org-capture nil "t") + (buffer-string))))) ;; When `:prepend' is nil, add the row at the end of the table. (should (equal "| a |\n| x |\n" -- 2.44.0