emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* elisp: links
@ 2006-05-22  1:50 Todd Neal
  2006-05-22  4:43 ` Carsten Dominik
  0 siblings, 1 reply; 2+ messages in thread
From: Todd Neal @ 2006-05-22  1:50 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: elisp: links
  2006-05-22  1:50 elisp: links Todd Neal
@ 2006-05-22  4:43 ` Carsten Dominik
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2006-05-22  4:43 UTC (permalink / raw)
  To: Todd Neal; +Cc: emacs-orgmode

Because so far I did not have a use for this.  But I am accepting the 
patch - good idea!.  Thanks.

- Carsten

On May 22, 2006, at 3:50, Todd Neal wrote:

>
> 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
>
>
>
> <org-elisp.patch>_______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-22  4:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-22  1:50 elisp: links Todd Neal
2006-05-22  4:43 ` Carsten Dominik

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