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))
|
(with-eval-after-load 'org (require 'init-org))
|
||||||
|
|
||||||
;;; PDF
|
;;; PDF
|
||||||
;;; TODO: Replace with pdf-tools package?
|
(nconc package-selected-packages '(pdf-tools))
|
||||||
(autoload 'pdf-view "init-pdf" nil t)
|
(when (require 'pdf-tools nil t)
|
||||||
(autoload 'pdf-compress "init-pdf" nil t)
|
(pdf-tools-install))
|
||||||
|
|
||||||
;;; Perl
|
;;; Perl
|
||||||
(defun perl-set-indent-rules ()
|
(defun perl-set-indent-rules ()
|
||||||
|
|
|
@ -31,13 +31,11 @@
|
||||||
(require 'dired-x)
|
(require 'dired-x)
|
||||||
(setq dired-omit-files "^\\.")
|
(setq dired-omit-files "^\\.")
|
||||||
|
|
||||||
(require 'init-pdf) ; for `pdf-viewer'
|
|
||||||
(setq dired-guess-shell-alist-user
|
(setq dired-guess-shell-alist-user
|
||||||
(list
|
(list
|
||||||
'("\\.ogg$" "mpv")
|
'("\\.ogg$" "mpv")
|
||||||
'("\\.\\(jpe?g\\|png\\|git\\)$" "sxiv")
|
'("\\.\\(jpe?g\\|png\\|git\\)$" "sxiv")
|
||||||
'("\\.\\(mkv\\|mpe?g\\|avi\\|mp4\\|ogm\\)$" "mpv")
|
'("\\.\\(mkv\\|mpe?g\\|avi\\|mp4\\|ogm\\)$" "mpv")))
|
||||||
'("\\.pdf$" (concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))))
|
|
||||||
|
|
||||||
(defvar dired-showing-humansize t "If dired is displaying humansize or not.")
|
(defvar dired-showing-humansize t "If dired is displaying humansize or not.")
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,8 @@
|
||||||
;;; Agendas.
|
;;; Agendas.
|
||||||
(add-to-list 'org-agenda-files "~/personal/todo/todo.org")
|
(add-to-list 'org-agenda-files "~/personal/todo/todo.org")
|
||||||
|
|
||||||
;;; Set PDF association in Org-mode (was Evince by default).
|
;;; Set PDF association in Org-mode (original is 'default).
|
||||||
(require 'init-pdf)
|
(setcdr (assoc "\\.pdf\\'" org-file-apps) 'emacs)
|
||||||
(setcdr (assoc "\\.pdf\\'" org-file-apps)
|
|
||||||
(concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))
|
|
||||||
|
|
||||||
;;; Hooks.
|
;;; Hooks.
|
||||||
(dolist (fun '(turn-off-linum turn-off-indent-tabs turn-off-auto-fill))
|
(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)
|
(delete-file file)
|
||||||
(message "Deleted %S." 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 ()
|
(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)
|
(interactive)
|
||||||
(require 'init-pdf)
|
|
||||||
(hack-local-variables)
|
(hack-local-variables)
|
||||||
(let ((master (or tex-masterfile buffer-file-name)))
|
(find-file (concat
|
||||||
(pdf-view master)))
|
(file-name-sans-extension (or tex-masterfile buffer-file-name))
|
||||||
|
".pdf")))
|
||||||
|
|
||||||
(defun tex-toggle-escape-char ()
|
(defun tex-toggle-escape-char ()
|
||||||
"Make backslash part of the word syntax or not.
|
"Make backslash part of the word syntax or not.
|
||||||
|
|
Loading…
Reference in New Issue