xyz
xyz

Reputation: 651

Emacs in Org mode, how to send file to specific program

I want to make links and send, for example, a text file to Firefox sometimes and sometimes to Gedit.

How can I make a link to tell Firefox to open the file.

The system has to be versatile, since sometimes I send a .jpg to Firefox and sometimes I use another program, but it has to be linked as hyperlink.

Upvotes: 1

Views: 233

Answers (2)

abo-abo
abo-abo

Reputation: 20362

How about this:

(setq reverse-org-file-apps 
  '(("firefox %s" . "\\.\\(?:xhtml\\|html\\|txt\\|jpg\\|png\\)")
    ("gedit %s" . "\\(?:txt\\|cc\\)")
    ("evince \"%s\"" . "\\.pdf\\'") 
    ("okular \"%s\"" . "\\.pdf\\'")))

(defun new-org-open-at-point (program)
  (interactive
   (list 
    (completing-read "Open with: "
                     reverse-org-file-apps
                     nil t)))
  (let* ((chosen-program (assoc program reverse-org-file-apps))
         (org-file-apps (list (cons (cdr chosen-program) 
                                    (car chosen-program)))))
    (org-open-at-point)))

(global-set-key (kbd "C-z") 'new-org-open-at-point)

Each time you invoke new-org-open-at-point, it'll give you a completion minibuffer with possible applications. You can extend reverse-org-file-apps as you like.

Upvotes: 1

lawlist
lawlist

Reputation: 13457

How about the file openwith.el ?

http://www.emacswiki.org/emacs/OpenWith

Upvotes: 1

Related Questions