all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: "Rudolf Adamkovič" <salutis@me.com>
Cc: Max Nikulin <manikulin@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Exporting elisp: and shell: links
Date: Sun, 08 Oct 2023 09:48:07 +0000	[thread overview]
Message-ID: <87r0m5phrc.fsf@localhost> (raw)
In-Reply-To: <m2ttre9uvn.fsf@me.com>

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

Rudolf Adamkovič <salutis@me.com> writes:

>> Still, it would be nice to have _a_ variant compared to the current
>> state of affairs.
>
> Agreed.  If the link has no description, we can do a great job on
> exporting it.  Half of the victory, right there!
>
> Also, how about the following /simple/ idea for the description:
>
>   [[elisp:(server-start)][Launch Server]]
>   [[elisp:(server-start)][=M-x server-start RET=]]
>   
>   src_elisp[:exports code]{(server-start)} (Launch Server)
>   src_elisp[:exports code]{(server-start)} (=M-x server-start RET=)
>
> TL;DR We export the description, if any, in parentheses after the code.

See the attached diff, implementing your suggestion.
I am not sure if I like it.

Consider the following example file:

----
#+options: toc:nil author:nil

[[elisp:(message "Hello")]]

[[elisp:(message "Hello")][Message Hello]]
----

Without the diff, exporting to ASCII yields

----
<elisp:(message "Hello")>

[Message Hello]


[Message Hello] <elisp:(message "Hello")>
----

with the diff:

----
`(message "Hello")'

`(message "Hello")' (Message Hello)
---

For markdown:

without diff:
---
<(message "Hello")>

[Message Hello]((message "Hello"))

---

with:
---
`(message "Hello")`

`(message "Hello")` (Message Hello)
---

For html:

without diff:

[-- Attachment #2: html-without-diff.png --]
[-- Type: image/png, Size: 10838 bytes --]

[-- Attachment #3: Type: text/plain, Size: 7 bytes --]


with:

[-- Attachment #4: html-with-diff.png --]
[-- Type: image/png, Size: 13552 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: code-link-export.diff --]
[-- Type: text/x-patch, Size: 1755 bytes --]

diff --git a/lisp/ol.el b/lisp/ol.el
index 20aab6bb8..d537709ac 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1377,7 +1377,29 @@ (defun org-link--open-elisp (path _)
 		 (call-interactively (read path))))
     (user-error "Abort")))
 
-(org-link-set-parameters "elisp" :follow #'org-link--open-elisp)
+(defun org-link--export-code (path description _ info &optional lang)
+  "Export executable link with PATH and DESCRIPTION.
+INFO is the current export info plist.
+LANG is the language name, as in #+begin_src lang.  For example, \"elisp\"
+or \"shell\"."
+  (concat
+   (org-export-data
+    (org-element-create
+     'inline-src-block
+     `( :language ,lang
+        :value ,path
+        :parameters ":exports code :noweb no :eval never"))
+    info)
+   (when description (format " (%s)" description))))
+
+(defun org-link--export-elisp (path description _ info)
+  "Export elisp: link with PATH and DESCRIPTION according to INFO channel."
+  (org-link--export-code path description nil info "emacs-lisp"))
+
+(org-link-set-parameters
+ "elisp"
+ :follow #'org-link--open-elisp
+ :export #'org-link--export-elisp)
 
 ;;;; "file" link type
 (org-link-set-parameters "file" :complete #'org-link-complete-file)
@@ -1435,7 +1457,14 @@ (defun org-link--open-shell (path _)
 		      clean-buffer-list-kill-buffer-names))))
     (user-error "Abort")))
 
-(org-link-set-parameters "shell" :follow #'org-link--open-shell)
+(defun org-link--export-shell (path description _ info)
+  "Export shell: link with PATH and DESCRIPTION according to INFO channel."
+  (org-link--export-code path description nil info "shell"))
+
+(org-link-set-parameters
+ "shell"
+ :follow #'org-link--open-shell
+ :export #'org-link--export-shell)
 
 \f
 ;;; Interactive Functions

[-- Attachment #6: Type: text/plain, Size: 225 bytes --]



-- 
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>

  reply	other threads:[~2023-10-08  9:47 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 15:25 [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)] Csepp
2023-09-01  2:44 ` Max Nikulin
2023-09-01  9:04   ` [DISCUSSION] May we recognize everything like [[protocol:uri]] as a non-fuzzy link? (was: [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)]) Ihor Radchenko
2023-09-01 10:49     ` Dr. Arne Babenhauserheide
2023-09-01 11:01       ` Ihor Radchenko
2023-09-01 12:25         ` Dr. Arne Babenhauserheide
2023-09-02  7:26           ` Ihor Radchenko
2023-09-02  7:54             ` Dr. Arne Babenhauserheide
2023-09-04 14:58             ` Max Nikulin
2023-09-05 11:02               ` Ihor Radchenko
2023-09-06 14:27                 ` Max Nikulin
2023-09-07 10:42                   ` Ihor Radchenko
2023-09-07 11:07                     ` Max Nikulin
2023-09-07 11:22                       ` Ihor Radchenko
2023-09-01 12:15     ` [DISCUSSION] May we recognize everything like [[protocol:uri]] as a non-fuzzy link? Jens Lechtenboerger
2023-09-02  7:29       ` Ihor Radchenko
2023-09-01 18:53     ` [DISCUSSION] May we recognize everything like [[protocol:uri]] as a non-fuzzy link? (was: [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)]) Tom Gillespie
2023-09-02  7:45       ` Ihor Radchenko
2023-09-02 12:00     ` [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)] Max Nikulin
2023-09-03  7:53       ` Ihor Radchenko
2023-09-04 10:51         ` Max Nikulin
2023-09-05  9:42           ` Ihor Radchenko
2023-09-10  4:40             ` Max Nikulin
2023-09-17 22:08               ` Rudolf Adamkovič
2023-09-18 15:20                 ` Exporting elisp: and shell: links Max Nikulin
2023-09-19  0:10                   ` Rudolf Adamkovič
2023-09-19 15:19                     ` Max Nikulin
2023-09-21  9:49                       ` Ihor Radchenko
2023-09-22 23:43                         ` Rudolf Adamkovič
2023-09-25 14:38                           ` Max Nikulin
2023-09-26 10:42                             ` Ihor Radchenko
2023-09-28 15:31                               ` Rudolf Adamkovič
2023-10-08  9:48                                 ` Ihor Radchenko [this message]
2023-10-09 12:04                                   ` Max Nikulin
2023-10-09 12:12                                     ` Ihor Radchenko
2023-10-10 10:35                                       ` Max Nikulin
2023-10-12 11:35                                         ` Ihor Radchenko
2023-10-13 10:20                                           ` Max Nikulin
2023-10-14  8:13                                             ` Ihor Radchenko
2023-10-11 19:34                                   ` Rudolf Adamkovič
2024-02-05 15:41               ` [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)] Ihor Radchenko
2024-03-12 11:00                 ` Ihor Radchenko
2023-09-04 15:08     ` [DISCUSSION] May we recognize everything like [[protocol:uri]] as a non-fuzzy link? (was: [BUG] URI handling is overly complicated and nonstandard [9.6.7 (N/A @ /gnu/store/mg7223g8mw90lccp6mm5g6f3mpjk70si-emacs-org-9.6.7/share/emacs/site-lisp/org-9.6.7/)]) Max Nikulin

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r0m5phrc.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --cc=salutis@me.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.