2

我正在尝试设置一些键绑定以使用Shift键突出显示文本。我可以使用pc-selection-mode,但这并不能提供我想要的所有键绑定。例如,我希望能够通过按Shift-Ctrl-down我可以在大多数 MS 文本编辑器中执行的操作来对整个段落进行移位标记,但pc-selection-mode不允许您这样做。

我发现这个网站有一个shift_mark.el文件,我可以用它来设置我想要的所有键绑定。我已经放入我的.xemacs/init.el文件来加载shift_mark.el

这是错误:

Warning (initialization): An error occurred while loading `/home/theory/phrkaj/\
.xemacs/init.el':

Wrong type argument: arrayp, (shift right)

所以我运行 Emacs--debug-init来尝试找出问题所在。这是调试器想出的:

Debugger entered--Lisp error: (wrong-type-argument arrayp (shift right))
  signal(wrong-type-argument (arrayp (shift right)))
  global-set-key((shift right) shift-mark-forward-char)
  eval-buffer(#<buffer  *load*<3>> nil "/home/theory/phrkaj/shift_mark.el" nil t)  ; Reading at buffer position 1476
  load-with-code-conversion("/home/theory/phrkaj/shift_mark.el" "/home/theory/phrkaj/shift_mark.el" nil nil)
  load("~/shift_mark.el")
  eval-buffer(#<buffer  *load*<2>> nil "/home/theory/phrkaj/.xemacs/init.el" nil t)  ; Reading at buffer position 25
  load-with-code-conversion("/home/theory/phrkaj/.xemacs/init.el" "/home/theory/phrkaj/.xemacs/init.el" nil nil)
  load("/home/theory/phrkaj/.xemacs/init.el" nil nil t)
  load-file("/home/theory/phrkaj/.xemacs/init.el")
  eval-buffer(#<buffer  *load*> nil "/home/theory/phrkaj/.emacs" nil t)  ; Reading at buffer position 253
  load-with-code-conversion("/home/theory/phrkaj/.emacs" "/home/theory/phrkaj/.emacs" t t)
  load("~/.emacs" t t)
  #[nil "^H\205\264^@   \306=\203^Q^@\307^H\310Q\2027^@ \311=\2033^@\312\307\313\314#\203#^@\315\2027^@\312\307\313\316#\203/^@\317\2027^@\315\2027^@\307^H\320Q^Z\321^S\322\n\321\211#\210^K\321=\203_^@\323\324\325\307^H\326Q!\"^\\322\f\$
  command-line()
  normal-top-level()

这是文件的一部分,shift_mark.el它定义了向前突出显示一个字符:

(defun shift-mark-forward-char ()
  (interactive)
  (shift-mark 'forward-char))

(global-set-key '(shift right) 'shift-mark-forward-char)

任何帮助表示赞赏。

4

2 回答 2

3

在 GNU Emacs 下,键绑定应该看起来像

(global-set-key [(shift right)] 'shift-mark-forward-char)

[…]构造一个文字数组)。但我怀疑你的做法是错误的。您是在运行 GNU Emacs、XEmacs,还是两者兼而有之?什么版本?除非你运行的是非常旧的版本,pc-selection-mode否则应该在 GNU Emacs 下做你想做的事,并且在 XEmacs 下不需要任何设置。如果你同时运行 GNU Emacs 和 XEmacs,你可以在你的.emacs:

(defvar running-xemacs (string-match "XEmacs" emacs-version))
(if (not running-xemacs)
    (pc-selection-mode 1))
于 2010-11-12T15:31:49.130 回答
1

C-hv shift-select-mode RET

shift-select-mode 是在“simple.el”中定义的变量。它的值为 nil

文档:当非零时,移动的运动键会瞬间激活标记。

以这种方式激活标记时,任何平移平移的点运动键都会扩展该区域,如果瞬态标记模式关闭,则会暂时打开。此外,标记将被任何未移位转换的后续点运动键或任何通常在瞬态标记模式下停用标记的动作停用。

有关 shift-translation 的含义,请参见“this-command-keys-shift-translated”。

您可以自定义此变量。

这个变量是在 GNU Emacs 23.1 中引入的:

** 临时活跃区域

*新的变量 shift-select-mode,默认为非 nil,控制 shift-selection。当 Shift Select 模式打开时,shift 转换的运动键(例如 S-left 和 S-down)激活并扩展一个临时区域,类似于鼠标选择。

*使用 shift-selection 或 mouse-selection 创建的临时活动区域不一定在下一个命令中停用。它们仅在未进行移位转换的点运动命令之后或在通常会在瞬态标记模式下停用标记的命令(例如,修改缓冲区的任何命令)之后停用。

于 2011-03-14T23:13:07.780 回答