我把emacs分割成一左一右两个窗口,一边是打开的pdf,另一边用org mode buffer记笔记用,我怎么才能在光标保持在org mode buffer的情况下,操作另一边的pdf buffer使它能上下滚动呢?
我试过scroll-other-window(C-M-v),发现不起作用……
我把emacs分割成一左一右两个窗口,一边是打开的pdf,另一边用org mode buffer记笔记用,我怎么才能在光标保持在org mode buffer的情况下,操作另一边的pdf buffer使它能上下滚动呢?
我试过scroll-other-window(C-M-v),发现不起作用……
用我的watch-other-window插件,scroll-other-window这个命令不知道哪个emacs版本后失效了
这个也不行啊,我刚试过……
我看你里面调用的是scroll-up/down,我发现这命令在PDFView buffer里根本不起作用……
你说EAF的pdf插件吗?可以啊,我每天都在用
我试了下eaf-pdf-viewer是可以的
(defun my/scroll-other-window-up ()
(interactive)
(save-window-excursion
(windmove-left)
(pdf-view-scroll-up-or-next-page)))
(defun my/scroll-other-window-down ()
(interactive)
(save-window-excursion
(windmove-left)
(pdf-view-scroll-down-or-previous-page)))
不是,我eaf暂时没用起来
这个功能很基础,我能确认至少27.2还在。
可以排除下配置或者pdf的问题,emacs -q 开两个窗口是否OK?
-q的话,pdf都打不开
可以看下普通的 buffer 是否可以滚动呀
普通的buffer一直是正常的
就是pdf不行
楼上那个调用pdf-view-scroll方法其实是可以的
绑定个快捷键就可以了
只是我感觉pdf-tools看pdf还是不太爽,跨页不能连续滚动,不过这个是另一个问题了
经过我的调研,最终采用了这样的配置:
(defun my/scroll-other-window ()
(interactive)
(let* ((wind (other-window-for-scrolling))
(mode (with-selected-window wind major-mode)))
(if (eq mode 'pdf-view-mode)
(with-selected-window wind
(pdf-view-next-line-or-next-page 2))
(scroll-other-window 2))))
(defun my/scroll-other-window-down ()
(interactive)
(let* ((wind (other-window-for-scrolling))
(mode (with-selected-window wind major-mode)))
(if (eq mode 'pdf-view-mode)
(with-selected-window wind
(progn
(pdf-view-previous-line-or-previous-page 2)
(other-window 1)))
(scroll-other-window-down 2))))
(bind-key "C-M-v" 'my/scroll-other-window org-mode-map)
(bind-key "C-M-S-v" 'my/scroll-other-window-down org-mode-map)
注意,这个配置滚动的单位不是一个page了,而是两行。如有需要可以自行更改。
供有需要的人参考
以前也有类似需求,这是我现在用的,需要配合 ace-window
来用。可以滚动分屏出的 任意窗口
(ace-window标出的窗口编号)。滚动时,第一次用 C-num
传个窗口编号参数进去,后面就记住该窗口了:
(defun lld/get-number-window (num)
"get window by ace number"
(when (numberp num)
(let ((found nil) window)
(dolist (win (aw-window-list))
(when (and (window-live-p win)
(eq num (string-to-number (window-parameter win 'ace-window-path))))
(setq found t)
(setq window win)
))
(unless found
(message "No specified window:%d" num))
window)))
(defun lld/scroll-window-num (&optional arg)
"根据winum 编号向下滚动窗口"
(interactive "P")
(let ((other-window-scroll-buffer nil)
(wnd (selected-window)))
(if arg
(progn
(setq other-window-scroll-buffer
(window-buffer (lld/get-number-window (prefix-numeric-value arg))))
(put 'lld/scroll-window-num 'last-other-window-scroll-buffer other-window-scroll-buffer)
(put 'lld/scroll-window-num-down 'last-other-window-scroll-buffer other-window-scroll-buffer))
(setq other-window-scroll-buffer (get 'lld/scroll-window-num 'last-other-window-scroll-buffer)))
(if (and other-window-scroll-buffer
(equal (with-current-buffer other-window-scroll-buffer
major-mode)
'pdf-view-mode))
(with-selected-window (get-buffer-window other-window-scroll-buffer)
(pdf-view-scroll-up-or-next-page)
(select-window wnd))
(scroll-other-window))))
(defun lld/scroll-window-num-down (&optional arg)
"根据winum编号向上滚动"
(interactive "P")
(let ((other-window-scroll-buffer nil)
(wnd (selected-window)))
(if arg
(progn
(setq other-window-scroll-buffer
(window-buffer (lld/get-number-window (prefix-numeric-value arg))))
(put 'lld/scroll-window-num 'last-other-window-scroll-buffer other-window-scroll-buffer)
(put 'lld/scroll-window-num-down 'last-other-window-scroll-buffer other-window-scroll-buffer))
(setq other-window-scroll-buffer (get 'lld/scroll-window-num-down 'last-other-window-scroll-buffer)))
(if (and other-window-scroll-buffer
(equal (with-current-buffer other-window-scroll-buffer
major-mode)
'pdf-view-mode))
(with-selected-window (get-buffer-window other-window-scroll-buffer)
(pdf-view-scroll-down-or-previous-page)
(select-window wnd))
(scroll-other-window '-))))
(global-set-key (kbd "M-[") 'lld/scroll-window-num-down)
(global-set-key (kbd "M-]") 'lld/scroll-window-num)
每一次见到这种按键时,我都被惊到了,这怎么下得去手!
双手并用,实在不行,脚也用上,哈哈哈
我刚从vim转过来时,也是被emacs的按键惊到,现在有点习惯了
你这个按键设置也不错,我那个主要是想跟原始的保持一致
你这个功能更强啊,在窗口比较多时很有用。
不过我目前还没有这种需要,等后面有了再来抄你的。
原来如此,一直不知道别人怎么按这个。单手按真是UFC的反关节技。