can anyone point me in the right direction to globally define the activation of shift select with the left mouse button?
I want to be able to select between the cursor point and the selected area...
It is possible to drag-select only, and it is possible to shift-select via keyboard only.
This unfortunately doesn't work (in ~/.emacs):
(define-key global-map (kbd "<S-down-mouse-1>") 'shift-selection)
Machine: Win7, Emacs-Version: 25.1.1 (i686-w64-mingw32) of 2016-09-17
Thanks.
(define-key global-map (kbd "<S-down-mouse-1>") 'mouse-save-then-kill)
https://superuser.com/questions/521223/shift-click-to-extend-marked-region
Related
Up and down arrow keys work but I was wondering if there was another option on the home row. If not, how do I set it to something else? (emacs noob)
emacs-jedi uses auto-complete under the hood
These are also supported (besides the default arrows):
M-n Next item
M-p Previous item
If you wanted to change them you could do something like this:
(define-key ac-completing-map (kbd "C-c j") 'ac-next)
(define-key ac-completing-map (kbd "C-c k") 'ac-previous)
There are 2 windows open in the horizontally split Emacs frame. Now, using keyboard shortcut, i would like the input focus to shift to other window.
i think, select-window function does it programatically.
I think windmove would help you. There are function like windmove-left, windmove-right, etc., and you can bind the key strokes you like to use the functions. For example, I set them up like the following:
(global-set-key (kbd "M-s-<left>") 'windmove-left)
(global-set-key (kbd "M-s-<right>") 'windmove-right)
(global-set-key (kbd "M-s-<up>") 'windmove-up)
(global-set-key (kbd "M-s-<down>") 'windmove-down)
With these settings, you can move the cursor between windows with arrow keys. You can change key stroke as you like.
http://emacswiki.org/emacs/WindMove
If you're in one frame containing two windows, you can use C-x o, which is bound to other-window, to go between them.
I have multiple windows open in emacs via C-X 2. However, sometimes I want to move a window at the top, down one, so that the window below it moves up, and that window I want to move goes down one place. I'm not talking about moving within windows, but moving the actual window. Is this possible in emacs?
Try this:
(require 'buffer-move)
(global-set-key (kbd "<C-S-up>") 'buf-move-up)
(global-set-key (kbd "<C-S-down>") 'buf-move-down)
(global-set-key (kbd "<C-S-left>") 'buf-move-left)
(global-set-key (kbd "<C-S-right>") 'buf-move-right)
I want Emacs to work like this:
Let auto-complete auto-popup menu:
(setq ac-auto-show-menu 0.8)
(setq ac-delay 0.1)
Use C-n/p / M-n/p to select auto-complete popup menu candidates:
(define-key ac-menu-map (kbd "M-n") 'ac-next)
(define-key ac-menu-map (kbd "M-p") 'ac-previous)
When selecting a candiate
disable TAB / S-TAB in popup menu selection:
(define-key ac-menu-map (kbd "<tab>") nil)
(define-key ac-menu-map (kbd "<S-tab>") nil)
press Enter to select the candiate, without inserting newline:
;; ???
if the candidate is an abbrev, Enter should only select the candiate:
;; ???
... and pressing Space should cause Emacs to auto-expand the abbrev.
if the candidate is a dabbrev, pressing M-\ on candidate should trigger dabbrev-expand.
pressing TAB / C-i to expand the candidate for yasnippet:
(setq yas-trigger-key "TAB")
I set this, but the trigger does not expand when I press TAB.
pressing TAB to expand a snippet trigger while in a field:
(setq yas-triggers-in-field t)
pressing C-j to jump to next field:
(setq yas-next-field-key '("<tab>")) ;; or "C-j"
How can I expand a snippet within a snippet using yasnippet?
Some explanations
There are two TABs in Emacs:
(kbd "TAB") / (\t, [9])
(kbd "<tab>") / ([tab])
If modes like yasnippet and auto-complete want to bind to TAB, their trigger key must be the same as the original tab command. Since Emacs binds indent-for-tab-command to (kbd "TAB"), it's better to use that as the trigger key. yasnippet binds to it by default, and it is easy to set up auto-complete to trigger using TAB as well:
;; trigger using TAB and disable auto-start
(custom-set-variables
'(ac-trigger-key "TAB")
'(ac-auto-start nil)
'(ac-use-menu-map t))
But in some modes (ruby-mode, markdown-mode, org-mode, etc.), the command is bound to
(kbd "<tab>"). When the real tab key is typed, the function bound to (kbd "<tab>) has higher priority, so yasnippet and auto-complete are not invoked. This is easy to fix by moving the key binding:
(defun iy-tab-noconflict ()
(let ((command (key-binding [tab]))) ; remember command
(local-unset-key [tab]) ; unset from (kbd "<tab>")
(local-set-key (kbd "TAB") command))) ; re-bind to (kbd "TAB")
(add-hook 'ruby-mode-hook 'iy-ac-tab-noconflict)
(add-hook 'markdown-mode-hook 'iy-ac-tab-noconflict)
(add-hook 'org-mode-hook 'iy-ac-tab-noconflict)
My setup
I downloaded yasnippet, auto-complete via the el-get packager manager. I'm using Ubuntu 12.04 and Emacs 24.3.50.1.
Wrapping up
I know this problem is a little long, but it really makes it difficult for me to use auto-complete and yasnippet. If the basic key binding doesn't work smoothly, this slows down my workflow quite a bit. I think many people have similar problems because I found some similar questions on the internet (though none of them are exactly like mine).
As you can see above, some of the relevant settings I already know. (But if you think I made a mistake somewhere, please tell me.) There are also some things I still don't know how to set up (???). Maybe there isn't a way to make all of these settings work together? Let me know if that is the case, and otherwise please make sure none of these setting interfere with each other.
After I get the answer to this question, I hope to write an Emacs extension to initialize all of these settings automatically.
Thanks for your help!
I faced the problem you're describing a long time ago and resolved it like this:
bind auto-complete to TAB (also C-i which is the same)
and yasnippet to C-o.
Abbrevs are on C-o as well, but I don't use them a lot.
The advantages are:
No stateful behavior results in a much more relaxed and productive editing.
You no longer think "what will TAB do in this context?" before pressing,
you just press it.
You no longer check if you got the expected outcome, because there's only one.
You can use auto-complete while in the process of expanding yasnippet.
C-i and C-o are neighbors and very easy to press.
Yasnippets now expand reliably in any mode since no mode overrides C-o.
This may be not what you want right now but consider trying it:
you might like it after a while.
Bind RET or <return> to function ac-expand. This is for select candidate.
app on Mac OS X on a MacBook. Most applications on the computer allow me to scroll both vertically and horizontally with a two-finger drag on the trackpad. I would like to use this ability to position the cursor in emacs.
Adding the following lines to .emacs allows me to move the cursor vertically:
(global-set-key [wheel-up] 'previous-line)
(global-set-key [wheel-down] 'next-line)
I don't know of an equivalent setting for wheel-left or wheel-right. Can anyone help?
Put this in your .emacs-file:
;; Turn on horizontal scrolling with mouse wheel
(global-set-key (kbd "<mouse-6>") 'scroll-right)
(global-set-key (kbd "<mouse-7>") 'scroll-left)
When you first use it, emacs will ask you if you want to activate the restricted command scroll-left. That's just because some users find it confusing at first.
this slightly simpler version works for me:
(global-set-key [wheel-right] 'scroll-left)
(global-set-key [wheel-left] 'scroll-right)
or for osx reversed scroll directions:
(global-set-key [wheel-right] 'scroll-left)
(global-set-key [wheel-left] 'scroll-right)
(global-set-key (kbd "<mouse-7>")
(lambda () (interactive) (message "WHEEEEEL")))
That worked for me. Try C-h c and then scroll the mouse the way you intend to to see what event is triggered. It will tell you in the echo area.
In version 26.2 I can set these variables from the mouse customize group:
'(mouse-wheel-flip-direction t) ;; correct left-right scroll direction for OS X
'(mouse-wheel-tilt-scroll t) ;; enable left-right scroll from trackpad
In emacs 25.1 check out the *Messages* buffer when you swipe left and right on the trackpad. By the looks of it the key bindings are wheel-right and wheel-left with double and triple variants.
For example:
(global-set-key (kbd "<triple-wheel-right>")
(lambda () (interactive) (message "wheeling right")))
(global-set-key (kbd "<triple-wheel-left>")
(lambda () (interactive) (message "wheeling left")))
For me these values are not reversed in macOS