Browse Source

org-attach-attach: Avoid linking to path starting with ~

* lisp/org-attach.el (org-attach-attach): Auto-expand ~ in the file
patch when using symlink (`lns') attach method.

Fixes https://orgmode.org/list/CAN_Dec_LyTKgSN_kiftee9GULM7FPER5frQFant3n_2C3cwM-g@mail.gmail.com
Ihor Radchenko 2 years ago
parent
commit
ad304faea1
1 changed files with 2 additions and 1 deletions
  1. 2 1
      lisp/org-attach.el

+ 2 - 1
lisp/org-attach.el

@@ -525,7 +525,8 @@ METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from
        ((eq method 'mv) (rename-file file attach-file))
        ((eq method 'cp) (copy-file file attach-file))
        ((eq method 'ln) (add-name-to-file file attach-file))
-       ((eq method 'lns) (make-symbolic-link file attach-file))
+       ;; We pass integer third argument to auto-expand "~" in FILE.
+       ((eq method 'lns) (make-symbolic-link file attach-file 1))
        ((eq method 'url) (url-copy-file file attach-file)))
       (run-hook-with-args 'org-attach-after-change-hook attach-dir)
       (org-attach-tag)