emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Joseph Vidal-Rosset <joseph.vidal.rosset@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: emacs-orgmode@gnu.org, Daryl Manning <dwm+orgmode@wakatara.com>
Subject: Re: Inserting org-mode heading links the org-refile way
Date: Mon, 04 May 2020 08:28:43 +0200	[thread overview]
Message-ID: <87r1w0rz6s.fsf@gmail.com> (raw)
In-Reply-To: <871ro0nv4u.fsf@localhost> (Ihor Radchenko's  message of "Mon, 04 May 2020 13:09:53 +0800")

Le   lun.   05/04/20   mai   2020    à   01:09:53   ,   Ihor   Radchenko
<yantar92@gmail.com> a envoyé 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.  
>
> (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: 

(setq org-agenda-custom-commands
      '(("t" "Agenda and Email-links tasks"
         ((agenda "")
          (tags-todo "email")
          (tags "link")))
        ))

;; (global-set-key (kbd "<f11> 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 
         "* 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-refile at a point; last: C-c C-t : DONE - F11-a: org-archive"
	  entry (file+headline "" "") ""
	 )
	)
      )
;; Merci à  Bob Newell , avec ce code, le lien de l'email est modifié correctement dès l'usage de la fonction refile C-c C-w  
  (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. 


  reply	other threads:[~2020-05-04  6:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 20:04 Daryl Manning
2020-05-04  5:09 ` Ihor Radchenko
2020-05-04  6:28   ` Joseph Vidal-Rosset [this message]
2020-05-04  7:11     ` Ihor Radchenko
2020-05-04 17:41       ` Joseph Vidal-Rosset
2020-05-05 14:19   ` Daryl Manning
2020-05-05 14:32     ` Ihor Radchenko
2020-05-07  2:13     ` Josh Moller-Mara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1w0rz6s.fsf@gmail.com \
    --to=joseph.vidal.rosset@gmail.com \
    --cc=dwm+orgmode@wakatara.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=yantar92@gmail.com \
    --subject='Re: Inserting org-mode heading links the org-refile way' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).