emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [emacs-wiki-discuss] Open a files in emacs-wiki with external applic


From: Stéfan van der Walt
Subject: Re: [emacs-wiki-discuss] Open a files in emacs-wiki with external applications
Date: Wed, 30 Jul 2008 12:24:14 +0200

Hi Csanyi

2008/7/30 Csanyi Pal <address@hidden>:
> 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éfan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]