I like the option to do C-s C-w and then show all in a separate buffer by using M-s o, but I would really like to keybind the M-s o ('occur) such that I can type C-s C-w C-, or similar-
I have tried the normal keybind:
(global-set-key (kbd "C-,") 'occur)
But it just do the normal occur, not the search buffer occur.
The command that is bound to M-s o during an isearch isn't the default occur command, but a special version called isearch-occur, that automatically invoke occur on isearch hits.
You can bind this to the C-o (or C-, if you prefer) shortcut without overriding other commands using the define-key command with the isearch-mode-map:
(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
In this way you can use the sequence C-sC-wC-o.
Related
I have added the following code in my .emacs file:
(global-set-key (kbd "C-i") 'previous-line)
(global-set-key (kbd "C-k") 'next-line)
After that I start Emacs and push C-x C-b to open *Buffer List* buffer. Then I push C-x o to make it active.
After these actions I try my new keybindings and they work strangely! C-i prints No buttons! at the bottom of the frame. C-k moves the point to the next line but prints D at the previous one.
Any suggestions?
If you ask emacs to tell you what the keys are bound to, using C-h c C-k RET and C-h c C-i RET in your Buffer List buffer, you will be told that
C-k runs the command Buffer-menu-delete
TAB runs the command forward-button
Just because you bound those keys to other functions in the global key map does not mean that those bindings are active in any particular buffer, because there may be other keymaps in force that take precedence over the global map.
This is a large subject and you must proceed with caution (in particular, note that C-k is somewhat destructive: it marks the buffer for deletion - but it is conceivable that in a different buffer with a different mode, the map in force might make it much more destructive).
You can read about keymaps in the emacs manual.
I simply want to clear the repl buffer so that a single prompt eg (user>) is left on the first line.
I have a keybinding:
(put 'erase-buffer 'disabled nil)
(global-set-key (kbd "C-x C-<backspace>") 'erase-buffer)
But this gives the message :
text is read only
There is the option C-c C-o but this only clears the last return value.
When using python, and run-python the following command C-x M-o which i believe is comint-clear-buffer
cider-repl.el provides a function cider-repl-clear-buffer which by default is bound to:
M-x c-r--bu RET
as C-c M-b is not used by cider-repl as far as I am aware:
(add-hook 'cider-repl-mode-hook
'(lambda () (define-key cider-repl-mode-map (kbd "C-c M-b")
'cider-repl-clear-buffer)))
cider-repl.el also provides cider-repl-handle-shortcut which is bound to ,.
Which will prompt you to many commands, such as clear (which you want), ns (to change namespace), refresh, reload and many others
I find pressing , followd by enter (to choose clear, faster/more convenient than the other answer.)
Note: you need to type , into the repl while the line is empty, it works for both evil and normal emacs keybinds
I want to bind the 'C-c C-c' to a custom command, don't know how to.
I tried (global-set-key (kbd "C-c C-c") 'suspend-emacs), but it seams not work.
Any idea will be appreciated.
Thanks.
It is very likely that the local binding of C-c C-c in the current buffer is shadowing the global binding that you make with global-set-key. Conventionally, key sequences consisting of C-c followed by a control character are reserved for major modes. For instance, CC Mode gives C-c C-c a local binding as comment-region. Key sequences consisting of C-c and a letter (either upper or lower case) are set aside for users:
(global-set-key (kbd "C-c c") 'suspend-emacs)
And you may not want to bind suspend-emacs to a new key sequece. suspend-frame, which is bound to C-z and C-x C-z by default, calls suspend-emacs for us when it is invoked from the (controlling) tty device.
You know how when you hit the up arrow in bash it will fill in the last command you typed in? Is there any way to do this in nrepl?
So far I've been doing a reverse search (C-r), typing the first few characters of the line in question, killing the line(s) (C-k), jumping to the end of the buffer (M->) and yanking the killed line (C-y). Is there an easier way to do this?
You can use M-p and M-n to navigate up and down in the input history. Also, the current input can be used as a search pattern, i.e. type the start of the command you want to match, then M-p will take you to the next match. This uses the functions nrepl-previous-input and nrepl-next-input. If you don't like those keybindings, you can also rebind to <up> and <down>:
(define-key nrepl-mode-map (kbd "<up>") 'nrepl-previous-input)
(define-key nrepl-mode-map (kbd "<down>") 'nrepl-next-input)
Just add this to your .emacs (and evaluate C-x C-e after each line if you don't want to restart your Emacs). Also, note that M-n and M-p are likely to be bound to similar functionality in other REPL and comint like modes.
If you're using Cider, you can add the following to your user config:
(define-key cider-repl-mode-map (kbd "<up>") 'cider-repl-previous-input)
(define-key cider-repl-mode-map (kbd "<down>") 'cider-repl-next-input)
To persist the history for the next time you open a repl, you also have the following options:
(setq cider-repl-wrap-history t)
(setq cider-repl-history-size 1000)
(setq cider-repl-history-file "~/.cider-repl-history")
cider-repl-history-file is required if you want a persistent history. If you use a relative path, the history will be local to the current project.
In GNU Emacs with AUCTeX enabled, C-C C-C is the default shortcut for running latex over the active buffer. How can I change this to also run dvips after the dvi output is generated by latex? Can I define a new shortcut, say C-C C-D, and assign it to the foregoing operation?
M-x describe-key <RET> C-c C-c
C-h k C-c C-c
will each give you the function name that is called for compile. Then you can rebind as follows in your .emacs:
(global-set-key (kbd "C-c C-d") '<function name>)
This isn't fully general, as I'm not fully familiar with the innards of AUCTeX. Typically there is some type of mode hook to run (keeps you from rebinding a global).
Here's an example adapted from http://emacswiki.org/emacs/AUCTeX
(add-hook 'LaTeX-mode-hook
'(lambda ()
(local-set-key "<key>" '<function name>)))
As to your question about running dvips, you would define your own function and do a keybinding. in a similar manner as above.