From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id +HUxFcho12Up/wAAe85BDQ:P1 (envelope-from ) for ; Thu, 22 Feb 2024 16:31:20 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id +HUxFcho12Up/wAAe85BDQ (envelope-from ) for ; Thu, 22 Feb 2024 16:31:20 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=ubedi-net.20230601.gappssmtp.com header.s=20230601 header.b=M2FjqKiy; 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"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708615880; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=PceX8OLodPJhN/Db9e5gSNau3szcsenuQxIqmDMFGTc=; b=UKlYlkmv8XG1pAS5Z6o8TDF8pt3i3DSNvbHcCz/X0HOPqAkhjUKQVytkgXARALCGjttR0m puzRbWV9gN1VMDhxelLP90NWjfXKVnuN+L/SJHnXytT9ZOw4eyErcTuC355ESUD1Qa2sI5 i0cbqNV4KW3a9/J1WXQEiiW7NVrUbe+V50OtbVz3r/HwFvfp5aFfHaA2D37RsBnu43ycfA xCAMlWNmk1seueNKEtlSLxN+MDQI/KKUCpJHEnz1mxGSu+4SzIXWk8SdK0FLT3KnZK7VVE b7nMaZ2RXYSBH1eYMbQGMFdrxoqzshjaggDAzqPCsFkaZTTr0eLegmY/Zn+sJA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=ubedi-net.20230601.gappssmtp.com header.s=20230601 header.b=M2FjqKiy; 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"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708615880; a=rsa-sha256; cv=none; b=HyyMShPoz+KxeFsSJW574XEgs96WrU2ovWtnn94icKI8Wl03FyO93oTeLk0quCEdD4PA3B dWO8oBHLanWu53OwRIBQP7FHO2dLzqc3TSgUjpaaSJUrwK/X5T2ea3C8wneZYxteJ3Jwm/ fGKNXV2i22aovFlVb/SfHPBqchEnxLFIgp8CFQrPNcvlcoN9JDIcsefyEoQhEhssdQ7bPj tvSB5Ba1wTaDmPaFvVagk3FhggLoW+A95sMF+5QFBXNJHlMrMO+7VusC93ugGXO1RFESUB YD8uYhQQtL6K5L8WnrBOhXezltuCHobvSXmLh/H+DgBK2ug4kFwrW+BwZAq84w== 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 A3E9F20CAF for ; Thu, 22 Feb 2024 16:31:19 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdB1o-0007Up-6t; Thu, 22 Feb 2024 10:30:28 -0500 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 1rdB1m-0007Uc-OT for emacs-orgmode@gnu.org; Thu, 22 Feb 2024 10:30:26 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdB1k-0000ir-CI for emacs-orgmode@gnu.org; Thu, 22 Feb 2024 10:30:26 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a3d5e77cfbeso192133366b.0 for ; Thu, 22 Feb 2024 07:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ubedi-net.20230601.gappssmtp.com; s=20230601; t=1708615822; x=1709220622; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PceX8OLodPJhN/Db9e5gSNau3szcsenuQxIqmDMFGTc=; b=M2FjqKiyBjB3cq0Imb6MwFfM3U2Ihkk6OF5UE1ozpBWz7QeVbfleEQTyjXCLpgvGgd guK+B2Chr1xiiDNcxGvUeBbC3ueIKhSjI9ztnE/O8LtlTZu250+28P0g9cpOP/X8zZx8 XNdy6g0oFaAjJdaeqZh2vi62AGxifh0dFQDNJgKf2iy/bS8qJ/e8Fwp9L3MtSUfuhGaH kKfBXaZRO/OpZC+H4kUpcVP7UgxysSZSwxLlv3Do5TKWW0Kq2w9sKidw1De+uYRtzU4b ATFVuHU4NA2YvcinrcGnxSnDZsqleXfIiU+raaRTPgDjDKMfTeIQQjCf8G2bxfmXLcAx klIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708615822; x=1709220622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PceX8OLodPJhN/Db9e5gSNau3szcsenuQxIqmDMFGTc=; b=RixW0t26ejMdzvTUEvT+z41Cc+/rDLUS91AK93/uuoc8kMY/sIRzpCI/9dudeYUSKv D1FSCi5b55X9GPw8UBXarJbHYXruXupllWWwsaAMBpcdU2MsvzjxgYschlRb9VEeHet9 D6AtacgLvrCfO+8viOr1kbe3Un31bGDQOdTjvdOqish0rYTx10XPXk0snqP3UsXqRRwW KDubLDFbUl7Rq66Yg4FiGeP9Qj34/et7JriPyCO8TZ3n5Bo6UljAiR+/9GN1GbYMVr24 v/p5GZ0JtSyf32yIsf1FyGAByb6lJ0I0QMnyJVZbGT8VM/oPP8j4IAIKHlj2sAY5YR0o mdoQ== X-Gm-Message-State: AOJu0YxyaHhQdeL2OQHkbUkaHLBl1Kzcxu0gXclvYOCkMoom50uhVWal pHwNyt9Hqyvnt1xELEEfS7w9+dZDI1yu4j/e6kXr7HL0ftG0oUY7u7RhOEGiWMjSeu5oKJhN4cO e X-Google-Smtp-Source: AGHT+IHCCEV1i8pyp9NKhuzzYKYbrOdTUpVMD2joNRUGu5lDgjT7HSjYkiWUIDaywFvNLKGJIHLriQ== X-Received: by 2002:a17:906:ef8f:b0:a3f:365:2276 with SMTP id ze15-20020a170906ef8f00b00a3f03652276mr2419795ejb.34.1708615821748; Thu, 22 Feb 2024 07:30:21 -0800 (PST) Received: from gt1.localnet (ip-4-221.hlucinnet.cz. [93.91.243.221]) by smtp.gmail.com with ESMTPSA id q18-20020a170906145200b00a3d2d81daafsm6173803ejc.172.2024.02.22.07.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:30:21 -0800 (PST) From: Martin Kampas To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] org-bibtex-yank: Allow to populate existing item Date: Thu, 22 Feb 2024 16:30:20 +0100 Message-ID: <5444244.Sb9uPGUboI@gt1> In-Reply-To: <87frxpsv62.fsf@localhost> References: <4868155.GXAFRqVoOG@gt1> <87frxpsv62.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2138562.OBFZWjSADL" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=martin.kampas@ubedi.net; helo=mail-ej1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -7.87 X-Spam-Score: -7.87 X-Migadu-Queue-Id: A3E9F20CAF X-TUID: B/dxj4I2YVDV This is a multi-part message in MIME format. --nextPart2138562.OBFZWjSADL Content-Type: multipart/alternative; boundary="nextPart1968979.yKVeVyVuyW" Content-Transfer-Encoding: 7Bit This is a multi-part message in MIME format. --nextPart1968979.yKVeVyVuyW Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" On ned=C4=9Ble 18. =C3=BAnora 2024 15:29:09 CET Ihor Radchenko wrote: > In the code, you do not check for t, but for non-nil. So, please say > "non-nil" in the docstring as well. As stated in the commit message, aligning with org-bibtex-create... ok, let= me update the=20 doc string of org-bibtex-create as well. > Also, I'd prefer a more descriptive name, like update-heading. nonew is > ambiguous - it can be interpreted in several ways. =2E..aligning with org-bibtex-create. > > + (interactive "P") > > + (let (entry > > + (noindent nonew)) >=20 > Why do you bind noindent here? It says nothing about (re)indenting the existing entry, so my feeling was i= t would be=20 better to avoid doing that if there is no way to override. Now if you need = to ask about it, it=20 seems it is not really an issue, so I removed it, hardcoding nil there. BR, Martin --nextPart1968979.yKVeVyVuyW Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8"

On ned=C4=9Ble 18. =C3=BAnora 2024 15:29:09 CET Ihor Radchenko wrote:

>= ; In the code, you do not check for t, but for non-nil. So, please say

>= ; "non-nil" in the docstring as well.


As stated in the commit message, aligning with org-bibtex-create... ok, = let me update the doc string of org-bibtex-create as well.


> Also, I'd prefer a more descriptive name, like update-heading. none= w is

>= ; ambiguous - it can be interpreted in several ways.


...aligning with org-bibtex-create.


> > +  (interactive "P")

>= ; > +  (let (entry

>= ; > +        (noindent nonew))

>= ;

>= ; Why do you bind noindent here?


It says nothing about (re)indenting the existing entry, so my feeling wa= s it would be better to avoid doing that if there is no way to override. No= w if you need to ask about it, it seems it is not really an issue, so I rem= oved it, hardcoding nil there.


BR,

Mar= tin

--nextPart1968979.yKVeVyVuyW-- --nextPart2138562.OBFZWjSADL Content-Disposition: attachment; filename="0001-org-bibtex-yank-Allow-to-populate-existing-item.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="x-UTF_8J"; name="0001-org-bibtex-yank-Allow-to-populate-existing-item.patch" >From 8210921aa94430b651c9813acb1c12448db00fb8 Mon Sep 17 00:00:00 2001 From: Martin Kampas Date: Mon, 12 Feb 2024 13:24:54 +0100 Subject: [PATCH] org-bibtex-yank: Allow to populate existing item Align with `org-bibtex-create'. * lisp/ol-bibtex.el (org-bibtex-write): New optional argument `nonew', similar to the existing `nonew' argument of `org-bibtex-create'. * lisp/ol-bibtex.el (org-bibtex-yank): New optional argument `nonew', similar to the existing `nonew' argument of `org-bibtex-create'. --- etc/ORG-NEWS | 10 ++++++++++ lisp/ol-bibtex.el | 42 ++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 7d2f70ab6..4751deaaa 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -812,6 +812,11 @@ propagating the value for this variable to ~org-agenda-archives-mode~. For acceptable values and their meaning, see the value of that variable. ** New features +*** ~org-bibtex-yank~ accepts a prefix argument + +When called with a prefix argument, ~org-bibtex-yank~ adds data to the +headline of the entry at point instead of creating a new one. + *** =ob-plantuml.el=: Support tikz file format output =ob-plantuml.el= now output =tikz= :file format via @@ -1011,6 +1016,11 @@ The same can be done via startup options: : #+STARTUP: fnanon ** New functions and changes in function arguments +*** New optional argument =NONEW= for ~org-bibtex-yank~ + +When the new argument is non-nil, add data to the headline of the +entry at point. + *** New API functions to store data within ~org-element-cache~ Elisp programs can now store data inside Org element cache. diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el index c5a950e2d..4ec4dc958 100644 --- a/lisp/ol-bibtex.el +++ b/lisp/ol-bibtex.el @@ -642,8 +642,8 @@ With prefix argument OPTIONAL also prompt for optional fields." (defun org-bibtex-create (&optional arg nonew) "Create a new entry at the given level. -With a prefix arg, query for optional fields as well. -If nonew is t, add data to the headline of the entry at point." +With a prefix ARG, query for optional fields as well. +If NONEW is non-nil, add data to the headline of the entry at point." (interactive "P") (let* ((type (completing-read "Type: " (mapcar (lambda (type) @@ -722,29 +722,32 @@ Return the number of saved entries." (interactive "fFile: ") (org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile))) -(defun org-bibtex-write (&optional noindent) +(defun org-bibtex-write (&optional noindent nonew) "Insert a heading built from the first element of `org-bibtex-entries'. When optional argument NOINDENT is non-nil, do not indent the properties -drawer." +drawer. If NONEW is non-nil, add data to the headline of the entry at +point." (interactive) (unless org-bibtex-entries (error "No entries in `org-bibtex-entries'")) (let* ((entry (pop org-bibtex-entries)) (org-special-properties nil) ; avoids errors with `org-entry-put' (val (lambda (field) (cdr (assoc field entry)))) - (togtag (lambda (tag) (org-toggle-tag tag 'on)))) - (org-insert-heading) - (insert (funcall org-bibtex-headline-format-function entry)) - (insert "\n:PROPERTIES:\n") - (org-bibtex-put "TITLE" (funcall val :title) 'insert) + (togtag (lambda (tag) (org-toggle-tag tag 'on))) + (insert-raw (not nonew))) + (unless nonew + (org-insert-heading) + (insert (funcall org-bibtex-headline-format-function entry)) + (insert "\n:PROPERTIES:\n")) + (org-bibtex-put "TITLE" (funcall val :title) insert-raw) (org-bibtex-put org-bibtex-type-property-name (downcase (funcall val :type)) - 'insert) + insert-raw) (dolist (pair entry) (pcase (car pair) (:title nil) (:type nil) - (:key (org-bibtex-put org-bibtex-key-property (cdr pair) 'insert)) + (:key (org-bibtex-put org-bibtex-key-property (cdr pair) insert-raw)) (:keywords (if org-bibtex-tags-are-keywords (dolist (kw (split-string (cdr pair) ", *")) (funcall @@ -752,25 +755,28 @@ drawer." (replace-regexp-in-string "[^[:alnum:]_@#%]" "" (replace-regexp-in-string "[ \t]+" "_" kw)))) - (org-bibtex-put (car pair) (cdr pair) 'insert))) - (_ (org-bibtex-put (car pair) (cdr pair) 'insert)))) - (insert ":END:\n") + (org-bibtex-put (car pair) (cdr pair) insert-raw))) + (_ (org-bibtex-put (car pair) (cdr pair) insert-raw)))) + (unless nonew + (insert ":END:\n")) (mapc togtag org-bibtex-tags) (unless noindent (org-indent-region (save-excursion (org-back-to-heading t) (point)) (point))))) -(defun org-bibtex-yank () - "If kill ring holds a bibtex entry yank it as an Org headline." - (interactive) +(defun org-bibtex-yank (&optional nonew) + "If kill ring holds a bibtex entry yank it as an Org headline. +When called with non-nil prefix argument NONEW, add data to the +headline of the entry at point." + (interactive "P") (let (entry) (with-temp-buffer (yank 1) (bibtex-mode) (setf entry (org-bibtex-read))) (if entry - (org-bibtex-write) + (org-bibtex-write nil nonew) (error "Yanked text does not appear to contain a BibTeX entry")))) (defun org-bibtex-import-from-file (file) -- 2.43.0 --nextPart2138562.OBFZWjSADL--