gpt4 book ai didi

emacs - 重新映射 org-shiftmetaright | org-shiftmetaleft 到 [shift-select-meta]left-word | [shift-select-meta]right-word]

转载 作者:行者123 更新时间:2023-12-02 06:18:49 25 4
gpt4 key购买 nike

有人可以帮我重新映射org-shiftmetaright | org-shiftmetaleft[shift-select-meta]left-word | [shift-select-meta]right-word] .目标是在 org-mode 中一举突出选择区域是一个完整的单词(右或左),而不是改变标题的级别。并且当我释放 shift 时不会突出显示,但仍然会向左或向右跳转整个单词。

我想 left-wordright-word可能有那个插入符号"^"在交互式命令或类似命令中,因此没有单独的左移字或右移字功能。

(defvar custom-keys-mode-map (make-keymap) "custom-keys-mode keymap.")

(define-minor-mode custom-keys-mode
"A minor mode so that my key settings override annoying major modes."
t " my-keys" 'custom-keys-mode-map)

(custom-keys-mode 1)

(defun my-minibuffer-setup-hook ()
(custom-keys-mode 0))

(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)

(defadvice load (after give-my-keybindings-priority)
"Try to ensure that my keybindings always have priority."
(if (not (eq (car (car minor-mode-map-alist)) 'custom-keys-mode))
(let ((mykeys (assq 'custom-keys-mode minor-mode-map-alist)))
(assq-delete-all 'custom-keys-mode minor-mode-map-alist)
(add-to-list 'minor-mode-map-alist mykeys))))

(ad-activate 'load)

;; (define-key custom-keys-mode-map (kbd "<C-key>") 'some-command)

(define-key custom-keys-mode-map (kbd "M-<left>") 'left-word)
(define-key custom-keys-mode-map (kbd "M-<right>") 'right-word)

(define-key custom-keys-mode-map (kbd "M-S-<left>") 'left-word)
(define-key custom-keys-mode-map (kbd "M-S-<right>") 'right-word)

编辑:这是我希望在 org-mode 中使用的 bindings.el 函数:
(defun right-word (&optional n)
"Move point N words to the right (to the left if N is negative).

Depending on the bidirectional context, this may move either forward
or backward in the buffer. This is in contrast with \\[forward-word]
and \\[backward-word], which see.

Value is normally t.
If an edge of the buffer or a field boundary is reached, point is left there
there and the function returns nil. Field boundaries are not noticed
if `inhibit-field-text-motion' is non-nil."
(interactive "^p")
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(forward-word n)
(backward-word n)))

(defun left-word (&optional n)
"Move point N words to the left (to the right if N is negative).

Depending on the bidirectional context, this may move either backward
or forward in the buffer. This is in contrast with \\[backward-word]
and \\[forward-word], which see.

Value is normally t.
If an edge of the buffer or a field boundary is reached, point is left there
there and the function returns nil. Field boundaries are not noticed
if `inhibit-field-text-motion' is non-nil."
(interactive "^p")
(if (eq (current-bidi-paragraph-direction) 'left-to-right)
(backward-word n)
(forward-word n)))

最佳答案

由于您只想回退到这些绑定(bind)的默认行为,我们可以简单地删除 org-mode 覆盖。

(eval-after-load "org"
'(progn
(define-key org-mode-map (kbd "<M-S-left>") nil)
(define-key org-mode-map (kbd "<M-S-right>") nil)
(define-key org-mode-map (kbd "<M-left>") nil)
(define-key org-mode-map (kbd "<M-right>") nil)))

关于emacs - 重新映射 org-shiftmetaright | org-shiftmetaleft 到 [shift-select-meta]left-word | [shift-select-meta]right-word],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17539007/

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