- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想按两次“home”键将我带到缓冲区的开头。我无法正确使用语法。以下不起作用,我无法通过谷歌找到答案...
;; key chords
(require 'key-chord)
(key-chord-mode 1)
;(setq key-chord-two-keys-delay 0.2)
;(key-chord-define-global "(home)(home)" 'beginning-of-buffer)
;(key-chord-define-global "[(home)(home)]" 'beginning-of-buffer)
;(key-chord-define-global (home)(home) 'beginning-of-buffer)
;(key-chord-define-global [home][home] 'beginning-of-buffer)
更新:我已经切换到按键组合包,它可以处理多个按键,包括主页键。
最佳答案
听起来像key-chord
在这种情况下无济于事,因为 <home>
不在其支持的字符范围内。
我相信以下内容应该可以满足您的需求,并且可以轻松地将相同的模式用于其他不受支持的键1:
(defvar my-double-key-timeout 0.25
"The number of seconds to wait for a second key press.")
(defun my-home ()
"Move to the beginning of the current line on the first key stroke,
and to the beginning of the buffer if there is a second key stroke
within `my-double-key-timeout' seconds."
(interactive)
(let ((last-called (get this-command 'my-last-call-time)))
(if (and (eq last-command this-command)
last-called
(<= (time-to-seconds (time-since last-called))
my-double-key-timeout))
(beginning-of-buffer)
(move-beginning-of-line nil)))
(put this-command 'my-last-call-time (current-time)))
(global-set-key (kbd "<home>") 'my-home)
请注意 this-command
将评估为 my-home
当函数运行时,我们设置 my-last-call-time
my-home
上的属性(property)符号,从而巧妙地避免需要维护一个单独的变量来记住上次调用此函数的时间,这使得该函数很好地独立和可重用:要创建另一个类似的函数,您只需更改 (beginning-of-buffer)
和 (move-beginning-of-line nil)
.
1 明显的警告是,如果您触发双键行为,两个命令将连续执行,因此不要将此方法用于将要执行的命令成为一个问题。
(相反,优势是我们不会弄乱计时器。)
关于emacs - 如何使用 'home' 键创建 emacs 键和弦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25572489/
我使用Andrew的d3和弦图示例并希望将弯曲切片内的所有文本标签居中。我尝试了很多东西,但始终无法将文本居中。你知道需要什么巫师技巧吗? var width = 720, height = 720,
我正在尝试实现一个系统,在该系统中我可以同时播放一组频率,目前可以单独播放每个频率。下面我有一个代码,它播放给定的频率,一次播放一个。 import java.applet.*; im
是否可以一次重新映射使用 ctrl+k 作为第一个按键操作的所有和弦? 我使用 ctrl+k 删除该行的其余部分。由于它与 vscode 中使用的最常见和弦冲突,因此通过快捷方式重新映射快捷方式会很不
我是一名优秀的程序员,十分优秀!