emacs evil mode binding mouse event - emacs

I've made these bindings.
(define-key prog-mode-map [double-down-mouse-1] 'evil-jump-to-tag)
(define-key evil-motion-state-map [down-mouse-1] nil)
(define-key prog-mode-map [mouse-8] 'xref-pop-marker-stack)
It works but there's a little problem.
If the postion to go is different with the current, then evil/emacs goes into visual mode. I've tried to figure out but I couldn't.
Fortunately, I've figured out what's happenning once double-clicking thru command-log-mode. Here those are.
<down-mouse-1>
evil-mouse-drag-region
<mouse-1> mouse-set-point
<double-down-mouse-1>
evil-jump-to-tag
I think those preceding 2 and are causing the weird visual selection and wrong cursor postion.
Please let me know if you know how to disable those 2 only once I'd like to jump to the definition by double-clicking.
Thanks. in advance.

This has helped me resolve this issue. Put in your .emacs file the following:
(with-eval-after-load 'evil-maps (define-key evil-motion-state-map [down-mouse-1] nil))
It is not entirely clear what is causing the behaviour. Please see this issue which I have reported to the evil-mode developers, where Vasilij Schneidermann (#wasamasa) has kindly suggested the above workaround.
Unfortunately, it does not seem they are likely to solve it. I hope the workaround helps you.
I have also reported it on the Emacs bug mailing list.

Related

How to make ENTER do go to the selected type or method when using Ensime global search with Emacs --no-window?

I'm using Ensime 2.10.0-0.9.8.9 with emacs 23.4.1, and I'm using emacs with --no-window parameter in the gnome terminal (v3.6.1). When I try to search for a scala type or method in my project with global search command C-c C-v v and then press ENTER to go to the selected item, it does not, but just enters a new line in the ensime-search buffer.
The thing is, when I try to do the same thing in normal emacs (without --no-window), all is fine...
Does someone know how to make it work with --no-window too ?
PS: please, don't answer: "just use emacs without --no-window"... :)
Ok, for partially fixing this I guess you can rebind the RET key just in scala-mode (or ensime). For that use:
(add-hook 'scala-mode-hook
(lambda () (local-set-key (kbd "RET") 'newline)))
Anyway, I say partially because I am not sure of what scala-newline does, so maybe there is some functionality that you may lose. You can try and see if that's ok for you.
Hope it helps :)
I finally found out how to solve this problem. I added the following binding in *ensime_2.10.0-0.9.8.9/elisp/ensime-search.el* :
(define-key map (kbd "RET") 'ensime-search-choose-current-result)
in the definition of function ensime-search-mode-map.
PS: as mentionned by Iqbal Ansari, it is better to add the binding in the init file :
(define-key ensime-search-mode-map (kbd "RET") 'ensime-search-choose-current-result)

shift up-arrow doesn't highlight text emacs iterm2

I recently had help fixing M-left and so forth here: emacs in terminal meta arrow keybindings, but am unable to fix Shift-up using a similar solution. When I try shift-up I get an error <select> is undefined. I've tried re-mapping it using:
(add-hook 'term-setup-hook
'(lambda ()
(define-key function-key-map "\e[1;9A" [M-up])
(define-key function-key-map "\e[1;9B" [M-down])
(define-key function-key-map "\e[1;9C" [M-right])
(define-key function-key-map "\e[1;2A" [S-up])
(define-key function-key-map "\e[1;9D" [M-left])))
But shift remains undefined. I also tried rebinding the key by setting it using the escape sequence returned from cat which is ^[[1;2A. Oddly enough shift down does work. shift-select-mode is marked at t as well.
This sounds like a trouble I had accessing a Ubuntu 12.04 machine via Putty, when END caused Emacs 23.3.1 to say <select> is undefined. That turned out to be an issue with the terminfo that lets programs use terminals in a device independent way.
Based on this 2008 bug report discussion, I solved my problem by adding the following to the top of my ~/.bashrc:
#so the END key will work correctly in Emacs over PuTTY
TERM=xterm-vt220
N.B., with either xterm-vt220 or the default xterm, emacs -Q -nw is getting ESC [ 4 ~ when I press END, ESC O A for Up, and ESC [ A for Shift-Up. (To see what keycodes Emacs is getting, press some buttons and then C-h,l.) For the same keys in the same order, cat says [4~, [A, and [OA...so Up and Shift-Up are oddly reversed.
If you don't want to change your terminfo, see this discussion for a workaround
http://lists.gnu.org/archive/html/help-gnu-emacs/2011-05/msg00211.html
You should be able to work around the issue with something like:
(define-key input-decode-map "\e[1;2A" [S-up])
And for this to take effect at the right time, you will have to use in your .emacs something like:
(if (equal "xterm" (tty-type))
(define-key input-decode-map "\e[1;2A" [S-up]))
Just to add more information about the solution:
https://github.com/arthurnn/dotfiles/blob/8d56f2419da9a4cb654d8941f379d6d5783bdb90/.emacs.d/init.d/setup-bindings.el#L3-L10 this should fix all the cases including emacsclient.
The last line is responsible for fixing the Shift-up when using emacsclient.

Emacs auto-complete

since I can't get CEDET to work for automatic code-completion (aka intelli-sense in the MS-world), after trying several times (no, it's just not working!), I've decided to use auto-complete, which works "quite fine" for me.
Unfortunately, auto-complete has an annoying behaviour when it comes to quit the imenu with its suggestions.
auto-complete starts imenu, no matter how many suggestions it has. So, if there's only one suggestion, the menu appears.
1.
To exit the imenu, I have to use the LEFT or RIGHT keys in order to make the menu disappear. ESC-ESC-ESC does not have any effect.
Is there any way, to modify these two behaviors?
Here's an excerpt of my .emacs file showing the auto-complete relevant stuff:
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)
(setq ac-delay 0.5) ;; eclipse uses 500ms
Kind regards,
mefiX
'Stop autocompleting' can be set by adding the following to your .emacs:
(define-key ac-completing-map "\ESC/" 'ac-stop)
...or alternatively you can use C-g as the default Emacs StopSomething command :)
As for showing the completion in a menu when there's only one candidate, I'm not really sure what other behaviour you'd want?

How configure delete-selection-mode to only delete?

I am using GNU Emacs 22.3.1 on Windows.
In my Emacs I have enabled delete-selection-mode, and it's very useful to select a region and delete or replace it. But I have a drawback.
When I write or press DEL over the selection, Emacs does not only remove the text, but it kills (a.k.a. send to the clipboard*). This is very annoying for me, because I don't have control of my kill-ring (a.k.a. clipboard) and may cause unexpected effects.
There is a way that delete-selection-mode does not kill the text, just delete it? Perhaps modify the source code?
(*: I have synchronized the kill-ring and the Windows clipboard, so for me (for practical purposes) it's the same)
Edit[Jun 24, 2009]
Thanks, danielpoe. Even with the idea of Trey Jackson the selection is still killing. And I found the reason.
I discovered that the problem was not in delete-selection-mode. The problem is, when I selected the region, I did it with the mouse. And never have imagined that it was the mouse who was copying the text. Using the set-mark command and the arrow keys the text finally aren't killed, only deleted.
I disabled this behavior writing this in my .emacs:
(require 'delsel)
(setq mouse-drag-copy-region nil)
(global-unset-key (kbd "<mouse-2>"))
(global-unset-key (kbd "<mouse-3>"))
Thanks for the advice. If this method of disable this mouse behavior can cause conflicts with other options, please comment.
Have you tried starting emacs with -Q. If I do so and only enable M-x: delete-selection-mode, I can't reproduce what you describe. Nothing is killed only deleted?! Can you check?
It looks as though you just need to modify a small part of the source, namely make this change:
(defun delete-active-region (&optional killp)
(delete-region (point) (mark))
t)
The original code looked at the argument killp and used that to decide whether to add the region to the kill-ring, and you said you don't ever want that. This change forces the region to always be deleted.
Now, you don't need to actually modify the source, just place that function definition after the (require 'delsel) in your .emacs (or after the (delete-selection-mode)).

Disable Carbon Emacs scroll beep

I've been looking into adopting Carbon Emacs for use on my Mac, and the only stumbling block I've run into is the annoying scroll beep when you try to scroll past the end of the document. I've looked online but I can't seem to find what I should add to my .emacs that will stop it from beeping when scrolling. I don't want to silence it completely, just when scrolling. Any ideas?
(setq visible-bell t)
This makes emacs flash instead of beep.
Using the hints from the Emacs wiki AlarmBell page, this does it for me:
(defun my-bell-function ()
(unless (memq this-command
'(isearch-abort abort-recursive-edit exit-minibuffer
keyboard-quit mwheel-scroll down up next-line previous-line
backward-char forward-char))
(ding)))
(setq ring-bell-function 'my-bell-function)
If you don't know the name of a command, press C-h k then the key/action you would like to get the name of.
You will have to customize the ring-bell-function.
This page may provide hints:
http://www.emacswiki.org/emacs/AlarmBell
Between Stephen Hassard's answer and Kipton Barros' comment:
(setq ring-bell-function 'ignore)
seems to be the most concise, works on emacs 24.x, and answers the original question.
This seems to do the trick:
(setq ring-bell-function nil)