From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id Ma0xHzT2vGBmrQAAgWs5BA (envelope-from ) for ; Sun, 06 Jun 2021 18:22:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id SCvDGTT2vGBVWAAAbx9fmQ (envelope-from ) for ; Sun, 06 Jun 2021 16:22:12 +0000 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 A687913367 for ; Sun, 6 Jun 2021 18:22:11 +0200 (CEST) Received: from localhost ([::1]:54896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpvXN-0001mS-EU for larch@yhetil.org; Sun, 06 Jun 2021 12:22:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpvWx-0001la-LX for emacs-orgmode@gnu.org; Sun, 06 Jun 2021 12:21:43 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:40519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpvWw-0004c3-4r for emacs-orgmode@gnu.org; Sun, 06 Jun 2021 12:21:43 -0400 Received: by mail-wm1-x335.google.com with SMTP id b145-20020a1c80970000b029019c8c824054so10975832wmd.5 for ; Sun, 06 Jun 2021 09:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=xe/0rhao6jA3WK8pwNdrqlqenY3g//sS1SS124+rwOA=; b=gqSYdtyefcwZcgI5+M+wd6sdWe/JnKwoa+DKRkqlauqdCk3Uz/H0dL9Zi1p98sGkmo NGsi/agMtfOCSnObhcd1VkL1EMnfkTuZsTfhQc67jncgJKVhpFJesGG0jHg4R67Exxf5 3beFvMU7dz42wlW8ANO1PNfb98gyPxA3iQ4y2AriOfDV7ng9exsFlW2tT9WiLm4xU2aS AwfYQ3e/Mf8COkTDpuhgxyofOmnIHUjIsgaT0tBcfhjIIWuhh8GSvhk10x99/9UI7vnj 3PPaIkuDdEPKKWRmdEK4OpbuzSnkueHyM4uc9Y7DNi7rHZaYlmIIG4p/E1SdzrvVm70B KsNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=xe/0rhao6jA3WK8pwNdrqlqenY3g//sS1SS124+rwOA=; b=mwUGdx++EWp4WrH1067q+dA+55ODyqn8OJKu8RGXCOLtWT7qaCHV+tsteM7nmDL6yn sEjVQEFHj83GYu9EsxSiTmVzrOgAwZSc5gS7gYY200vgPHMFiLryzAPW2fb+Mn8ADVeK 7BXQSo8gvbTRGaG9oP+Ll79HSMzBYMr5setdmsumDd/9t+0IqT+Bdoj60we6yxypyLcn nl7PT9t7xvXameW/CQ3zFPqmYjyAsgskuiBXq9078/iRYqHbI1jIiOFaf8vuOCe1Ut+l mIwHuzt3IQFCaumdrkPK3F+anWB7aTFoqwCdvL6odjFPYyaKQesJT744kyK08sp7E3nR ChXw== X-Gm-Message-State: AOAM530vMqO3aHOtUAPvOH2AvEIaFyvHpr++DL8InB0JhbwSsL7bVNTp aVRUA5yk85RFBQEk7Fc7B7P7V2KDojLU3d+sSv1ydl5W2Z4= X-Google-Smtp-Source: ABdhPJznd/P7YI2hXWjMEab7g5zPv6aE6QsrQ6MhYHOK6lQ/bEqoTGHR5r+ZcvRB40geEG+wK+4bPBXwkoupB5S7mfg= X-Received: by 2002:a05:600c:1c1b:: with SMTP id j27mr13327211wms.133.1622996499429; Sun, 06 Jun 2021 09:21:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Bruce D'Arcus" Date: Sun, 6 Jun 2021 12:21:28 -0400 Message-ID: Subject: Re: [org-cite] request for coding help on a capf to insert citation key To: org-mode-email Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=bdarcus@gmail.com; helo=mail-wm1-x335.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622996532; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xe/0rhao6jA3WK8pwNdrqlqenY3g//sS1SS124+rwOA=; b=s5TnB/wqZXlNIre0QECupG3nEDCl4Czpd1aHnWPoPz5wpXJ7yFtKhy7l9FwA4B9Q1q4BG/ RuxQemSFg1xkd2W/ObZLRQlA59L5DG7sgdml3OkANwkWK1/9sU0OyBv0jO5XPvyBIPC/K7 iaQVK+AxRf0yoa0sp1AFV+R1HbASelc7dLAf8B43f+WsQCZ5o1xmSgPGVr9W4z7fpLz5gu yMwy+rVGBFkufVfBUfe5ljqXyDO86aBJHnoJ1L+u3TY2rBNwyitaqK/KqNPPYoZZ2yd/t5 HKA2PXQbleanAOJVKz8DGbD671i95oNrjHuptSGj3cJ1ETVPUZZNx6HAj969uw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622996532; a=rsa-sha256; cv=none; b=AZOaBC3pZ5PC9Ns4Ep0H4gVCUHivOjYZB/pmv1VXg4MjxEkyOsT5aU/mXm3KtGZJgPSfJG RxaafFJYtITCVyfKF0OAt9UhFkfFxt68zoYcSXPKqwNhLDnIOFctylSP/bowZuwZsYHaRS FkilnmGtw9k+NAYsYhKOcFRxlUIzgXmrJjxvUpfNShEK2CYfzcu6pecvVVRbgHHfgpt+PI /di4kivZ4NWcwrwfSUMxRY77l4LWaU/zQn9GwDzDyosxBihm2YLH218WVCSbvV5UDyMxnK eZdBP5siyZQ8zAOcamhe/EOslIAD7MsO8WJsO9grrQcaw6fJ6FYrxG4RAfWcjA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=gqSYdtye; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=gqSYdtye; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: A687913367 X-Spam-Score: -3.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: HwVTs4Y9JMEf One other idea, Nicolas: Is there room to include a org-cite somehow, so that one had a defcustom like: (setq org-cite-complete-key-candidates my-candidates) ;; here override default with results from my package (setq my-candidates (bibtex-actions--get-candidates)) ... and default could be some simple thing in oc-basic? If not, totally fine of course, but I thought I'd mention it as I'm trying to figure this out. Bruce On Sat, Jun 5, 2021 at 5:14 PM Bruce D'Arcus wrote: > > Round 2, which should address the "regex" todo. > > --8<---------------cut here---------------start------------->8--- > (defun bibtex-actions-complete-key-at-point-oc () > "Complete org-cite citation key at point. > > When inserting '@' in a buffer the capf UI will present user with > a list of entries, from which they can narrow against a string > which includes title, author, etc., and then select one. This > function will then return the key 'key', resulting in '@key' at > point." > ;; FIX exit-function is wrong; results in "no match" > (when (and (eq major-mode 'org-mode) > (eq (car (org-element-context)) 'citation)) > (let* ((candidates (bibtex-actions--get-candidates)) > (begin (save-excursion (backward-word) (point))) > (end (point))) > (list begin end candidates :exclusive 'no > :exit-function > (lambda (chosen status) > (when (eq status 'finished) > (cdr (assoc chosen candidates)))))))) > --8<---------------cut here---------------end--------------->8---