【问题标题】:Understanding Emacs CUA mode for shift click selection了解 Emacs CUA 模式的 shift 点击选择
【发布时间】:2012-06-25 23:19:18
【问题描述】:

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

;; 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 的定义:

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的定义:

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.

但他们都没有提供任何线索。我找不到任何名为 move 的变量或函数,并且我还查看了 mouse.el、cua-base.el、cua-gmrk.el 和 cua-rect 的源代码。埃尔。

谁能解释最后一行的工作原理,以及我如何自己找到更多信息?谢谢。

【问题讨论】:

    标签: emacs cua-mode


    【解决方案1】:

    我没有深入研究 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))
    

    我认为您可以从这里弄清楚该物业的用途。希望这会有所帮助。

    【讨论】:

    • 谢谢,我专门找鼠标命令,不知道有“this-command”符号
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-07
    • 2017-06-08
    • 2014-04-23
    • 2020-08-01
    • 1970-01-01
    • 2016-04-25
    • 2016-03-07
    相关资源
    最近更新 更多