[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Bookmark a PDF, open in external program
From: |
Drew Adams |
Subject: |
RE: Bookmark a PDF, open in external program |
Date: |
Sat, 31 Jan 2015 10:31:59 -0800 (PST) |
> I use the Bookmarks+ module (perhaps not relevant). I also frequently read
> PDFs. But when I bookmark a PDF, jumping to it causes it to open within
> emacs, rather than with my system default viewer. There are many people
> asking similar questions online but the answers don't seem to fit; I can't
> use the dired solution of `!` to execute a shell command in this case. Any
> tips?
Since you use Bookmark+ the answer is yes, you can easily open
a bookmark that targets a PDF file using any application you like,
and you have several possibilities:
You can use option `bmkp-default-handlers-for-file-types' to
control which operation (bookmark handler) to use by default,
for which file types (e.g. PDF).
`M-x customize-option bmkp-default-handlers-for-file-types'
This is a set of associations (an alist), with each key being
a regexp matching file names, and with each associated value
being a Lisp sexp that evaluates to either a shell command
(a string) or an Emacs function (a symbol or lambda form).
You can think of `bmkp-default-handlers-for-file-types' as
somewhat analogous to `auto-mode-alist'. But it maps file-name
patterns to file actions instead of mapping them to buffer
modes. And it has an effect only when you use certain commands.
The default value of `bmkp-default-handlers-for-file-types'
is taken from the value of `dired-guess-shell-alist-user', so
you can, if you prefer, just customize that option. (That
option comes from standard library `dired-x.el'.)
If `bmkp-default-handlers-for-file-types' specifies no
matching association for a given file, and if option
`bmkp-guess-default-handler-for-file-flag' is non-nil,
then Bookmark+ guesses a shell command to use. It uses
`dired-guess-shell-alist-default' (first) and your mailcap
entries (second) to guess.
A bookmark that was created for a file without visiting it
(e.g., using `C-x p c f' or `C-x p c a') has its `file-handler'
property set automatically to the handler specified for its
type by `bmkp-default-handlers-for-file-types'.
If you are on MS Windows, then, in _addition_ to what is
said above:
* In the `*Bookmark List*' display you can use any of these to
open bookmarks using associated Windows `Open' applications:
`M-RET' - `bmkp-bmenu-w32-open': this bookmark (on this line)
`M-mouse-2' - `bmkp-bmenu-w32-open-with-mouse': clicked bookmark
`M-o' - `bmkp-bmenu-w32-jump-to-marked': this bookmark &
marked bookmarks
You can still associate particular bookmarks or file types
with particular shell commands or other programs, via option
`bmkp-default-handlers-for-file-types'.
But you can also take advantage of the file associations
that are defined outside Emacs, for Windows. You can thus
have two different associations for the same file type and
use either of them whenever you want.
* If you associate action `w32-browser' with a file type in
`bmkp-default-handlers-for-file-types' then you can use
command `bmkp-w32-browser-jump' (not bound to a key by
default) anytime to open a file of that type using the
Windows `Open' action.
* You can use command `bmkp-jump-to-type' (`C-x j :') and
input `w32-browser' as the bookmark type, to limit completion
candidates to bookmarks that are associated with `w32-browser'.
This is all covered in the Bookmark+ doc:
* All of the doc: http://www.emacswiki.org/emacs/BookmarkPlus
* `bmkp-default-handlers-for-file-types':
http://www.emacswiki.org/emacs/BookmarkPlus#BookmarkingFilesYouCannotVisitWithEmacs
* Using MS Windows file associations:
http://www.emacswiki.org/emacs/BookmarkPlus#WindowsFileAssociations