From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 8Ky9J7wWymUtWwAAe85BDQ:P1 (envelope-from ) for ; Mon, 12 Feb 2024 14:01:48 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 8Ky9J7wWymUtWwAAe85BDQ (envelope-from ) for ; Mon, 12 Feb 2024 14:01:48 +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=nx9VCsLI; 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=1707742908; 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: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=zsAbzl9/lpPhlBGGy5dx09YbKhDmdcXNk6JvChAxMpk=; b=nP3CPH/k28dL22mwL5+fhyD8coOfjXcn6U5oT1bOaq7gjT/ZIXZC6lLEVa0nk9hx6KtajD u2O+CVVr38l64gBr0BTlVUtGPGQ0sO0tihDITHd3GNmlTfc+JNjhEKPoF9eEOirro/xjDC ut/wgeBvL/o2gyqfmlMuEtqlWyu5SVR6jO0xNlyQG5rttylIiBxgdqkP8oTdjCAn6HNVcP Y43s6l1MYyIX4YAO855yO7517NBCK0d9tw9Q1o8LA+goGd1Rf/JyIMJSJrpPOYKax4hYsc zntMkwL0pt99wjiMFd/3pQQ0Prn6JePFici7ANwWoCKCFATXmujYtFgEKUqNCA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=ubedi-net.20230601.gappssmtp.com header.s=20230601 header.b=nx9VCsLI; 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=1707742908; a=rsa-sha256; cv=none; b=NObTE3t4FVAyO3p55Bu+x+7a2ShevN8SrzlQXLzVZ9iC1bWKBqVtfOVBDRj7opKgLwLfx8 EBHoQyFrh9a08umP/cKz0gSNA4MLJ2s6zwcYM5o+7mYgL8ZwJZO+tnab9Tw6H97+40cvhr 2Q9yg/yQecb0Ozl/GmkvnjWhifKyYW5mFWKjxEIWi4qlIdtUhB0i2S+e101uGvVHT1GV43 gDOCO5IdbRlq/JL3j0WVt1876tJm06WVMi8rg2Yc484H5X31YYHLhJv/DNOKpixQ/G8Hpp osQH3GCAUpf7A4W0LDUxhdNtXDfpTZidIVZ5++kKty0KZDD/PLdDoLRJVtXonA== 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 3B878153EE for ; Mon, 12 Feb 2024 14:01:48 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZVwK-0000Gi-39; Mon, 12 Feb 2024 08:01:40 -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 1rZVw9-00009G-HO for emacs-orgmode@gnu.org; Mon, 12 Feb 2024 08:01:29 -0500 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZVw6-00030v-TI for emacs-orgmode@gnu.org; Mon, 12 Feb 2024 08:01:28 -0500 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5611e54a92dso3898764a12.2 for ; Mon, 12 Feb 2024 05:01:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ubedi-net.20230601.gappssmtp.com; s=20230601; t=1707742884; x=1708347684; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=zsAbzl9/lpPhlBGGy5dx09YbKhDmdcXNk6JvChAxMpk=; b=nx9VCsLIZibsZU/iZxYWwFcMYr4UhzwMi32coWvuQ5HxDFpHpvLstbtNASQW+ishTr 1Dj97mX6Lm1GJ/m/dOTCqF30O6FHSMJBs4a8sjBYxPdiJmEYw5DZcUhkDW/gkN7MYmIp y6YljWIKLTUBL1Qi0qkXH9pLSxr/kpeisnbCn9sWyAXlG6SsjREgOe1Ocr7chgzOmBMd +7g8BH90NyAxa1ncaZuygrZUqWUQpPs0x10aQJvyDF4jExKvdVQgMZWEwGobTkAyc3JS oaw0yf3fU1gaS1JvfozgCq4bPFS4ir0ebaHpYsAMzE1++EstPPMTpTZJ7/kaDF1o+ubB mAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707742884; x=1708347684; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zsAbzl9/lpPhlBGGy5dx09YbKhDmdcXNk6JvChAxMpk=; b=m1lIYK/3NBKpC6E9iBEc4/ouwmASiATw3vLQV2lorERGMMgWVgC+DVwacOgLIkkgh+ FQX1pmq8jPJLy/cogyO12CLCmHhAa2csR02mu4iIg5LUfYzpNISwkpHV28PX+/+chDp1 aH7nrtYy8sQB6P9Hnoe3xAoIXsFX2elwLhEPp2JJKzLpnERP36j8XoqjjaxcXLx2da92 xw4osggXTtGkQf4bm3sFkM/bGGx4mOlfcd4k24oaNKDPo5VNPYk91pjr7cm087EmNqnt 9Gy60LPJg6uotlkQSX/lmW3yAZfGpJJfUYWe/6IB/xISlUIsIghyV0Pqfc2ZTsOwUoQ7 nC7A== X-Gm-Message-State: AOJu0YwlWIWap1+NQyA8YhTWqU42PN7uP43X5ICpMWRNNuPA/5IReyf8 d/css8qTckpvqz3XTRHUXSBsGzpyybvazZtkJDs4BoutJg4i8vaWlwiy1EPFVNPdlrKrmL0vbZ2 Q X-Google-Smtp-Source: AGHT+IEdpgnKgjqkT5804IUL6IFOmLUji68ywINRW9YqaytcPwcQBemFeqOvvJBesIFPpuFsX+ypsQ== X-Received: by 2002:a17:906:1c98:b0:a3c:31d0:5924 with SMTP id g24-20020a1709061c9800b00a3c31d05924mr4842789ejh.3.1707742883762; Mon, 12 Feb 2024 05:01:23 -0800 (PST) Received: from gt1.localnet (ip-4-221.hlucinnet.cz. [93.91.243.221]) by smtp.gmail.com with ESMTPSA id k20-20020a170906681400b00a3bf7a9edc4sm194680ejr.15.2024.02.12.05.01.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:01:23 -0800 (PST) From: Martin Kampas To: emacs-orgmode@gnu.org Subject: [PATCH] org-bibtex-yank: Allow to populate existing item Date: Mon, 12 Feb 2024 13:50:05 +0100 Message-ID: <4868155.GXAFRqVoOG@gt1> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2172732.irdbgypaU6" Content-Transfer-Encoding: 7Bit Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=martin.kampas@ubedi.net; helo=mail-ed1-x52e.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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -8.31 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: -8.31 X-Migadu-Queue-Id: 3B878153EE X-TUID: DT6xMkdxkE9o This is a multi-part message in MIME format. --nextPart2172732.irdbgypaU6 Content-Type: multipart/alternative; boundary="nextPart1877372.tdWV9SEqCh" Content-Transfer-Encoding: 7Bit This is a multi-part message in MIME format. --nextPart1877372.tdWV9SEqCh Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Hi, The attached patch allows to use org-bibtex-yank to populate an existing item instead of creating a new one, aligning its behavior with org-bibtex-create. BR, Martin Kampas --nextPart1877372.tdWV9SEqCh Content-Transfer-Encoding: 7Bit Content-Type: text/html; charset="us-ascii"

Hi,


The attached patch allows to use org-bibtex-yank to populate an existing item instead of creating a new one, aligning its behavior with org-bibtex-create.


BR,

Martin Kampas

--nextPart1877372.tdWV9SEqCh-- --nextPart2172732.irdbgypaU6 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 96af3ef46bb056e58206af77d3d37c5af2e43d7f 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 --- lisp/ol-bibtex.el | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lisp/ol-bibtex.el b/lisp/ol-bibtex.el index c5a950e2d..6ae4ae3cc 100644 --- a/lisp/ol-bibtex.el +++ b/lisp/ol-bibtex.el @@ -722,29 +722,31 @@ 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 t, 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 +754,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) - (let (entry) +(defun org-bibtex-yank (&optional nonew) + "If kill ring holds a bibtex entry yank it as an Org headline. +If nonew is t, add data to the headline of the entry at point." + (interactive "P") + (let (entry + (noindent nonew)) (with-temp-buffer (yank 1) (bibtex-mode) (setf entry (org-bibtex-read))) (if entry - (org-bibtex-write) + (org-bibtex-write noindent nonew) (error "Yanked text does not appear to contain a BibTeX entry")))) (defun org-bibtex-import-from-file (file) -- 2.43.0 --nextPart2172732.irdbgypaU6--