emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] New "project" option for org-link-file-path-type


From: Kyle Meyer
Subject: Re: [PATCH] New "project" option for org-link-file-path-type
Date: Thu, 05 Nov 2020 22:33:10 -0500

Jack Kamm writes:

> I like the idea of letting org-link-file-path-type be a function.
>
> However, it struck me that it might be too limiting to just have the
> function return the project root. There's a lot more potential for
> customization here -- for example, a user might want to combine the
> noabbrev option with the adaptive option. If we could instead pass a
> function that takes the filename as an argument and returns the path to
> insert, that would allow for greater flexibility.
>
> Other benefits are that the implementation is much simpler, and
> subjectively I think it's more intuitive to explain the meaning of this
> option (as opposed to an option where the user passes a function that
> returns the project root).
>
> The downside of this is that the user has to do a bit more work and
> write some elisp to take advantage of the option.
>
> I've attached an updated patch in this direction. What do you think? I
> think the simplicity and flexibility outweighs the downside, but I'm not
> sure.

I think that's a good direction to go (for the reasons you laid out, not
just because it lets me use this with projectile :).

> +++ b/etc/ORG-NEWS
> @@ -35,6 +35,25 @@ omit a file description was to omit the header argument 
> entirely,
>  which made it difficult/impossible to provide a default value for
>  =file-desc=.
>  
> +*** New option to set ~org-link-file-path-type~ to a function
> +
> +If ~org-link-file-path-type~ can now be set to a function that takes
> +the full filename as an argument and returns the path to link to.

Drop "If"?

> +For example, if you use ~project.el~, you can set this function to use
> +relative links within a project as follows:
> +
> +#+begin_src emacs-lisp
> +(setq (org-link-file-path-type
> +       (lambda (path)
> +         (let* ((proj (project-current))
> +                (root (if proj (project-root proj) default-directory)))
> +           (if (string-prefix-p (expand-file-name root) path)
> +               (progn
> +                 (file-relative-name path))
> +             (abbreviate-file-name path))))))
> +#+end_src

superfluous progn



reply via email to

[Prev in Thread] Current Thread [Next in Thread]