gpt4 book ai didi

emacs - 了解 Emacs CUA 模式以进行 shift 单击选择

转载 作者:行者123 更新时间:2023-12-01 02:34:00 24 4
gpt4 key购买 nike

我是 Emacs 的新手,正在弄清楚如何启用 shift-click 选择。在 CUA Mode 的 EmacsWiki 页面上,以下代码片段概述了如何执行此操作:

;; shift + click select region
(define-key global-map (kbd "<S-down-mouse-1>") 'ignore) ; turn off font dialog
(define-key global-map (kbd "<S-mouse-1>") 'mouse-set-point)
(put 'mouse-set-point 'CUA 'move)

我不明白最后一行是如何启用选择的。我查看了 的定义放 :
put is a built-in function in `C source code'.

(put SYMBOL PROPNAME VALUE)

Store SYMBOL's PROPNAME property with value VALUE.
It can be retrieved with `(get SYMBOL PROPNAME)'.

以及 的定义鼠标设置点 :
mouse-set-point is an interactive compiled Lisp function in
`mouse.el'.

It is bound to <S-mouse-1>, <triple-mouse-1>, <double-mouse-1>,
<mouse-1>.

(mouse-set-point EVENT)

Move point to the position clicked on with the mouse.
This should be bound to a mouse click event type.

但他们都没有给出任何线索。我找不到任何名为 的变量或函数搬家 ,我还查看了 mouse.el、cua-base.el、cua-gmrk.el 和 cua-rect.el 的源代码。

有人会解释最后一行是如何工作的,以及我如何自己找到更多信息吗?谢谢。

最佳答案

我没有深入研究 CUA 模式,但我明白你在找什么。 'put' 是符号属性列表的函数。在这种情况下,符号是鼠标设置点,并且您正在将该符号的属性“CUA”设置为值“移动”。要读回符号的属性值,您可以使用函数“get”。您可以在 GNU 网页上的 Elisp 引用手册中找到更多带有示例的文档。

我在 cua-*.el 中查找了对 CUA 属性的引用,果然,在 cua-base.el 中找到了一个:(我使用的是 Emacs 23.3.1)

    (defun cua--pre-command-handler-1 ()
;; Cancel prefix key timeout if user enters another key.
(when cua--prefix-override-timer
(if (timerp cua--prefix-override-timer)
(cancel-timer cua--prefix-override-timer))
(setq cua--prefix-override-timer nil))

(cond
;; Only symbol commands can have necessary properties
((not (symbolp this-command))
nil)

;; Handle delete-selection property on non-movement commands
((not (eq (get this-command 'CUA) 'move))

我认为您可以从这里弄清楚该属性(property)的用途。希望这可以帮助。

关于emacs - 了解 Emacs CUA 模式以进行 shift 单击选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11176853/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com