emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Feature proposal] Add :description function to org-link-parameters
@ 2019-08-02 16:01 Ihor Radchenko
  2019-08-02 22:23 ` John Kitchin
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ihor Radchenko @ 2019-08-02 16:01 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Wondering if anyone is interested in adding a new org-link property to
customise generating the link description.

For now, there is global org-link-make-description-function, which is
shared among all the link types. If would be more convenient if the
description function can be set independently for different link types.

I propose to use :description property in org-link-parameters. A sample
implementation working with current org version is below:

#+begin_src emacs-lisp
(defun yant/org-make-link-description-function (link desk)
  "Return description of the link LINK according to :description link property.
Return DESK if :desk is not set."
  (let ((fun (org-link-get-parameter (car (split-string link ":")) :description)))
    (if (functionp fun)
	(funcall fun link desk)
      desk)))

(setq org-make-link-description-function #'yant/org-make-link-description-function)
#+end_src

Example usage:

#+begin_src emacs-lisp
(defun org-id-link-desk (link desk)
  "Description function for id: link."
  (let ((id (cadr (split-string link ":"))))
    (org-with-point-at (org-id-find id 'marker)
      (s-replace "||" "/" (yant/task-fulltitle)))))

(org-link-set-parameters "id" 
                         :desk #'org-id-link-desk)
#+end_src

Best,
Ihor


-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg

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

* Re: [Feature proposal] Add :description function to org-link-parameters
  2019-08-02 16:01 [Feature proposal] Add :description function to org-link-parameters Ihor Radchenko
@ 2019-08-02 22:23 ` John Kitchin
  2019-08-03  2:35   ` Ihor Radchenko
  2019-10-07  2:52 ` stardiviner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: John Kitchin @ 2019-08-02 22:23 UTC (permalink / raw)
  To: emacs-orgmode

This sounds reasonable. I was a little confused with the mixture of
of description and desk in the code below. If you replace desk with
description everywhere in your code is that what you mean?

Ihor Radchenko <yantar92@gmail.com> writes:

> Hi,
>
> Wondering if anyone is interested in adding a new org-link property to
> customise generating the link description.
>
> For now, there is global org-link-make-description-function, which is
> shared among all the link types. If would be more convenient if the
> description function can be set independently for different link types.
>
> I propose to use :description property in org-link-parameters. A sample
> implementation working with current org version is below:
>
> #+begin_src emacs-lisp
> (defun yant/org-make-link-description-function (link desk)
>   "Return description of the link LINK according to :description link property.
> Return DESK if :desk is not set."
>   (let ((fun (org-link-get-parameter (car (split-string link ":")) :description)))
>     (if (functionp fun)
> 	(funcall fun link desk)
>       desk)))
>
> (setq org-make-link-description-function #'yant/org-make-link-description-function)
> #+end_src
>
> Example usage:
>
> #+begin_src emacs-lisp
> (defun org-id-link-desk (link desk)
>   "Description function for id: link."
>   (let ((id (cadr (split-string link ":"))))
>     (org-with-point-at (org-id-find id 'marker)
>       (s-replace "||" "/" (yant/task-fulltitle)))))
>
> (org-link-set-parameters "id"
>                          :desk #'org-id-link-desk)
> #+end_src
>
> Best,
> Ihor


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

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

* Re: [Feature proposal] Add :description function to org-link-parameters
  2019-08-02 22:23 ` John Kitchin
@ 2019-08-03  2:35   ` Ihor Radchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2019-08-03  2:35 UTC (permalink / raw)
  To: John Kitchin, emacs-orgmode

Oops. Indeed, :desk should be replaced with :description. I used :desk
property in my personal config, but it may be confusing for others.

Best,
Ihor


John Kitchin <jkitchin@andrew.cmu.edu> writes:

> This sounds reasonable. I was a little confused with the mixture of
> of description and desk in the code below. If you replace desk with
> description everywhere in your code is that what you mean?
>
> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> Hi,
>>
>> Wondering if anyone is interested in adding a new org-link property to
>> customise generating the link description.
>>
>> For now, there is global org-link-make-description-function, which is
>> shared among all the link types. If would be more convenient if the
>> description function can be set independently for different link types.
>>
>> I propose to use :description property in org-link-parameters. A sample
>> implementation working with current org version is below:
>>
>> #+begin_src emacs-lisp
>> (defun yant/org-make-link-description-function (link desk)
>>   "Return description of the link LINK according to :description link property.
>> Return DESK if :desk is not set."
>>   (let ((fun (org-link-get-parameter (car (split-string link ":")) :description)))
>>     (if (functionp fun)
>> 	(funcall fun link desk)
>>       desk)))
>>
>> (setq org-make-link-description-function #'yant/org-make-link-description-function)
>> #+end_src
>>
>> Example usage:
>>
>> #+begin_src emacs-lisp
>> (defun org-id-link-desk (link desk)
>>   "Description function for id: link."
>>   (let ((id (cadr (split-string link ":"))))
>>     (org-with-point-at (org-id-find id 'marker)
>>       (s-replace "||" "/" (yant/task-fulltitle)))))
>>
>> (org-link-set-parameters "id"
>>                          :desk #'org-id-link-desk)
>> #+end_src
>>
>> Best,
>> Ihor
>
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg

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

* Re: [Feature proposal] Add :description function to org-link-parameters
  2019-08-02 16:01 [Feature proposal] Add :description function to org-link-parameters Ihor Radchenko
  2019-08-02 22:23 ` John Kitchin
@ 2019-10-07  2:52 ` stardiviner
  2020-02-04  8:13 ` Bastien
  2022-10-09  6:41 ` Ihor Radchenko
  3 siblings, 0 replies; 6+ messages in thread
From: stardiviner @ 2019-10-07  2:52 UTC (permalink / raw)
  To: emacs-orgmode


I propose this feature too. Hope can add this.

Ihor Radchenko <yantar92@gmail.com> writes:

> Hi,
>
> Wondering if anyone is interested in adding a new org-link property to
> customise generating the link description.
>
> For now, there is global org-link-make-description-function, which is
> shared among all the link types. If would be more convenient if the
> description function can be set independently for different link types.
>
> I propose to use :description property in org-link-parameters. A sample
> implementation working with current org version is below:
>
> #+begin_src emacs-lisp
> (defun yant/org-make-link-description-function (link desk)
>   "Return description of the link LINK according to :description link property.
> Return DESK if :desk is not set."
>   (let ((fun (org-link-get-parameter (car (split-string link ":")) :description)))
>     (if (functionp fun)
> 	(funcall fun link desk)
>       desk)))
>
> (setq org-make-link-description-function #'yant/org-make-link-description-function)
> #+end_src
>
> Example usage:
>
> #+begin_src emacs-lisp
> (defun org-id-link-desk (link desk)
>   "Description function for id: link."
>   (let ((id (cadr (split-string link ":"))))
>     (org-with-point-at (org-id-find id 'marker)
>       (s-replace "||" "/" (yant/task-fulltitle)))))
>
> (org-link-set-parameters "id" 
>                          :desk #'org-id-link-desk)
> #+end_src
>
> Best,
> Ihor


-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

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

* Re: [Feature proposal] Add :description function to org-link-parameters
  2019-08-02 16:01 [Feature proposal] Add :description function to org-link-parameters Ihor Radchenko
  2019-08-02 22:23 ` John Kitchin
  2019-10-07  2:52 ` stardiviner
@ 2020-02-04  8:13 ` Bastien
  2022-10-09  6:41 ` Ihor Radchenko
  3 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2020-02-04  8:13 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Hi Ihor,

Ihor Radchenko <yantar92@gmail.com> writes:

> Wondering if anyone is interested in adding a new org-link property to
> customise generating the link description.

yes, this sounds useful.

Can you propose a patch against current Org master branch?

See https://orgmode.org/worg/org-contribute.html on how to contribute.

If you need to contribute more than 15 lines of code or want to be
able to contribute later on, please fill this form:

https://code.orgmode.org/bzg/org-mode/raw/master/request-assign-future.txt

Also, as John noted already, "desk" is confusing, you can simply use
"description" (long names are not a problem.)

Thanks in advance!

-- 
 Bastien

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

* Re: [Feature proposal] Add :description function to org-link-parameters
  2019-08-02 16:01 [Feature proposal] Add :description function to org-link-parameters Ihor Radchenko
                   ` (2 preceding siblings ...)
  2020-02-04  8:13 ` Bastien
@ 2022-10-09  6:41 ` Ihor Radchenko
  3 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2022-10-09  6:41 UTC (permalink / raw)
  To: emacs-orgmode

Ihor Radchenko <yantar92@gmail.com> writes:

> Hi,
>
> Wondering if anyone is interested in adding a new org-link property to
> customise generating the link description.
>
> For now, there is global org-link-make-description-function, which is
> shared among all the link types. If would be more convenient if the
> description function can be set independently for different link types.
>
> I propose to use :description property in org-link-parameters. A sample
> implementation working with current org version is below:

For record, this feature has been implemented in
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e3a05d09b7398b46e8ef724ae7609eeb8a35346e

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2022-10-09  6:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-02 16:01 [Feature proposal] Add :description function to org-link-parameters Ihor Radchenko
2019-08-02 22:23 ` John Kitchin
2019-08-03  2:35   ` Ihor Radchenko
2019-10-07  2:52 ` stardiviner
2020-02-04  8:13 ` Bastien
2022-10-09  6:41 ` 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).