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 ODfmMUzBr16McAAA0tVLHw (envelope-from ) for ; Mon, 04 May 2020 07:16:28 +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 uB2hOFbBr156WAAA1q6Kng (envelope-from ) for ; Mon, 04 May 2020 07:16:38 +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 665469400D5 for ; Mon, 4 May 2020 07:16:37 +0000 (UTC) Received: from localhost ([::1]:60932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jVVLA-0002Xp-JJ for larch@yhetil.org; Mon, 04 May 2020 03:16:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jVVKg-0002WJ-LY for emacs-orgmode@gnu.org; Mon, 04 May 2020 03:16:08 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:43910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jVVKe-0006ZO-6d for emacs-orgmode@gnu.org; Mon, 04 May 2020 03:16:06 -0400 Received: by mail-pl1-x632.google.com with SMTP id z6so6432560plk.10 for ; Mon, 04 May 2020 00:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=HOrGQPGzlT3wkhvhPeBAHVd4uo0eJ2jTmpRElQsEPQY=; b=E6jqNlVABYbv9TVbcI/tvTggiOVrWcCDGP8TL9Hh7g4ehA9Fo+PzfjzN3a8kKpANg8 jRIXBpRV3O8ORYv3tCrgf1XAZzfAPromI8bindnUSgYxE7pcsNHGGoVQZtsAcKhGXsHl 1ADU9KsyQJoowmdZOpQkBce6r+T31PnnPTSV4JFDqb3zxqPsIU+OLWXMgJoWLaMZ0955 ji9Ox3oLJ2Uj5T9n4qrF4N9LDQje1M3fvVijs6aKF2a9IvToPAv20aKAXUWyX/Z4328m fQ7sOIf6T/wWhWEymNgH+qSlpvGCy4vc0xRZlJNzhQNb5N/GdbgYRAU8BogIt5jtTmxF f52A== 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:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=HOrGQPGzlT3wkhvhPeBAHVd4uo0eJ2jTmpRElQsEPQY=; b=foPoXlHEB7EzxGNKFpFkwPS2AC2BdNqQ8QWO4+PF4n0ajLTqlNgJRBRZRxm51IOTUY CFAWF6iXettmRrWO1dADBSpJJwrFdD+hKfgKhaFCVX+f0/FC1O635moDT0xhJyg5i4+I D2Xqi2bCKKANeffvoa6GlDwqDVjX0Jcd6iylW/iZ6v0lZy9v+Z9D4BQF2wWa/fIZAVXS Dn24YYQ3sT81PxsbjiYqGcOTWcNx7T/8LbcR5XOxjaKwi2xYu3zHqR25CgOVvlGKgpxD sO3BfYa6qnaFUN0aG3ZgaWmGD58YSuz8Q4TCJcsa4zEmoH75I+Lk830ZLhLDh984/WC1 Ri4w== X-Gm-Message-State: AGi0PuY0esln7HhjjsWT+6YC1wsIch37z9YBxS2xx6aWDclpdYy2shu1 9IvpXCTG2FkPSIPrpdUl9n8= X-Google-Smtp-Source: APiQypL1nMWeD7o711NiBSGYdjg5o+DkHDiC/vJEvdaXWy4XtbEcpCpo94Z5CAQoSM+wtAJBuXcPhA== X-Received: by 2002:a17:90a:35f0:: with SMTP id r103mr15763283pjb.167.1588576562615; Mon, 04 May 2020 00:16:02 -0700 (PDT) Received: from localhost ([210.3.160.218]) by smtp.gmail.com with ESMTPSA id c63sm8135701pfc.2.2020.05.04.00.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 00:16:01 -0700 (PDT) From: Ihor Radchenko To: Joseph Vidal-Rosset Subject: Re: Inserting org-mode heading links the org-refile way In-Reply-To: <87r1w0rz6s.fsf@gmail.com> References: <871ro0nv4u.fsf@localhost> <87r1w0rz6s.fsf@gmail.com> Date: Mon, 04 May 2020 15:11:57 +0800 Message-ID: <87y2q8mawy.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=yantar92@gmail.com; helo=mail-pl1-x632.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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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.59 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=E6jqNlVA; 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.59 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.49438733695428]; 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]; TAGGED_FROM(0.00)[larch=yhetil.org]; FROM_NEQ_ENVFROM(0.00)[yantar92@gmail.com,emacs-orgmode-bounces@gnu.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[6]; URIBL_BLOCKED(0.00)[sutd.edu.sg:email]; 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)[]; MID_RHS_NOT_FQDN(0.50)[]; FORGED_SENDER_MAILLIST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : SPF not aligned (relaxed),none] X-TUID: 4eA9s5jLIZXU > 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 It is also not very clear for me what could be broken in your setup. One guess would be that I use non-standard :desk link property to setup default link description. That property actually need some extra custom code to work. I imagine that it might somehow interfere with the existing org code when set. Can you try the following simplified code? (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))) (org-link-set-parameters "id" :complete #'org-id-link-complete) P.S. You can use %^t instead of %(org-insert-time-stamp ...). >From org-capture-templates docstring: > %^t Like %t, but prompt for date. Similarly %^T, %^u, %^U. > You may define a prompt like: %^{Please specify birthday}t. > The default date is that of %t, see above. Best, Ihor Joseph Vidal-Rosset writes: > Le lun. 05/04/20 mai 2020 =C3=A0 01:09:53 , Ihor Radch= enko > 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-tim= e-stamp (org-read-date nil t \"%:date\"))]] \n* %(org-insert-time-stamp (or= g-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-ref= ile 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 --=20 Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong U= niversity, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg