【问题标题】:Turn rectangle mark mode off in org mode in emacs在 emacs 的 org 模式下关闭矩形标记模式
【发布时间】:2016-04-07 11:26:37
【问题描述】:

在 emacs 中使用 org 模式时如何禁用 cua 的矩形标记模式?两种模式都使用 Ctrl + Enter,我宁愿在 org 模式下失去 cua 的功能,因为在编辑 org 文档时我通常不需要选择矩形。

我很确定我曾经在我的 .emacs 中有一些执行此功能的代码,但我再也无法在网上的任何地方找到它。可悲的是,我还不足以成为一个 elisp 大师,无法自己弄清楚。

【问题讨论】:

  • 使用 C- 您还可以使用 M- 来表示 org-insert-heading-respect-content。结果 C- 用于 CUA 模式。 M- 用于组织模式。

标签: emacs org-mode cua-mode


【解决方案1】:

除了矩形我不使用 CUA,所以我使用了

(global-set-key (kbd "C-<return>") 'cua-rectangle-mark-mode)

Org 模式的绑定会自动覆盖全局绑定,因此 C-&lt;enter&gt; 无需额外配置即可运行 org-insert-heading-respect-content


不过,我假设您使用的是 cua-selection-modecua-mode。由于它是全局的,因此您不能仅在 org 缓冲区中将其关闭。可能最好的办法是定义自己的函数并将其绑定到cua-mode 的映射。

(defun jpk/C-<return> (&optional arg)
  (interactive "P")
  (if (eq major-mode 'org-mode)
      (org-insert-heading-respect-content arg)
    (cua-rectangle-mark-mode arg)))

(define-key cua-global-keymap (kbd "C-<return>") #'jpk/C-<return>)

与大多数次要模式相比,CUA 做的事情有点奇怪,所以虽然上面的方法对我有用,但如果你的设置与我的不同,可能会很不稳定。

【讨论】:

  • 谢谢,你的函数能满足我的需要。我对cua有一个模糊的记忆,有一个矩形标记模式的忽略列表,但我认为我将它与拖动东西混淆了,因为我看到了“(添加到列表'拖动物品除外模式'组织模式) " 在我的 .emacs 中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多