emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Todd Neal <tolchz@tolchz.net>
To: emacs-orgmode@gnu.org
Subject: elisp: links
Date: Sun, 21 May 2006 21:50:59 -0400	[thread overview]
Message-ID: <87psi64ykc.fsf@tolchz.net> (raw)

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


I checked the message archive and couldn't find anything regarding
links that eval elisp so I wrote up a quick patch.  Was there a reason
that they weren't included before (unsafe, not needed, etc.)?

Todd




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch to support elisp: links --]
[-- Type: text/x-patch, Size: 2565 bytes --]

--- ../org.el	2006-05-21 21:40:41.873116136 -0400
+++ org.el	2006-05-21 21:45:26.301876392 -0400
@@ -987,6 +987,26 @@
 	  (const :tag "with y-or-n (faster)" y-or-n-p)
 	  (const :tag "no confirmation (dangerous)" nil)))
 
+
+
+(defcustom org-confirm-elisp-links 'yes-or-no-p
+  "Non-nil means, ask for confirmation before executing elisp links.
+  Elisp links can be dangerous, just thing about a link
+
+     [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]]
+
+This link would show up in your Org-mode document as \"Google Search\"
+but really it would remove your entire home directory.  Dangerous indeed.
+Therefore I *definitely* advise agains setting this varaiable to nil.
+Just change it to `y-or-n-p' of you want to confirm with a single key press
+rather than having to type \"yes\"."
+  :group 'org-link-follow
+  :type '(choice
+	  (const :tag "with yes-or-no (safer)" yes-or-no-p)
+	  (const :tag "with y-or-n (faster)" y-or-n-p)
+	  (const :tag "no confirmation (dangerous)" nil)))
+
+
 (defconst org-file-apps-defaults-gnu
   '((t . mailcap))
   "Default file applications on a UNIX or GNU/Linux system.
@@ -2666,7 +2686,7 @@
 
 (defconst org-non-link-chars "]\t\n\r<>")
 (defconst org-link-types '("https?" "ftp" "mailto" "file" "news" "bbdb" "vm"
-			   "wl" "mhe" "rmail" "gnus" "shell"))
+			   "wl" "mhe" "rmail" "gnus" "shell" "elisp"))
 (defconst org-link-re-with-space 
   (concat
    "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
@@ -7812,6 +7832,16 @@
 		(shell-command cmd))
 	    (error "Abort"))))
 
+       ((string= type "elisp")
+	(let ((cmd path))
+	  (if (or (not org-confirm-elisp-links)
+		  (funcall org-confirm-elisp-links
+			   (format "Execute \"%s\" as elisp? "
+				   (org-add-props cmd nil
+				     'face 'org-warning))))
+              (message "%s => %s" cmd (eval (read cmd)))
+	    (error "Abort"))))
+
        (t
 	(browse-url-at-point))))))
 
@@ -8022,6 +8052,7 @@
 	(delete-window (get-buffer-window "*BBDB*"))
 	(error "No matching BBDB record")))))
 
+
 (defun org-follow-gnus-link (&optional group article)
   "Follow a Gnus link to GROUP and ARTICLE."
   (require 'gnus)
@@ -12569,7 +12600,7 @@
 					    (not descp))))
 			      (concat "<img src=\"" thefile "\"/>")
 			    (concat "<a href=\"" thefile "\">" desc "</a>")))))
-	     ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell"))
+	     ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell" "elisp"))
 	      (setq rpl (concat "<i>&lt;" type ":"
 				(save-match-data (org-link-unescape path))
 				"&gt;</i>"))))

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

_______________________________________________
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

             reply	other threads:[~2006-05-22  1:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-22  1:50 Todd Neal [this message]
2006-05-22  4:43 ` elisp: links Carsten Dominik

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=87psi64ykc.fsf@tolchz.net \
    --to=tolchz@tolchz.net \
    --cc=emacs-orgmode@gnu.org \
    /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).