macos 如何让鼠标选择在 Mac 上的 emacs 和 iTerm2 中工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5710334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:57:50  来源:igfitidea点击:

How can I get mouse selection to work in emacs and iTerm2 on Mac?

macosemacsiterm

提问by Chris

after turning on xterm-mouse-mode, any click on the in the screen returns "mouse-1 is undefined". What should I be defining "mouse-1" as? Is there some reason my mouse clicks are returning this event, and not others its suspecting?

打开 xterm-mouse-mode 后,在屏幕上的任何点击都会返回“mouse-1 is undefined”。我应该将“mouse-1”定义为什么?我的鼠标点击是否有原因返回此事件,而不是其他原因?

采纳答案by DrStrngeluv

I put this in my .emacs:

我把它放在我的 .emacs 中:

(require 'mouse)
(xterm-mouse-mode t)
(defun track-mouse (e)) 
(setq mouse-sel-mode t)

and that seems to do the trick, and now a mouse click in a split changes focus to the split.

这似乎可以解决问题,现在在拆分中单击鼠标会将焦点更改为拆分。

Note: I am using iterm2, and I found the info here: http://groups.google.com/group/iterm2-discuss/browse_thread/thread/8e1f2ee7db26c07d/17ac15e69c554998?show_docid=17ac15e69c554998&pli=1

注意:我正在使用 iterm2,我在这里找到了信息:http://groups.google.com/group/iterm2-discuss/browse_thread/thread/8e1f2ee7db26c07d/17ac15e69c554998?show_docid=17ac15e69c554998&pli=1

回答by bfroehle

For Emacs in iTerm 2, I've found that the following bit in my ~/.emacsfile works very well, providing the ability to insert the character at an arbitrary location, mark a region, and use the scroll wheel:

对于 iTerm 2 中的 Emacs,我发现我的~/.emacs文件中的以下位运行良好,提供了在任意位置插入字符、标记区域和使用滚轮的能力:

;; Enable mouse support
(unless window-system
  (require 'mouse)
  (xterm-mouse-mode t)
  (global-set-key [mouse-4] (lambda ()
                              (interactive)
                              (scroll-down 1)))
  (global-set-key [mouse-5] (lambda ()
                              (interactive)
                              (scroll-up 1)))
  (defun track-mouse (e))
  (setq mouse-sel-mode t)
)

回答by hekevintran

Mac OS X's Terminal.app does not support mouse reporting. However MouseTerm is a SIMBL plugin that provides it with this feature. http://bitheap.org/mouseterm/

Mac OS X 的 Terminal.app 不支持鼠标报告。然而,MouseTerm 是一个 SIMBL 插件,为它提供了这个功能。http://biteap.org/mouseterm/

Install MouseTerm and put the following in your Emacs config file:

安装 MouseTerm 并将以下内容放入您的 Emacs 配置文件中:

; enable mouse reporting for terminal emulators
(unless window-system
  (xterm-mouse-mode 1)
  (global-set-key [mouse-4] (lambda ()
                              (interactive)
                              (scroll-down 1)))
  (global-set-key [mouse-5] (lambda ()
                              (interactive)
                              (scroll-up 1))))

回答by George

I suspect that installing the emacs-goodies-el will provide the appropriate bindings.

我怀疑安装 emacs-goodies-el 将提供适当的绑定。