Emacs: Replace init-pdf by pdf-tools
parent
ba3799fcda
commit
f5ac496622
|
@ -204,9 +204,9 @@ e-mail."
|
|||
(with-eval-after-load 'org (require 'init-org))
|
||||
|
||||
;;; PDF
|
||||
;;; TODO: Replace with pdf-tools package?
|
||||
(autoload 'pdf-view "init-pdf" nil t)
|
||||
(autoload 'pdf-compress "init-pdf" nil t)
|
||||
(nconc package-selected-packages '(pdf-tools))
|
||||
(when (require 'pdf-tools nil t)
|
||||
(pdf-tools-install))
|
||||
|
||||
;;; Perl
|
||||
(defun perl-set-indent-rules ()
|
||||
|
|
|
@ -31,13 +31,11 @@
|
|||
(require 'dired-x)
|
||||
(setq dired-omit-files "^\\.")
|
||||
|
||||
(require 'init-pdf) ; for `pdf-viewer'
|
||||
(setq dired-guess-shell-alist-user
|
||||
(list
|
||||
'("\\.ogg$" "mpv")
|
||||
'("\\.\\(jpe?g\\|png\\|git\\)$" "sxiv")
|
||||
'("\\.\\(mkv\\|mpe?g\\|avi\\|mp4\\|ogm\\)$" "mpv")
|
||||
'("\\.pdf$" (concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))))
|
||||
'("\\.\\(mkv\\|mpe?g\\|avi\\|mp4\\|ogm\\)$" "mpv")))
|
||||
|
||||
(defvar dired-showing-humansize t "If dired is displaying humansize or not.")
|
||||
|
||||
|
|
|
@ -18,10 +18,8 @@
|
|||
;;; Agendas.
|
||||
(add-to-list 'org-agenda-files "~/personal/todo/todo.org")
|
||||
|
||||
;;; Set PDF association in Org-mode (was Evince by default).
|
||||
(require 'init-pdf)
|
||||
(setcdr (assoc "\\.pdf\\'" org-file-apps)
|
||||
(concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))
|
||||
;;; Set PDF association in Org-mode (original is 'default).
|
||||
(setcdr (assoc "\\.pdf\\'" org-file-apps) 'emacs)
|
||||
|
||||
;;; Hooks.
|
||||
(dolist (fun '(turn-off-linum turn-off-indent-tabs turn-off-auto-fill))
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
;;; PDF utils
|
||||
|
||||
(defvar pdf-compressor "pdfctl" "PDF compressor.")
|
||||
|
||||
(defvar pdf-viewer "zathura" "PDF viewer.")
|
||||
|
||||
(defvar pdf-viewer-args
|
||||
'("--fork"
|
||||
"-x" "emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'")
|
||||
"List of arguments passed to `pdf-viewer' when called.
|
||||
You may want to fork the viewer so that it detects when the same
|
||||
document is launched twice, and persists when Emacs gets closed.\n
|
||||
For instance with `zathura':\n
|
||||
zathura --fork\n
|
||||
We can use\n
|
||||
emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'\n
|
||||
to reverse-search a PDF using SyncTeX. Note this can only work
|
||||
with emacsclient since we need to communicate the command to an
|
||||
existing instance.")
|
||||
|
||||
;;;###autoload
|
||||
(defun pdf-compress (&optional file)
|
||||
"Call `pdf-compessor' over FILE.
|
||||
If FILE is not provided, use PDF associated to current buffer
|
||||
filename. If called with universal argument, prompt for filename.
|
||||
It FILE is not a PDF, the extension is automatically replaced by
|
||||
.pdf."
|
||||
(interactive
|
||||
(list (if (equal current-prefix-arg '(4))
|
||||
(expand-file-name (read-file-name "PDF to view: " nil nil t
|
||||
(concat (file-name-base buffer-file-name) ".pdf"))))))
|
||||
(let ((pdf (concat
|
||||
(file-name-sans-extension
|
||||
(if file file
|
||||
buffer-file-name))
|
||||
".pdf")))
|
||||
(when (and (file-exists-p pdf) (file-writable-p pdf)
|
||||
(executable-find pdf-compressor))
|
||||
(start-process "dummy" nil pdf-compressor "compress" "-i" pdf)
|
||||
(message "File %s compressed." pdf))))
|
||||
|
||||
;;;###autoload
|
||||
(defun pdf-view (&optional file)
|
||||
"Call `pdf-viewer' over FILE.
|
||||
If FILE is not provided, use PDF associated to current buffer
|
||||
filename. If called with universal argument, prompt for filename.
|
||||
It FILE is not a PDF, the extension is automatically replaced by
|
||||
.pdf."
|
||||
(interactive
|
||||
(list (if (equal current-prefix-arg '(4))
|
||||
(expand-file-name (read-file-name "PDF to view: " nil nil t
|
||||
(concat (file-name-base buffer-file-name) ".pdf"))))))
|
||||
(let ((pdf (concat
|
||||
(file-name-sans-extension
|
||||
(if file file
|
||||
buffer-file-name))
|
||||
".pdf")))
|
||||
(when (and
|
||||
(file-exists-p pdf) (file-writable-p pdf)
|
||||
(executable-find pdf-viewer))
|
||||
(apply 'start-process "dummy" nil pdf-viewer pdf pdf-viewer-args))))
|
||||
|
||||
(provide 'init-pdf)
|
|
@ -84,21 +84,13 @@ This command should be safe, but there is no warranty."
|
|||
(delete-file file)
|
||||
(message "Deleted %S." file)))))
|
||||
|
||||
(defun tex-pdf-compress ()
|
||||
"Use `tex-masterfile' variable as default value for `pdf-compress'."
|
||||
(interactive)
|
||||
(require 'init-pdf)
|
||||
(hack-local-variables)
|
||||
(let ((master (or tex-masterfile buffer-file-name)))
|
||||
(pdf-compress master)))
|
||||
|
||||
(defun tex-pdf-view ()
|
||||
"Use `tex-masterfile' variable as default value for `pdf-view'."
|
||||
"Find PDF file associated to `tex-masterfile' if set or buffer-filename otherwise."
|
||||
(interactive)
|
||||
(require 'init-pdf)
|
||||
(hack-local-variables)
|
||||
(let ((master (or tex-masterfile buffer-file-name)))
|
||||
(pdf-view master)))
|
||||
(find-file (concat
|
||||
(file-name-sans-extension (or tex-masterfile buffer-file-name))
|
||||
".pdf")))
|
||||
|
||||
(defun tex-toggle-escape-char ()
|
||||
"Make backslash part of the word syntax or not.
|
||||
|
|
Loading…
Reference in New Issue