pes*_*che 5 emacs keyboard-shortcuts cua cua-mode
我想使用PgUp和PgDn键仅将显示的文件的内容向上或向下移动,但是光标(Emacs Lingo中的点)应保持在屏幕上的位置。不幸的是,默认的Emacs行为是不同的。默认行为很难描述,但是如果按PgDn后跟,PgUp则最终结果不会像以前一样(!)。
这不是一个新问题,存在一个名为很好的解决方案SFP-向上翻页和SFP-页面向下的EmacsWiki。
(defun sfp-page-up ()
(interactive)
(setq this-command 'previous-line)
(previous-line
(- (window-text-height)
next-screen-context-lines)))
Run Code Online (Sandbox Code Playgroud)
但是,与cua -mode 结合使用时会出现一个问题,该模式提供(尤其是)移位选择(按Shift和光标移动键,例如←或PgDn开始突出显示选定区域):
cua-mode无法识别重新定义的PgUp/ PgDn键,即它们不开始选择。解决方法是先按↑或↓键,然后按PgUp/ 继续PgDn。
我该如何cua-mode与他人打好关系sfp-page-up/down?
我在线程中找到了解决方案的另一半,如果我设置 home 键 (...) 然后 shift+home 不会在gnu.emacs.help上的cua 模式下选择文本:
要参与 的移位选择cua-mode,函数(在我的例子中sfp-page-xxx)必须将符号属性CUA设置为move:
(put 'sfp-page-up 'CUA 'move)
Run Code Online (Sandbox Code Playgroud)
(有关解决方案的前半部分,请参阅JSON 的答案)。
所以这是我的完整解决方案:
(defun sfp-page-down (&optional arg)
(interactive "^P")
(setq this-command 'next-line)
(next-line
(- (window-text-height)
next-screen-context-lines)))
(put 'sfp-page-down 'isearch-scroll t)
(put 'sfp-page-down 'CUA 'move)
(defun sfp-page-up (&optional arg)
(interactive "^P")
(setq this-command 'previous-line)
(previous-line
(- (window-text-height)
next-screen-context-lines)))
(put 'sfp-page-up 'isearch-scroll t)
(put 'sfp-page-up 'CUA 'move)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1744 次 |
| 最近记录: |