From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 2E01NkfWr2QaHwEASxT56A (envelope-from ) for ; Thu, 13 Jul 2023 12:47:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id +JNmNUfWr2R9XAAAG6o9tA (envelope-from ) for ; Thu, 13 Jul 2023 12:47:35 +0200 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 F0DF15D3D8 for ; Thu, 13 Jul 2023 12:47:34 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=jL5tFLEc; 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=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689245255; a=rsa-sha256; cv=none; b=Ci9DTsLKFNCIXcSZfBHssDDDceP7nhf+BJ5P3etjD0LWt93fJPm4cfnUX+0PFKYkYeHSFd IwoQVVm13bgpAwOsthk+zXGKwbwRG/ePiQ8Fq16IOLeXiNHBYELGRe7MpFaGmqk7brsmoK 6hPZYyiUtv9UgVeY8Hnu/0fpZskBVOOmQ6pB8sCM9VL0HpfvPGalCOTVt04vswkeIDm/jz htuoYaNhgsKsFfYA3jMZjXj9SfUwYg0is8sy7Xn6d7RCS4e40PzGm4gGjCMyVtpyzt1YgI mKwvs+3dmho8yNnrOh4oMQpC33REy8n84rVVbuWSH8wj10DY+z/Bi4vonQgFUA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=jL5tFLEc; 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=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689245255; 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=Wz6sDHzzRsxVSBHWuA9MO9wHa7GpgaCPepJJ3KE+n2g=; b=CBcfOWknMxir5tapo4+ZaV92Iiv6qArISBNn1SatGNfEHE5DeCSHJjRX+GWA2rS+5beXGr Gmdi9/pEQO3KpLwFm4QWQQkOMDRfgQun/Cqy3Jieo0azWrsInICZO83MWLkRtBeEHmrHfQ 4fMSoMLRr412Haa+l/cGhQZZ4BqESdObwwpu4O2zn3qcpXFRm7mF+AKPKAXCWMo8a00UZY F3lC2lEGqgQqLjG21dhs4SsyK0eUvMT/Jc61e//OuRvb3ZA3OW7yX8Mse3ZJFNkJUjchOC ff4b84nfokMIH6j5huDrBhKoyrSIGbrQ5h2G+PORQKWy/THNQptpEcKTmvDQmA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJtqN-0000d7-EK; Thu, 13 Jul 2023 06:46:43 -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 1qJtqL-0000cv-1o for emacs-orgmode@gnu.org; Thu, 13 Jul 2023 06:46:41 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJtqI-0005iZ-GF for emacs-orgmode@gnu.org; Thu, 13 Jul 2023 06:46:40 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 0F3E5240103 for ; Thu, 13 Jul 2023 12:46:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1689245194; bh=twM4hznRIz88JfZn8DA7GNN5JrqxGzGBvnj8kgAFK7Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=jL5tFLEcNfSJODad6eQ6bV7/iMcTwVRudqxZh06nrJoAJAtawSERJdvrkh3aSTTM/ Ey0xum3FluqAIrwkf6bycuxQk7j+6kfv4Y0Z4VCSTUwi6kqfCa9zNECKyHDia198aS 2ZVMs6ykcJ10Va1dCEYq1FiX8KMoItgw/eTfnpXUxW4PLJQAdOXshuWfz5pcSen9Fi e7ap9xzqNhrcJYqqN7wuNybpekezZcYxYhnULRzGEpmA85NxF4oFOdNH449NhuTA3l gMuZZXm6teeXi/i4+XmWr0ApXqCQ+o2uodQlBHnLR369Pcw6FvgDZTHkxpYceVLplf oPtallV+XFaSg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4R1rrS6qfVz9rxB; Thu, 13 Jul 2023 12:46:32 +0200 (CEST) From: Ihor Radchenko To: Samuel Wales Cc: Max Nikulin , emacs-orgmode@gnu.org Subject: Improve org-insert-link completion (was: [Bug] org-insert-link removes on one link from 2 added by org-store-link) In-Reply-To: References: <871qhq69dn.fsf@localhost> Date: Thu, 13 Jul 2023 10:46:41 +0000 Message-ID: <877cr4ytpq.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -9.29 X-Spam-Score: -9.29 X-Migadu-Queue-Id: F0DF15D3D8 X-TUID: R5sMK/HM/GzD Samuel Wales writes: > link has already been stored is a bug in my case in that i can't just > go to a header, grab it [whether rabbed bfere or not] and then paste > it. i surprise easily when the wrong link gets pasted. This has been fixed already. > in answer to a q by ihor, indeed puttig previously stored id liks as > descriptions in front of all the prefixes woudl be useful to me, but > idk who is doing the sorting, so idk whether it wold make a difference > but if it dos then gret..] Org is actually not supposed to control sorting. It is to be customized by user via `completions-sort'. What we can do instead is provide grouping metadata. Below, I provide a simple demo on how it looks like. However, the demo will only make a difference starting from Emacs 28 that has the necessary completion API. (defun org--complete-links (string predicate flag) (let* ((links '(:type ("id:" "file:") :path ("/a/a/b" "file.org") :description ("foo" "barr" "baz"))) (all-links (append (plist-get links :type) (plist-get links :path) (plist-get links :description))) matches) (pcase flag (`nil (try-completion string all-links predicate)) (`t (all-completions string all-links predicate)) (`lambda (test-completion string all-links predicate)) (`(boundaries . suffix) (completion-boundaries string all-links predicate suffix)) (`metadata `(metadata (group-function . (lambda (completion transform) (if transform completion (let ((links ',links)) (cond ((member completion (plist-get links :type)) "Link type") ((member completion (plist-get links :path)) "Link path") ((member completion (plist-get links :description)) "Link description"))))))))))) (completing-read "Test: " #'org--complete-links) > it seems org-insert-=inki is overloaded. one use case says insert a > previously stored link. the other says insert a brand new link which > i will now specify. might it be useful to separate those two > functions? I do not see why it is overloaded. The last stored link is used as default completion option, which is a common practice. You can also use C-u 1 C-c C-M-l to insert the last stored link. Or just C-c C-M-l. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at