emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-link-set-parameters :complete how to prompt for description?
@ 2020-08-26 15:29 TRS-80
  2020-08-27 11:37 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: TRS-80 @ 2020-08-26 15:29 UTC (permalink / raw)
  To: emacs-orgmode

Good day, everyone!

I have been trying to create a new custom link type with
org-link-set-parameters, which in turn calls functions for the various
"methods" (for lack of a better term), like so:

   (org-link-set-parameters "zdlink"
			   :complete  #'my-zetteldeft-org-complete-link
			   :follow    #'my-zetteldeft-org-follow-link
			   :help-echo #'my-zetteldeft-org-help-echo
			   :store     #'my-zetteldeft-org-store-link)

The only one I seem to be having trouble with is :complete.  I can get 
it to
prompt me for completing-read, and it returns the link portion only, but 
how
to get it to also prompt for a description?  Here is my :complete 
function:

   (defun my-zetteldeft-org-complete-link ()
	"Link completion for Org zdlink type links"
	(let* ((file (completing-read "File to link to: "
		  (deft-find-all-files-no-prefix)))
	   (link (zetteldeft--lift-id file)))
    (unless link (user-error "No file selected"))
    (concat "zdlink:" link)))

I searched the Internet, this mailing list archives, etc. high and low, 
all
to no avail.  So I decide to join the mailing list today.  Probably long
overdue anyway.  :)

Any tips would be greatly appreciated.

Cheers,
TRS-80


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-link-set-parameters :complete how to prompt for description?
  2020-08-26 15:29 org-link-set-parameters :complete how to prompt for description? TRS-80
@ 2020-08-27 11:37 ` Ihor Radchenko
  2020-08-27 20:10   ` TRS-80
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2020-08-27 11:37 UTC (permalink / raw)
  To: TRS-80, emacs-orgmode

> Any tips would be greatly appreciated.

Take a look at org-link-make-description-function

Best,
Ihor


TRS-80 <trs-80@isnotmyreal.name> writes:

> Good day, everyone!
>
> I have been trying to create a new custom link type with
> org-link-set-parameters, which in turn calls functions for the various
> "methods" (for lack of a better term), like so:
>
>    (org-link-set-parameters "zdlink"
> 			   :complete  #'my-zetteldeft-org-complete-link
> 			   :follow    #'my-zetteldeft-org-follow-link
> 			   :help-echo #'my-zetteldeft-org-help-echo
> 			   :store     #'my-zetteldeft-org-store-link)
>
> The only one I seem to be having trouble with is :complete.  I can get 
> it to
> prompt me for completing-read, and it returns the link portion only, but 
> how
> to get it to also prompt for a description?  Here is my :complete 
> function:
>
>    (defun my-zetteldeft-org-complete-link ()
> 	"Link completion for Org zdlink type links"
> 	(let* ((file (completing-read "File to link to: "
> 		  (deft-find-all-files-no-prefix)))
> 	   (link (zetteldeft--lift-id file)))
>     (unless link (user-error "No file selected"))
>     (concat "zdlink:" link)))
>
> I searched the Internet, this mailing list archives, etc. high and low, 
> all
> to no avail.  So I decide to join the mailing list today.  Probably long
> overdue anyway.  :)
>
> Any tips would be greatly appreciated.
>
> Cheers,
> TRS-80


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-link-set-parameters :complete how to prompt for description?
  2020-08-27 11:37 ` Ihor Radchenko
@ 2020-08-27 20:10   ` TRS-80
  2020-08-28  1:26     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: TRS-80 @ 2020-08-27 20:10 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs-orgmode, emacs-orgmode

> On 2020-08-27 07:37, Ihor Radchenko wrote:
> 
>>    Any tips would be greatly appreciated.
> 
>   Take a look at org-link-make-description-function
> 
>   Best,
>   Ihor

Hi Ihor,

I am guessing you were referring to org-link-make-string?

I don't know how I missed that.  All I can say is I don't think
it is actually in the Docs anywhere.  Because I looked and
looked (as well as searching Internet)!

In either case, I truly am greatly appreciative, as promised.  :)
Thanks a lot, Ihor!

---

@All,

Apologies for any duplicates received, I seem to have some
trouble figuring out the correct thread and method to reply (even
though I don't usually have problem on other lists).

Assuming I didn't overlook it, perhaps this is an opportunity to
improve said Docs?

Cheers,
TRS-80


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: org-link-set-parameters :complete how to prompt for description?
  2020-08-27 20:10   ` TRS-80
@ 2020-08-28  1:26     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2020-08-28  1:26 UTC (permalink / raw)
  To: TRS-80; +Cc: Emacs-orgmode, emacs-orgmode

> I am guessing you were referring to org-link-make-string?

Well. Not really. But I am glad that you found the function you need.

Normally, org-link-make-description-function should be called for any
link inserted with org-insert-link to generate initial text for the
description prompt. The (possibly empty) prompt should actually be shown
regardless of the value of org-link-make-description-function. But I
guess you can as well directly return the link with description in your
completion function.

Best,
Ihor

TRS-80 <trs-80@isnotmyreal.name> writes:

>> On 2020-08-27 07:37, Ihor Radchenko wrote:
>> 
>>>    Any tips would be greatly appreciated.
>> 
>>   Take a look at org-link-make-description-function
>> 
>>   Best,
>>   Ihor
>
> Hi Ihor,
>
> I am guessing you were referring to org-link-make-string?
>
> I don't know how I missed that.  All I can say is I don't think
> it is actually in the Docs anywhere.  Because I looked and
> looked (as well as searching Internet)!
>
> In either case, I truly am greatly appreciative, as promised.  :)
> Thanks a lot, Ihor!
>
> ---
>
> @All,
>
> Apologies for any duplicates received, I seem to have some
> trouble figuring out the correct thread and method to reply (even
> though I don't usually have problem on other lists).
>
> Assuming I didn't overlook it, perhaps this is an opportunity to
> improve said Docs?
>
> Cheers,
> TRS-80


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-28  1:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-26 15:29 org-link-set-parameters :complete how to prompt for description? TRS-80
2020-08-27 11:37 ` Ihor Radchenko
2020-08-27 20:10   ` TRS-80
2020-08-28  1:26     ` Ihor Radchenko

Code repositories for project(s) associated with this public 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).