From: "Gustav Wikström" <gustav@whil.se>
To: "mail@nicolasgoaziou.fr" <mail@nicolasgoaziou.fr>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: FW: [RFC] Link-type for attachments, more attach options
Date: Sat, 17 Nov 2018 11:58:17 +0000 [thread overview]
Message-ID: <PR1PR02MB4732F970AA6D525029930F7CDADE0@PR1PR02MB4732.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <87muqo8o68.fsf@nicolasgoaziou.fr>
[-- Attachment #1: Type: text/plain, Size: 11534 bytes --]
Hi Nicolas,
Thanks for your detailed comments. Much appreciated.
> -----Original Message-----
> From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
> Sent: den 4 november 2018 23:37
> To: Gustav Wikström <gustav@whil.se>
> Cc: emacs-orgmode@gnu.org
> Subject: Re: FW: [RFC] Link-type for attachments, more attach options
>
> Hello,
>
> Gustav Wikström <gustav@whil.se> writes:
>
> > I’ve attached a patch with some suggested additions to org-attach.
> > Patch comments below. Please review.
>
> Thank you. Some comments follow.
>
> > * Add new linktype "attached" for attachments
>
> This seem a bit long. Why not "att" links?
Yeah - I liked "attached" because I prefer clear keywords. But sure, we can keep it shorter. I'd suggest "@" instead in that case. Patch updated with that.
>
> > * Add further options for ATTACH_DIR
> >
> > When working with ATTACH_DIR there are now a couple of new options available:
> > - org-attach-dir-inherit-by-default
>
> What is the difference between this and `org-attach-allow-inheritance'?
>
> > - org-attach-dir-create-if-not-exist
>
> What is the use-case for this one? It doesn't seem terribly useful at
> first glance.
If you try to open attachments on a node where there is no ID or ATTACH_DIR, the default behavior is to add an ID and create a folder based on that ID. I would like Org-mode to not do that. This customization give the user the option to change that. Instead of providing this customization one could just change the default behavior of org-attach, since it's a bit offensive to create folders when I didn't ask for it. But instead of changing the default, I thought this way was more graceful. I wouldn't mind skipping this customization though, if the behavior was changed to what I implemented with org-attach-dir-create-if-not-exist set to nil.
>
> > - org-attach-dir-relative
>
> I'm not sure to understand this one.
When adding folders to nodes using option "s" in org-attach, the path is absolute. This makes attachment-directory paths relative to location of the file instead.
> >
> > +This list shows the full set of built-in external link types:
> > +| http | web |
> > +| https | secure web |
> > +| doi | DOI for electronic resources |
> > +| file | file-links |
> > +| file+sys | file-links forced to open via OS |
> > +| file+emacs | file-links forced to open via emacs |
> > +| attached | links to attachments for nodes |
> > +| docview | doc-view mode |
> > +| id | Link to heading by id |
> > +| news | Usenet link |
> > +| mailto | mail link |
> > +| mhe | MH-E folder link |
> > +| rmail | Rmail link |
> > +| gnus | Gnus link |
> > +| bbdb | BBDB link |
> > +| irc | IRC link |
> > +| info | Info link |
> > +| shell | shell command |
> > +| elisp | interactive elisp command link |
> > +
> > +The following list shows examples for each link type.
> > +
> > +| =http://www.astro.uva.nl/=dominik= | on the web |
> > +| =doi:10.1000/182= | DOI for an electronic resource |
> > +| =file:/home/dominik/images/jupiter.jpg= | file, absolute path |
> > +| =/home/dominik/images/jupiter.jpg= | same as above |
> > +| =file:papers/last.pdf= | file, relative path |
> > +| =./papers/last.pdf= | same as above |
> > +| =file:/ssh:me@some.where:papers/last.pdf= | file, path on remote machine |
> > +| =/ssh:me@some.where:papers/last.pdf= | same as above |
> > +| =file:sometextfile::NNN= | file, jump to line number |
> > +| =file:projects.org= | another Org file |
> > +| =file:projects.org::some words= | text search in Org file[fn:28] |
> > +| =file:projects.org::*task title= | heading search in Org file |
> > +| =file+sys:/path/to/file= | open via OS, like double-click |
> > +| =file+emacs:/path/to/file= | force opening by Emacs |
> > +| =attached:projects.org= | file in folder attached to headline |
> > +| =attached:projects.org::some words= | text search in attached file |
> > +| =docview:papers/last.pdf::NNN= | open in doc-view mode at page |
> > +| =id:B7423F4D-2E8A-471B-8810-C40F074717E9= | link to heading by ID |
> > +| =news:comp.emacs= | Usenet link |
> > +| =mailto:adent@galaxy.net= | mail link |
> > +| =mhe:folder= | MH-E folder link |
> > +| =mhe:folder#id= | MH-E message link |
> > +| =rmail:folder= | Rmail folder link |
> > +| =rmail:folder#id= | Rmail message link |
> > +| =gnus:group= | Gnus group link |
> > +| =gnus:group#id= | Gnus article link |
> > +| =bbdb:R.*Stallman= | BBDB link (with regexp) |
> > +| =irc:/irc.com/#emacs/bob= | IRC link |
> > +| =info:org#External links= | Info node link |
> > +| =shell:ls *.org= | shell command |
> > +| =elisp:org-agenda= | interactive Elisp command |
> > +| =elisp:(find-file "Elisp.org")= | Elisp form to evaluate |
>
> I'm not sure to like the change above. It introduces a lot of
> redundancy.
>
Currently the list in the documentation is just a bunch of examples. I've looked at it a couple of times asking myself "What is the complete list of built in link types?". This commit "fixes" that. I wouldn't say its redundant since all the rows in the second list are just examples.
> > Here is the syntax of the different ways to attach a search to a file
> > link, together with explanations for each:
> >
> > #+begin_example
> > -[[file:~/code/main.c::255]]
> > -[[file:~/xx.org::My Target]]
> > -[[file:~/xx.org::*My Target]]
> > -[[file:~/xx.org::#my-custom-id]]
> > -[[file:~/xx.org::/regexp/]]
> > + [[file:~/code/main.c::255]]
> > + [[file:~/xx.org::My Target]]
> > + [[file:~/xx.org::*My Target]]
> > + [[file:~/xx.org::#my-custom-id]]
> > + [[file:~/xx.org::/regexp/]]
> > + [[attached:~/code/main.c::255]]
> > #+end_example
>
> Please discard this change.
Ofc, sorry for that.
>
> > +Another method is /attachments/, which are files located in a
> > +directory belonging to an outline node. Org uses directories either
> > +named by the unique ID of each entry, or by the =ATTACH_DIR= property.
> > +ID-based directories are by default located in the ~data~ directory
>
> ... =data/= directory, which ...
Done.
>
> > +(defcustom org-attach-dir-inherit-by-default nil
> > + "Defines whether ATTACH_DIR-directories should be inherited by
> > + subheadings by default when created. Defaults to not being
> > + inherited."
> > + :group 'org-attach
> > + :type 'boolean)
>
> First line in a docstring must be a full sentence. Indentation is wrong
> in the subsequent lines. Also, the `defcustom' is missing keywords,
> e.g., :package-version and :safe.
I can't say I understand the use of :safe here. But added it anyways. If you care, please explain why it's needed. Package-version is added. I set it to 9.2. Correct?
>
> > +(defcustom org-attach-dir-create-if-not-exists t
> > + "Choose whether ATTACH_DIR-directories should be created if
> > +they do not exist since before. Default is to create them."
> > + :group 'org-attach
> > + :type 'boolean)
> > +
> > +(defcustom org-attach-dir-relative nil
> > + "Choose whether ATTACH_DIR-directories should be added as
> > +relative links or not. Defaults to not relative."
> > + :group 'org-attach
> > + :type 'boolean)
>
> Ditto.
Ok
>
> > (defcustom org-attach-commit t
> > "If non-nil commit attachments with git.
> > This is only done if the Org file is in a git repository."
> > @@ -280,20 +299,26 @@ Throw an error if we cannot root the directory."
> > "Set the ATTACH_DIR node property and ask to move files there.
> > The property defines the directory that is used for attachments
> > of the entry. When called with `\\[universal-argument]', reset \
> > -the directory to
> > -the default ID based one."
> > +the directory to the default ID based one. Creates relative links
>
> You need to use two spaces to separate sentences.
Ah, yes ofc. Fixed.
>
> > + (let ((old (org-attach-dir nil))
> > + (new
> > + (progn
> > + (if arg (org-entry-delete nil "ATTACH_DIR")
> > + (let* ((attach-dir (read-directory-name
> > + "Attachment directory: "
> > + (org-entry-get nil
> > + "ATTACH_DIR")))
> > + (current-dir (file-name-directory (or load-file-name
> > + buffer-file-name)))
>
> Why `load-file-name'? Why not using `default-directory'?
Good question. I don't remember having any particular arguments for it. I'll change to your suggestion.
>
> > +(defun org-attach-open-link (link &optional in-emacs)
> > + "LINK is expanded with the attached directory and opened the same
> > +way as file-links are."
>
> You need to expound the arguments in the docstring.
Sorry, I don't understand what I'm supposed to do here... I changed the comment to (maybe?) make it read better. Other than that, I'm at a loss.
>
> > + (file-types-re (format "[][]\\[\\(?:file\\|attached\\|[./~]%s\\)"
> > (if (not link-abbrevs) ""
> > (format "\\|\\(?:%s:\\)"
> > (regexp-opt link-abbrevs))))))
>
> Why is it needed? "attached" link type is already registered, so you
> don't need to also hard-code it here.
This is when parsing the buffer for images. I couldn't get org-mode to display images without this.
>
> > + (when (and (or (equal "file" (org-element-property :type link))
> > + (equal "attached" (org-element-property :type link)))
>
> Ditto.
Same comment as above.
>
> > + (let ((file (if (equal "attached" (org-element-property :type link))
> > + (require 'org-attach)
> > + (org-attach-expand
> > + (org-link-unescape
> > + (org-element-property :path link)))
> > + (expand-file-name
> > + (org-link-unescape
> > + (org-element-property :path link))))))
>
> Ditto.
Same comment as above.
>
> Regards,
>
> --
> Nicolas Goaziou
Thanks again for your comments. Updated patch is attached/att/@!
Kind regards,
Gustav
[-- Attachment #2: 0001-org-attach-org-manual-org-New-link-type-more-attach-.patch --]
[-- Type: application/octet-stream, Size: 17679 bytes --]
From f556e3e1dcfff6103e54aee244bbeacf13aeeb55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gustav=20Wikstr=C3=B6m?= <gustav.erik@gmail.com>
Date: Sun, 23 Sep 2018 02:43:16 +0200
Subject: [PATCH] org-attach, org-manual, org: New link-type, more attach
options
* Add new linktype "attached" for attachments
A new linktype "attached" is added in order to reduce link-duplication
when wanting to link to files in attached folders of nodes. This works
for both ID-based attachments and ATTACH_DIR. Inline images will
trigger also for attachments, as well as search-decorations in the
links. The goal is to make the functionality for attached-links
mirror file-links.
* Add further options for ATTACH_DIR
When working with ATTACH_DIR there are now a couple of new options available:
- org-attach-dir-inherit-by-default
- org-attach-dir-create-if-not-exist
- org-attach-dir-relative
Descriptions of them can be found in the commit for each new customization.
* Documentation in org-manual
Org-manual is updated with the new link-type as well as some minor
cleanup in the documentation related to external links and attachments.
---
doc/org-manual.org | 72 ++++++++++++++++-------
lisp/org-attach.el | 143 ++++++++++++++++++++++++++++++++++++---------
lisp/org.el | 17 ++++--
3 files changed, 181 insertions(+), 51 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 5e4effb6f..960292ab2 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -3141,6 +3141,7 @@ point on or at a target.
#+cindex: irc links
#+cindex: URL links
#+cindex: file links
+#+cindex: @ links
#+cindex: Rmail links
#+cindex: MH-E links
#+cindex: Usenet links
@@ -3152,7 +3153,30 @@ Org supports links to files, websites, Usenet and email messages, BBDB
database entries and links to both IRC conversations and their logs.
External links are URL-like locators. They start with a short
identifying string followed by a colon. There can be no space after
-the colon. The following list shows examples for each link type.
+the colon.
+
+This list shows the full set of built-in external link types:
+| http | web |
+| https | secure web |
+| doi | DOI for electronic resources |
+| file | file-links |
+| file+sys | file-links forced to open via OS |
+| file+emacs | file-links forced to open via emacs |
+| @ | links to attachments for nodes |
+| docview | doc-view mode |
+| id | Link to heading by id |
+| news | Usenet link |
+| mailto | mail link |
+| mhe | MH-E folder link |
+| rmail | Rmail link |
+| gnus | Gnus link |
+| bbdb | BBDB link |
+| irc | IRC link |
+| info | Info link |
+| shell | shell command |
+| elisp | interactive elisp command link |
+
+The following list shows examples for each link type.
| =http://www.astro.uva.nl/=dominik= | on the web |
| =doi:10.1000/182= | DOI for an electronic resource |
@@ -3168,6 +3192,8 @@ the colon. The following list shows examples for each link type.
| =file:projects.org::*task title= | heading search in Org file |
| =file+sys:/path/to/file= | open via OS, like double-click |
| =file+emacs:/path/to/file= | force opening by Emacs |
+| =@:projects.org= | file attached to headline |
+| =@:projects.org::some words= | text search in attached file |
| =docview:papers/last.pdf::NNN= | open in doc-view mode at page |
| =id:B7423F4D-2E8A-471B-8810-C40F074717E9= | link to heading by ID |
| =news:comp.emacs= | Usenet link |
@@ -3538,14 +3564,15 @@ the link completion function like this:
:END:
#+cindex: search option in file links
#+cindex: file links, searching
+#+cindex: @ links, searching
-File links can contain additional information to make Emacs jump to
-a particular location in the file when following a link. This can be
-a line number or a search option after a double colon[fn:35]. For
-example, when the command ~org-store-link~ creates a link (see
-[[*Handling Links]]) to a file, it encodes the words in the current line
-as a search string that can be used to find this line back later when
-following the link with {{{kbd(C-c C-o)}}}.
+File links and attached (@) links can contain additional information
+to make Emacs jump to a particular location in the file when following
+a link. This can be a line number or a search option after a double
+colon[fn:35]. For example, when the command ~org-store-link~ creates
+a link (see [[*Handling Links]]) to a file, it encodes the words in the
+current line as a search string that can be used to find this line
+back later when following the link with {{{kbd(C-c C-o)}}}.
Here is the syntax of the different ways to attach a search to a file
link, together with explanations for each:
@@ -3556,6 +3583,7 @@ link, together with explanations for each:
[[file:~/xx.org::*My Target]]
[[file:~/xx.org::#my-custom-id]]
[[file:~/xx.org::/regexp/]]
+[[@:~/code/main.c::255]]
#+end_example
- =255= ::
@@ -7533,18 +7561,22 @@ node/task. Small chunks of plain text can simply be stored in the
subtree of a project. Hyperlinks (see [[*Hyperlinks]]) can establish
associations with files that live elsewhere on your computer or in the
cloud, like emails or source code files belonging to a project.
-Another method is /attachments/, which are files located in
-a directory belonging to an outline node. Org uses directories named
-by the unique ID of each entry. These directories are located in the
-~data~ directory which lives in the same directory where your Org file
-lives[fn:86]. If you initialize this directory with =git init=, Org
-automatically commits changes when it sees them. The attachment
-system has been contributed to Org by John Wiegley.
-
-In cases where it seems better to do so, you can attach a directory of
-your choice to an entry. You can also make children inherit the
-attachment directory from a parent, so that an entire subtree uses the
-same attached directory.
+Another method is /attachments/, which are files located in a
+directory belonging to an outline node. Org uses directories either
+named by the unique ID of each entry, or by the =ATTACH_DIR= property.
+ID-based directories are by default located in the =data/= directory,
+which lives in the same directory where your Org file lives[fn:86].
+If you initialize this directory with =git init=, Org automatically
+commits changes when it sees them. The attachment system has been
+contributed to Org by John Wiegley.
+
+In cases where =ATTACH_DIR= property is used to declare attachments,
+you can choose to either use absolute (default) or relative links.
+You can also make children inherit the attachment directory from a
+parent, so that an entire subtree uses the same attached directory.
+
+See customization group =Org Attach= if you want to change the default
+settings for attachments.
The following commands deal with attachments:
diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index e827d3721..bc7f02669 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -57,6 +57,30 @@ where the Org file lives."
:type 'directory
:safe #'stringp)
+(defcustom org-attach-dir-inherit-by-default nil
+ "Defines whether ATTACH_DIR-directories should be inherited by subheadings by default when created.
+Defaults to not being inherited."
+ :group 'org-attach
+ :type 'boolean
+ :package-version '(Org . "9.2")
+ :safe #'booleanp)
+
+(defcustom org-attach-dir-create-if-not-exists t
+ "Choose whether ATTACH_DIR-directories should be created if they do not exist since before.
+Default is to create them."
+ :group 'org-attach
+ :type 'boolean
+ :package-version '(Org . "9.2")
+ :safe #'booleanp)
+
+(defcustom org-attach-dir-relative nil
+ "Choose whether ATTACH_DIR-directories should be added as relative links or not.
+Defaults to not relative."
+ :group 'org-attach
+ :type 'boolean
+ :package-version '(Org . "9.2")
+ :safe #'booleanp)
+
(defcustom org-attach-commit t
"If non-nil commit attachments with git.
This is only done if the Org file is in a git repository."
@@ -280,20 +304,26 @@ Throw an error if we cannot root the directory."
"Set the ATTACH_DIR node property and ask to move files there.
The property defines the directory that is used for attachments
of the entry. When called with `\\[universal-argument]', reset \
-the directory to
-the default ID based one."
+the directory to the default ID based one. Creates relative
+links if ORG-ATTACH-DIR-RELATIVE is t, and sets inheritance based
+on ORG-ATTACH-DIR-INHERIT-BY-DEFAULT."
(interactive "P")
- (let ((old (org-attach-dir))
- (new
- (progn
- (if arg (org-entry-delete nil "ATTACH_DIR")
- (let ((dir (read-directory-name
- "Attachment directory: "
- (org-entry-get nil
- "ATTACH_DIR"
- (and org-attach-allow-inheritance t)))))
- (org-entry-put nil "ATTACH_DIR" dir)))
- (org-attach-dir t))))
+ (let ((old (org-attach-dir nil))
+ (new
+ (progn
+ (if arg (org-entry-delete nil "ATTACH_DIR")
+ (let* ((attach-dir (read-directory-name
+ "Attachment directory: "
+ (org-entry-get nil
+ "ATTACH_DIR")))
+ (current-dir (file-name-directory (or default-directory
+ buffer-file-name)))
+ (attach-dir-relative (file-relative-name attach-dir current-dir)))
+ (if org-attach-dir-relative
+ (org-entry-put nil "ATTACH_DIR" attach-dir-relative)
+ (org-entry-put nil "ATTACH_DIR" attach-dir))))
+ (org-attach-dir t))))
+ (when org-attach-dir-inherit-by-default (org-attach-set-inherit))
(unless (or (string= old new)
(not old))
(when (yes-or-no-p "Copy over attachments from old directory? ")
@@ -527,14 +557,15 @@ This ignores files ending in \"~\"."
"Show the attachment directory of the current task.
This will attempt to use an external program to show the directory."
(interactive "P")
- (let ((attach-dir (org-attach-dir (not if-exists))))
- (and attach-dir (org-open-file attach-dir))))
+ (let* ((create-if-not-exist (if if-exists nil org-attach-dir-create-if-not-exists))
+ (attach-dir (org-attach-dir create-if-not-exist)))
+ (when attach-dir (org-open-file attach-dir))))
(defun org-attach-reveal-in-emacs ()
"Show the attachment directory of the current task in dired."
(interactive)
- (let ((attach-dir (org-attach-dir t)))
- (dired attach-dir)))
+ (let ((attach-dir (org-attach-dir org-attach-dir-create-if-not-exists)))
+ (when attach-dir (dired attach-dir))))
(defun org-attach-open (&optional in-emacs)
"Open an attachment of the current task.
@@ -543,15 +574,17 @@ This command will open the file using the settings in `org-file-apps'
and in the system-specific variants of this variable.
If IN-EMACS is non-nil, force opening in Emacs."
(interactive "P")
- (let* ((attach-dir (org-attach-dir t))
- (files (org-attach-file-list attach-dir))
- (file (if (= (length files) 1)
- (car files)
- (completing-read "Open attachment: "
- (mapcar #'list files) nil t)))
- (path (expand-file-name file attach-dir)))
- (org-attach-annex-get-maybe path)
- (org-open-file path in-emacs)))
+ (let ((attach-dir (org-attach-dir org-attach-dir-create-if-not-exists)))
+ (if attach-dir
+ (let* ((files (org-attach-file-list attach-dir))
+ (file (if (= (length files) 1)
+ (car files)
+ (completing-read "Open attachment: "
+ (mapcar #'list files) nil t)))
+ (path (expand-file-name file attach-dir)))
+ (org-attach-annex-get-maybe path)
+ (org-open-file path in-emacs))
+ (message "No attachment exists!"))))
(defun org-attach-open-in-emacs ()
"Open attachment, force opening in Emacs.
@@ -570,6 +603,64 @@ Basically, this adds the path to the attachment directory, and a \"file:\"
prefix."
(concat "file:" (org-attach-expand file)))
+(defun org-attach-open-link (link &optional in-emacs)
+ "Attach link type LINK is expanded with the attached directory and opened.
+This is done in the same way as file-links are opened."
+ (interactive "P")
+ (let (line search)
+ (if (string-match "::\\([0-9]+\\)\\'" link)
+ (setq line (string-to-number (match-string 1 link))
+ link (substring link 0 (match-beginning 0)))
+ (if (string-match "::\\(.+\\)\\'" link)
+ (setq search (match-string 1 link)
+ link (substring link 0 (match-beginning 0)))))
+ (if (string-match "[*?{]" (file-name-nondirectory link))
+ (dired (org-attach-expand link))
+ (org-open-file (org-attach-expand link) in-emacs line search))))
+
+(defun org-attach-complete-link ()
+ "Advise the user with the available files in the attachment directory."
+ (let (file link attached-dir)
+ (setq attached-dir (expand-file-name (org-attach-dir)))
+ (setq file (read-file-name "File: " attached-dir))
+ (let ((pwd (file-name-as-directory attached-dir))
+ (pwd1 (file-name-as-directory (abbreviate-file-name
+ attached-dir))))
+ (cond
+ ((string-match (concat "^" (regexp-quote pwd1) "\\(.+\\)") file)
+ (setq link (concat "@:" (match-string 1 file))))
+ ((string-match (concat "^" (regexp-quote pwd) "\\(.+\\)")
+ (expand-file-name file))
+ (setq link (concat
+ "@:" (match-string 1 (expand-file-name file)))))
+ (t (setq link (concat "@:" file)))))
+ link))
+
+(defun org-attach-export-link (link description format)
+ "Translate \"attached\" (@) LINK from Org mode format to exported FORMAT.
+Also includes the DESCRIPTION of the link in the export."
+ (save-excursion
+ (let (path desc)
+ (if (string-match "::\\([0-9]+\\)\\'" link)
+ (setq link (substring link 0 (match-beginning 0)))
+ (if (string-match "::\\(.+\\)\\'" link)
+ (setq link (substring link 0 (match-beginning 0)))))
+ (search-forward (concat "@:" (org-link-escape link)))
+ (setq path (file-relative-name (org-attach-expand link))
+ desc (or description link))
+ (pcase format
+ (`html (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
+ (`latex (format "\\href{%s}{%s}" path desc))
+ (`texinfo (format "@uref{%s,%s}" path desc))
+ (`ascii (format "%s (%s)" desc path))
+ (`md (format "[%s](%s)" desc path))
+ (_ path)))))
+
+(org-link-set-parameters "@"
+ :follow 'org-attach-open-link
+ :export 'org-attach-export-link
+ :complete 'org-attach-complete-link)
+
(defun org-attach-archive-delete-maybe ()
"Maybe delete subtree attachments when archiving.
This function is called by `org-archive-hook'. The option
diff --git a/lisp/org.el b/lisp/org.el
index eb1affbc7..9ed663bb9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4428,6 +4428,7 @@ This is needed for font-lock setup.")
(beg end))
(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
(declare-function org-agenda-skip "org-agenda" ())
+(declare-function org-attach-expand "org-attach" (&optional if-exists))
(declare-function org-attach-reveal "org-attach" (&optional if-exists))
(declare-function org-gnus-follow-link "org-gnus" (&optional group article))
(declare-function org-indent-mode "org-indent" (&optional arg))
@@ -18721,7 +18722,7 @@ boundaries."
;; Check absolute, relative file names and explicit
;; "file:" links. Also check link abbreviations since
;; some might expand to "file" links.
- (file-types-re (format "[][]\\[\\(?:file\\|[./~]%s\\)"
+ (file-types-re (format "[][]\\[\\(?:file\\|@\\|[./~]%s\\)"
(if (not link-abbrevs) ""
(format "\\|\\(?:%s:\\)"
(regexp-opt link-abbrevs))))))
@@ -18730,14 +18731,20 @@ boundaries."
;; Check if we're at an inline image, i.e., an image file
;; link without a description (unless INCLUDE-LINKED is
;; non-nil).
- (when (and (equal "file" (org-element-property :type link))
+ (when (and (or (equal "file" (org-element-property :type link))
+ (equal "@" (org-element-property :type link)))
(or include-linked
(null (org-element-contents link)))
(string-match-p file-extension-re
(org-element-property :path link)))
- (let ((file (expand-file-name
- (org-link-unescape
- (org-element-property :path link)))))
+ (let ((file (if (equal "@" (org-element-property :type link))
+ (require 'org-attach)
+ (org-attach-expand
+ (org-link-unescape
+ (org-element-property :path link)))
+ (expand-file-name
+ (org-link-unescape
+ (org-element-property :path link))))))
(when (file-exists-p file)
(let ((width
;; Apply `org-image-actual-width' specifications.
--
2.19.1.windows.1
next prev parent reply other threads:[~2018-11-17 11:58 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-21 7:53 FW: [RFC] Link-type for attachments, more attach options Gustav Wikström
2018-11-01 1:45 ` tumashu
2018-11-02 22:40 ` Gustav Wikström
2018-11-01 16:00 ` Marco Wahl
2018-11-02 23:07 ` Gustav Wikström
2018-11-03 3:37 ` Ihor Radchenko
2018-11-17 12:13 ` Gustav Wikström
2018-11-18 0:42 ` Ihor Radchenko
2018-11-18 8:57 ` Gustav Wikström
2018-11-20 14:00 ` Ihor Radchenko
2018-11-24 13:56 ` Gustav Wikström
2018-12-14 2:16 ` Ihor Radchenko
2019-05-26 22:24 ` Gustav Wikström
2018-11-04 22:37 ` Nicolas Goaziou
2018-11-17 11:58 ` Gustav Wikström [this message]
[not found] ` <PR1PR02MB47322711B7F7B7142D156F54DADE0@PR1PR02MB4732.eurprd02.prod.outlook.com>
2018-11-19 23:52 ` Nicolas Goaziou
2018-11-25 21:13 ` Gustav Wikström
2018-11-27 9:39 ` Nicolas Goaziou
2019-05-26 23:05 ` Gustav Wikström
2019-06-15 13:29 ` Nicolas Goaziou
2019-06-15 15:38 ` Bastien
2019-06-30 6:03 ` Gustav Wikström
2019-07-06 21:46 ` Nicolas Goaziou
2019-07-07 18:38 ` Gustav Wikström
2019-07-08 10:47 ` Marco Wahl
2019-07-09 10:16 ` Nicolas Goaziou
2019-07-27 14:56 ` Ihor Radchenko
2019-07-28 20:39 ` Gustav Wikström
2019-07-28 23:20 ` Ihor Radchenko
2019-01-04 12:21 ` FW: " Feng Shu
2019-05-26 23:15 ` Gustav Wikström
2019-12-12 5:21 ` stardiviner
2019-12-12 6:12 ` Gustav Wikström
2019-12-12 9:52 ` stardiviner
2019-12-12 19:42 ` Gustav Wikström
2019-12-13 13:38 ` stardiviner
2019-12-13 21:37 ` Gustav Wikström
2019-12-13 22:15 ` Gustav Wikström
2019-12-15 4:14 ` stardiviner
2019-12-15 9:29 ` stardiviner
2019-12-15 10:06 ` Gustav Wikström
2019-12-15 14:26 ` stardiviner
2019-12-15 20:41 ` Gustav Wikström
2019-12-16 3:38 ` stardiviner
2019-12-16 11:21 ` stardiviner
2019-12-17 4:27 ` stardiviner
2020-01-13 12:24 ` attachment: link type export to HTML invalid attach dir stardiviner
2020-01-14 3:27 ` Gustav Wikström
2020-01-14 5:04 ` stardiviner
2020-01-14 20:58 ` Gustav Wikström
2020-01-15 5:53 ` stardiviner
2020-01-15 19:48 ` Gustav Wikström
2020-01-16 11:06 ` stardiviner
2020-01-16 13:18 ` Nicolas Goaziou
2020-01-16 21:42 ` Gustav Wikström
2020-01-16 23:07 ` Gustav Wikström
2020-01-17 0:39 ` Nicolas Goaziou
2020-01-17 14:29 ` Gustav Wikström
2020-01-17 18:36 ` Gustav Wikström
2020-01-18 1:13 ` Gustav Wikström
2020-01-18 11:34 ` Nicolas Goaziou
2020-01-18 15:14 ` Gustav Wikström
2020-01-19 21:12 ` Nicolas Goaziou
2020-01-19 23:29 ` Gustav Wikström
2020-01-20 1:25 ` Nicolas Goaziou
2020-01-25 11:34 ` Gustav Wikström
2020-02-05 16:54 ` Nicolas Goaziou
2020-02-06 20:55 ` Gustav Wikström
2020-02-07 14:28 ` Nicolas Goaziou
2020-02-08 15:39 ` Gustav Wikström
2020-02-13 20:41 ` Nicolas Goaziou
2020-02-13 21:11 ` Gustav Wikström
2020-02-13 21:37 ` Nicolas Goaziou
2020-02-13 22:07 ` Gustav Wikström
2020-02-14 0:16 ` Nicolas Goaziou
2020-02-14 7:23 ` Gustav Wikström
2020-02-14 2:42 ` Kyle Meyer
2020-02-14 7:35 ` Gustav Wikström
2020-02-14 7:41 ` Gustav Wikström
2020-02-14 11:06 ` Bastien
2020-02-14 17:12 ` Nicolas Goaziou
2020-02-14 20:33 ` Bastien
2020-02-15 18:08 ` Nicolas Goaziou
2020-02-15 23:04 ` Kyle Meyer
2020-02-16 8:51 ` Nicolas Goaziou
2020-02-16 23:59 ` Bastien
2020-02-17 9:37 ` Nicolas Goaziou
2020-02-17 10:25 ` Bastien
2020-02-16 23:58 ` Bastien
2020-02-17 10:32 ` Nicolas Goaziou
2020-02-17 10:53 ` Bastien
2020-02-20 9:20 ` Nicolas Goaziou
2020-02-20 10:20 ` Bastien
2020-02-22 12:58 ` Nicolas Goaziou
2020-02-22 13:32 ` Bastien
2020-02-25 23:36 ` Gustav Wikström
2020-02-26 15:22 ` Nicolas Goaziou
2020-02-27 19:02 ` Gustav Wikström
2020-02-28 0:37 ` Nicolas Goaziou
2020-02-13 21:57 ` Gustav Wikström
2020-02-14 10:02 ` Bastien
2020-01-13 13:41 ` FW: [RFC] Link-type for attachments, more attach options stardiviner
2020-01-14 21:17 ` Gustav Wikström
2020-01-15 6:20 ` stardiviner
2020-01-15 22:42 ` Gustav Wikström
2020-01-16 11:15 ` stardiviner
2020-01-18 14:56 ` stardiviner
2020-01-18 15:30 ` Gustav Wikström
2020-01-19 4:28 ` stardiviner
2020-01-19 9:53 ` Gustav Wikström
2020-01-17 7:39 ` Missing `org-attach-set-inherit' function stardiviner
2020-01-17 16:31 ` Gustav Wikström
2020-01-18 14:54 ` stardiviner
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=PR1PR02MB4732F970AA6D525029930F7CDADE0@PR1PR02MB4732.eurprd02.prod.outlook.com \
--to=gustav@whil.se \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).