From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 4I2YJiy2r14uawAA0tVLHw (envelope-from ) for ; Mon, 04 May 2020 06:29:00 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id COuULDa2r15WNgAA1q6Kng (envelope-from ) for ; Mon, 04 May 2020 06:29:10 +0000 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::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 A5D2C944612 for ; Mon, 4 May 2020 06:29:09 +0000 (UTC) Received: from localhost ([::1]:43194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVUbF-0007Ky-VR for larch@yhetil.org; Mon, 04 May 2020 02:29:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVUau-0007Kn-RR for emacs-orgmode@gnu.org; Mon, 04 May 2020 02:28:48 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:37474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVUat-00070w-8G for emacs-orgmode@gnu.org; Mon, 04 May 2020 02:28:48 -0400 Received: by mail-wm1-x333.google.com with SMTP id z6so7612289wml.2 for ; Sun, 03 May 2020 23:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=ww5Wd5zLalSZYC48Jap1X2hV1+p9RecU192mptUNiSg=; b=t35v8Imd62285sqfdRckpU+ah3FIQFbOW0RVIojiHLgCECEG9tKgMF39Dq8LSWN5xz G/zGi+EbWh16js39Ir2n2ZT9LWDbhX/srKK2fxrIBs+7bCGsUAb1iInIRbxS4fAWO9d0 ZzDU2dBYIN4uBpsbkSVzvSFdSAK9K3N6402Vhe6Ls5ijEYDP+lCdHoa6GRVA/XFOHEKU DolUjKvYAwLbQOAtY1L0AY+3o6pui3cf8gZcoQT3NERAMPAvKyDvR1RitNGLbxUVrqn7 z+YWfi+JmdNMN64wqdrawmSzM+j8e/W+d7ODGtI7O+f5lBAd06gBlWe+94YKuRJB1+oP M2IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=ww5Wd5zLalSZYC48Jap1X2hV1+p9RecU192mptUNiSg=; b=eXNQ3LpU35GRu8BfZdQ+j/1EuCzybU4BKa4WxtdLv1xqy8x00ACQB/3zNzDdqYmGAb lUDsOUnS9JVIxNXYFNhubI7NGua9tu5jTuimOGB53AW/zZ8PrjEyDhz7ScgScuZcmreu t2BTDpJaDA+BSSVXzn+lEJJguJxzPf/ECfE3Q/tUdpAkoN+Ti/Q521SMp+j+U89k+IlA rjGI8reUZWKltb7Ra0KDjj62rFM8o9eF2jZhZxCUBG0KD2R5ymhxlPvD7Ndc/4VqdpSh Bb+V+jYKvhaZoKstOi3qmmAd38nn475cTszmu94DG1M16r3cnpF/+Ot/wpJLHM5OBmmn 2NSg== X-Gm-Message-State: AGi0PuZpxGO+sS01VViu6MQyW2Rz5K2KF8p6VWv9a+iX9n1aRfJ09Jt1 fE2xppoKm/TNr32o1F9xOZE0+vBFgMw= X-Google-Smtp-Source: APiQypJf5QPq86ZkVPGIEz7Rebx5VQMnwWS7s4rIqhcORlyI3jbv2TmVgkExJN7MaRKlPdcpA/IjWQ== X-Received: by 2002:a05:600c:2945:: with SMTP id n5mr12761255wmd.148.1588573724921; Sun, 03 May 2020 23:28:44 -0700 (PDT) Received: from debian ([2a01:e0a:21e:7710:f8d4:6c6b:9bb:e9bc]) by smtp.gmail.com with ESMTPSA id s8sm13813159wrt.69.2020.05.03.23.28.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 May 2020 23:28:44 -0700 (PDT) From: Joseph Vidal-Rosset To: Ihor Radchenko Subject: Re: Inserting org-mode heading links the org-refile way References: <871ro0nv4u.fsf@localhost> Date: Mon, 04 May 2020 08:28:43 +0200 In-Reply-To: <871ro0nv4u.fsf@localhost> (Ihor Radchenko's message of "Mon, 04 May 2020 13:09:53 +0800") Message-ID: <87r1w0rz6s.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=joseph.vidal.rosset@gmail.com; helo=mail-wm1-x333.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: emacs-orgmode@gnu.org, Daryl Manning Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 X-Spam-Score: 0.09 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=t35v8Imd; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 2001:470:142::17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Scan-Result: default: False [0.09 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49431569405042]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2001:470:142::/48:c]; R_DKIM_REJECT(1.00)[gmail.com:s=20161025]; DWL_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; FREEMAIL_FROM(0.00)[gmail.com]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.14), country: US(-0.00), ip: 2001:470:142::17(-0.49)]; DKIM_TRACE(0.00)[gmail.com:-]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; MAILLIST(-0.20)[mailman]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_FAIL(0.00)[2001:470:142::17:server fail]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22989, ipnet:2001:470:142::/48, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[josephvidalrosset@gmail.com,emacs-orgmode-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; TAGGED_RCPT(0.00)[orgmode]; PREVIOUSLY_DELIVERED(0.00)[emacs-orgmode@gnu.org]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FORGED_SENDER_MAILLIST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : SPF not aligned (relaxed),none] X-TUID: mgtG8//9+1pC Le lun. 05/04/20 mai 2020 =C3=A0 01:09:53 , Ihor Radchen= ko a envoy=C3=A9 ce message: > If I understand you correctly, the following code should achieve what > you want. The code reuses org-refile interface to complete id: links.=20= =20 > > (defun org-id-prompt-id () > "Prompt for the id during completion of id: link." > (let ((org-refile-history nil) > (org-refile-cache nil) > (org-refile-target-verify-function nil)) > (let ((prompt-ans (org-refile-get-location "Select org entry"))) > (prog1 > (or (org-id-get (seq-find #'markerp > prompt-ans) > 'create) > (user-error "Cannot find ID of the entry: %s" prompt-ans)) > (setq org-id-history org-refile-history) > (setq org-id-cache org-refile-cache))))) > > (defun org-id-link-complete (&optional arg) > "Completion function for id: link." > (let* ((id (org-id-prompt-id))) > (format "id:%s" id))) > > (defun org-id-link-desk (link desk) > "Description function for id: link." > (or desk > (let ((id (cadr (split-string link ":")))) > (org-with-point-at (org-id-find id 'marker) > (org-get-heading 'strip 'all 'the 'extra))))) > > (org-link-set-parameters "id" > :complete #'org-id-link-complete > :desk #'org-id-link-desk) Hi, Always interested in org-links, I have tested your code. It will maybe interesting that I point out that, even if I am unable to understand why, I have checked that it breaks the function for org-linking from emails in gnus, at least in my setup i.e. with the following code:=20 (setq org-agenda-custom-commands '(("t" "Agenda and Email-links tasks" ((agenda "") (tags-todo "email") (tags "link"))) )) ;; (global-set-key (kbd " c") 'org-capture) ;; capture todo items using C-c c t ;; (define-key global-map (kbd "C-c c") 'org-capture) (setq org-capture-templates '( ("t" "todo" entry (file+headline "~/Dropbox/Orgzly/todo.org" "Tasks") "* TODO [#A] %?\n [[~/Dropbox/Orgzly/links.org::%(org-insert-time-= stamp (org-read-date nil t \"%:date\"))]] \n* %(org-insert-time-stamp (org-= read-date nil t \"%:date\")) %a " ) ("n" ; key "note" ;name entry ;type (file+headline "~/Dropbox/Orgzly/notes.org" "Notes") ;target=20 "* NOTE du %(org-insert-time-stamp (org-read-date nil t \"%:date\"= )) \n Voir %a " ; template ) ("H" "HOWTO: C-c C-s : schedule ; C-c C-d : deadline ; C-c C-w : org-refil= e at a point; last: C-c C-t : DONE - F11-a: org-archive" entry (file+headline "" "") "" ) ) ) ;; Merci =C3=A0 Bob Newell , avec ce code, le lien de l'email est modifi= =C3=A9 correctement d=C3=A8s l'usage de la fonction refile C-c C-w=20=20 (defun jr/fix-the-link (&rest args) (interactive) (save-excursion (find-file "~/Dropbox/Orgzly/todo.org") (goto-char (point-min)) (while (search-forward "gnus:INBOX#" nil t) (replace-match "gnus:\\[Gmail\\]/Tous les messages#")) (save-buffer))) (advice-add 'org-capture-finalize :after #'jr/fix-the-link) Best wishes, Jo.=20