Re: Open a files in emacs-wiki with external applications
"Stéfan van der Walt" <[email protected]> Wed, 30 Jul 2008 12:24:14 +0200
| Newsgroups | gmane.emacs.wiki.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Csanyi 2008/7/30 Csanyi Pal <[email protected]>: > Hello! > > Is it possible to open a file clicking on a link in emacs-wiki > mode with approppriate applications? > > Say one want to open a PDF file but with evince, or file.sch with > gschem application. Can one open these files with evince and gschem > respectively? > > Any advices will be appreciated! Here is what I use: ; Opening other kinds of files ; http://www.emacswiki.org/cgi-bin/wiki/TrivialMode ; by Cyprian Laskowski ; Modified to make buffer read only and to suppress output of command (defun define-trivial-mode(mode-prefix file-regexp &optional command) (or command (setq command mode-prefix)) (let ((mode-command (intern (concat mode-prefix "-mode")))) (fset mode-command `(lambda () (interactive) (toggle-read-only t) (start-process ,mode-prefix nil ,command (buffer-file-name)) (kill-buffer (current-buffer)))) (add-to-list 'auto-mode-alist (cons file-regexp mode-command))) ) (define-trivial-mode "gv" "\\.ps$") (define-trivial-mode "evince" "\\.pdf$") Alternatively: ;; This is how you would do it by hand ;; (defun view-pdf () ;; "Use evince to view PDFs." ;; (interactive) ;; (progn ;; (toggle-read-only t) ;; (start-process "pdf" nil ;; "evince" (buffer-file-name))) ;; ) ;; (add-to-list 'auto-mode-alist '("\\.pdf\\'" . view-pdf)) Hope that helps! Cheers St=E9fan