【分享】同时滚动所有选中 PDF 缓冲区中的文档

在修改卡片时,时常需要把修改意见文档与更新后的文档同步向后或向前翻页。下面的脚本可以实现这个简单的功能。在使用过程中,首先需要选择哪些 PDF 文档要被处理。呼叫 wr/pdf-view-next-page-command-together 之后,用 C-<SPC> 选中后, 按下 RET 即可。之后,在 非 PDF 缓冲区中呼叫 wr/pdf-view-next-page-command-together 或者 wr/pdf-view-previous-page-command-together备份地址

(require 'ivy)
(require 'icicles-cmd1)

(defun my-insert-action (x)
  (push x impossible-2-have-same-name/pdfs-to-execute))

(defun wr-select-pdf-frames ()
  (interactive)
  (setq impossible-2-have-same-name/pdfs-to-execute nil)
  (let ((candidates (mapcar #'car (icicle-make-window-alist current-prefix-arg))))
    (ivy-read "choice: " candidates
              :action #'my-insert-action)))

(defun wr/pdf-view-next-page-command-together (&optional n)
  (interactive "p")
  (if (eq (derived-mode-p major-mode) 'PDFView)
      (message "Not able to execute from a PDF buffer.")
    (if impossible-2-have-same-name/pdfs-to-execute
      (dolist (buffer impossible-2-have-same-name/pdfs-to-execute)
        (with-current-buffer buffer
          (call-interactively #'pdf-view-next-page-command)))
    (call-interactively #'wr-select-pdf-frames))))

(defun wr/pdf-view-previous-page-command-together (&optional n)
  (interactive "p")
  (if (eq (derived-mode-p major-mode) 'PDFView)
      (message "Not able to execute from a PDF buffer.")
    (if impossible-2-have-same-name/pdfs-to-execute
      (dolist (buffer impossible-2-have-same-name/pdfs-to-execute)
        (with-current-buffer buffer
          (call-interactively #'pdf-view-previous-page-command)))
    (call-interactively #'wr-select-pdf-frames))))

(define-key ivy-minibuffer-map (kbd "C-<SPC>") 'ivy-mark)

(provide 'pdfs-together-action)
1 个赞