Emacs Helm: what actions can I do in a helm buffer? - emacs

I have 2 questions:
In a helm buffer like helm mini or helm ag, there are usually too much candidates. In evil mode I can use C-d or C-u to scroll down or up. Can I do such things in helm buffer?
Sometimes when I enter a file path/name, there is only a default one in the buffer but not the one I entered. Whenever I hit enter the default path/file will be visit. What actions can I do in the input bar (where you input characters)?
Would you please provide the document describing these kind of keymaps? I can't find them because I don't what's my question :(

If you are using spacemacs, try M-x describe-keymap helm-map, it's bound to SPC h d K.
Sadly emacs itself doesn't have such a nice describe-keymap function. In this case you may either:
copy describe-keymap from spacemacs
use describe-bindings (it's not so smooth to read and misses some keymaps)
C-h v helm-map to browse the keymap as a variable (hard to read because the keys are in the form of something like unicode code points, but if you config all your key bindings yourself without framework-defaults, this is fine for "what's my bindings?" and debugging)

You can use describe-bindings or helm-descbinds to find the currently active bindings. The latter allows you to interactively search them through helm.

Related

describe binding filtering in emacs

Is there a way to filter the list of available bindings (C-h b), so it will not show all the possible bindings but just the relevant ones for the used mode?
For example on org-mode, I get all the general C-x list plus all the bindings of the modes that have general key bindings plus all the major mode bindings, followed by all the org mode ones, followed by global bindings... 1369 lines in total... I'm using this view for learning my way around, perhaps there is a way to filter so as to find my way around.
I think you are looking for C-h m which runs the command describe-mode.
You will find more goodies in C-h C-h which runs the command help-for-help.
C-h m shows the doc for the current major mode, as well as currently enabled minor modes.
Often C-h m lists some of the more important local key bindings, that is, some of the bindings made for the current major mode. But not always, and typically it does not list all of the local bindings.
If you use library help-fns+.el then you can use command describe-keymap to list all of the local key bindings:
M-: (describe-keymap (current-local-map))
If you know the name of the local keymap variable (e.g. emacs-lisp-mode) then you can invoke describe-keymap interactively using C-h M-k, providing the map name at the prompt.
If you use Icicles then you can see all of the currently available key bindings using S-TAB (key completion). By default, the local bindings (i.e, those for the current major mode) are shown first, and are highlighted specially. (You can use C-, to sort the candidate bindings in other ways (by key name, prefix keys first; by command name).
After C-h b switch into Help-buffer and call M-xoccurRETorgRET which will display all lines containing "org".

ajax-like command helper for EMACS?

I am new to Emacs. I find it is powerful and very convenient IF one can master its set of commands. I also believe anyone can do this with patience, and the eagerness to learn and USE the software. However it will be much nicer for beginners, and seasonal users to have some command helper plugin that do following thing:
When the user start typing any CONTROL or META, COMMAND, or any special keys, a "ajax-like" or "smart search" window appear below or in the minibuffer showing help text like, for example: If I hold "CONTROL", command helper windows shows:
C-p Up one line
C-n Down one line
C-f Forward one character
C-b Backward one character
C-a Beginning of line
C-e End of line
C-x ...
Then if I continue to type "x" while holding "CONTROL", the window will update and show something like:
C-x C-a add-mode-abbrev
C-x C-b list-buffers
C-x C-c save-buffers-kill-emacs
C-x C-d list-directory
C-x C-e eval-last-sexp
C-x C-f find-file
C-x C-h inverse-add-mode-abbrev
C-x TAB indent-rigidly
C-x C-l downcase-region
C-x C-n set-goal-column
C-x C-o delete-blank-lines
I have tried googling it, but it doesn't seem exist yet. So I guess this is more a feature request for EMACS rather then a question. But it is great if somebody can write a plugin/module to do this.
I do not believe this is out there, but I also believe that it is not really needed. It would just clutter the screen, though, maybe for a rookie it might be indeed useful.
For now, you might consider printing a cheatsheet.
Do not lose hope, I learned it without any sort of help, the key is indeed to just use it often.
Also, there is quite a good logic behind it all, so if you read up the structure in a cheatsheet or anywhere else, then it might help you "guess" what is the right key combo sooner than later.
EDIT: I actually myself asked a similar question, at least the same functionality was required. I accepted an answer which apparently mentions that Icicles offers this functionality.
Also, one advise is that after you type the prefix key, e.g. C-c, typing C-h afterwards will show you the possible completions.
This leads me to the following:
I believe we could use code like:
"If last key is a prefix key, run C-h*, switch back to previous buffer and rehit the last prefix key"
*this is a general method, working even for my own poorly designed minor mode
I also don't know an existing package that would do that, but here's a couple of tips.
To get an overview of all available bindings, press C-h b. The displayed buffer looks fairly raw, because it includes all ways used to enter special characters (and they are usually at the top), but you can search it with C-s if you remember at least a part of the command name.
If you know the prefix (e.g. C-x) but don't remember what comes next, you can follow it with C-h instead (type C-x C-h). That will bring up a similar buffer that only contains bindings that start with the same prefix. It's one of the more obscure features, I think.
Speaking of "if I hold Ctrl", though, showing hints when you've just pressed Ctrl and nothing else if currently impossible to implement at the Lisp level. That would require some lower-level changes.
There are too many keybindings in emacs for this to be practically useful.
I agree with the other responses and just wanted to add that I found the built-in tutorial very useful for getting past the basics. You can reach the tutorial with C-h t.
You'll probably end up changing several of the default bindings, but learning them will help you find your way around new modes (assuming that they work in an "emacsy" way).
I come back to this be cause I found a perfect solution and can't live without it: The emacs-helm and which-key

How to make speedbar list the C functions + Unable to use sr-speedbar+macro+command history

I am new to Emacs on Windows XP and have multiple queries which I could not find/understand after a lot of search.
I understand that speedbar will support showing of C functions list. As mentioned in http://stackoverflow.com/questions/259364/how-do-i-configure-emacs-speedbar-for-c-sharp-mode, I added the code in .emacs as
(speedbar 1)
(add-to-list 'speedbar-fetch-etags-parse-list
'("\\.c" . speedbar-parse-c-or-c++tag))
I see the speedbar startup but it never shows the functions. Maybe I need to install etags but cannot find it. I also found gtags but could never find a binary
I copied sr-speedbar.el in ~/emacs.d/ directory. I added (require 'sr-speedbar) in .emacs, commented out speedbar related code, reloaded M-x ~/.emacs but did not find any sr-speedbar. If I uncomment speedbar code and comment sr-speedbar, it shows the speedbar on loading. Emacs is able to find sr-speedbar.el in ~/emacs.d/ directory since if I change filename, it shows an error: unable to find sr-speedbar.
I wanted to make a keyboard macro for logging using tramp and ssh. However, when I record a macro, I have to delete multiple characters to provide the path from the beginnig i.e. emacs automatically shows the last path and so I have to delete all the characeters and then start again with ssh://. The keyboard macro records all backspaces and returns error if the backspaces are more than the length of the current path. Is there a way to avoid it
I configured linum package. I want it to start at the beginning of emacs session automatically with typing M-x linum. How can I do that?
Is there way to retrieve command history (not shell commands) and then replay some command
Thanks again for patience on reading until the point :-)
For C, C++, and other languages, supported by CEDET/Semantic, the Speedbar is able to show functions & other objects. But you need to setup Semantic correctly, for example, you can use my article in CEDET.
As I understand, to enable linum-mode globally, you need to put (global-linum-mode 1) into your ~/.emacs
For 3, there are two options:
just type "/ssh:blabla" at the end of the pre-inserted directory (this directory will be ignored as witnessed by it becoming grey).
do C-a C-k to erase the content of the minibuffer.
For 5, there is repeat-complex-command bound to C-x ESC ESC and there is repeat bound to C-x z.

How to work out which package is unsetting keybindings?

Something in my config is unsetting/overwriting some standard keybindings for C-c C-e so that commands in various major modes don't work properly. In AUCTeX C-c C-e should start the "insert environment" dialogue and in org-mode the same keys should start the export/publish dialogue, but in both of these modes C-c C-e is undefined and emacs just waits for more input.
I know I could start emacs with -Q and load packages until something breaks (and if I load emacs that way and open a file in org-mode, the keybindings work as they should) but, like lots of people, at some point my init file became monstrously big. Is there a quicker, smarter way?
[EDIT] Nothing in my config is unsetting C-c C-e explicitly.
The debugger might give you enough clues to sort it out. Try adding the following to the beginning of your .emacs:
(debug-on-entry 'global-unset-key)
You might need to try 'local-unset-key as well. For details see the debugger manual.
Binary search is your friend.
Go to the middle of your .emacs and add (error "here"), then launch Emacs and see if the problem persists.
If it does, then insert another error line half way between the current and the top of the file, if not, comment out the current error and add one half way between the current and the bottom.
Repeat the bisection process until you isolate the line or two which are responsible for causing the problem.
You could use C-h k C-c C-e to find out which function is bound to your combination.
In the popped up help buffer, you will get the function name, its documentation and a link to the file where it is defined. Follow that link and you will end up at the place of the function definition.
At this point, it should be simple to identify which package that is responsible for redefinition of your keybinding using the name of the file.
If this does not help, you could M-x rgrep in your customization directory for 'C-c C-e' or 'C-e' and manually check everything.

How can I more easily switch between buffers in Emacs?

I've recently started using emacs and I'm enjoying using it for the most part. The only thing I'm not enjoying, is switching between buffers. I often have a few buffers open and I've grown tired of using C-x b and C-x C-b, are there any packages that make switching between buffers easier? I've looked into emacs wiki on switching buffers and I'd appreciate insight/feedback on what are are using/enjoying. Thanks.
UPDATE: iswitchb-mode is obsolete in Emacs >= 24.4, replaced by ido.
All of the features of iswitchdb are now provided by ido. Ross provided a link to the documentation in his answer. You can activate with the following in your .emacs (or use the customization interface as Ross suggests):
(require 'ido)
(ido-mode 'buffers) ;; only use this line to turn off ido for file names!
(setq ido-ignore-buffers '("^ " "*Completions*" "*Shell Command Output*"
"*Messages*" "Async Shell Command"))
By default, ido provides completions for buffer names and file names. If you only want to replace the features of iswitchb, the second line turns off this feature for file names. ido will ignore any buffers that match the regexps listed in ido-ignore-buffers.
The behaviour described below for iswitchb-mode applies equally to ido for switching buffers.
iswitchb-mode (Emacs < 24.4)
iswitchb-mode replaces the default C-x b behaviour with a very intuitive buffer-switching-with-completion system. There are more sophisticated options, but I've never needed more than this.
After you hit C-x b, you are presented with a list of all buffers. Start typing the name of the buffer you want (or part of its name), and the list is narrowed until only one buffer matches. You don't need to complete the name, though, as soon as the buffer you want is highlighted hitting enter will move you to it. You can also use C-s and C-r to move through the list in order.
You can turn it on by default with this in your .emacs:
(iswitchb-mode 1)
You can also tell it to ignore certain buffers that you never (or very rarely) need to switch to:
(setq iswitchb-buffer-ignore '("^ " "*Completions*" "*Shell Command Output*"
"*Messages*" "Async Shell Command"))
You can use C-x <right> (next-buffer) and C-x <left> (previous-buffer) to cycle around in the buffer ring. You could bind S-<right> and S-<left> to these functions. (S is the "super-key" or windows-key). This way you can save some keystrokes.
Moreover, note that C-x b has a default entry, i.e. it displays a standard value (most of the time this is the previously viewed buffer), so that you don't always need to enter the buffer name explicitly.
Another nice trick is to open separate windows using C-x 2 and C-x 3. This displays several buffers simultaneously. Then you can bind C-<tab> to other-window and get something similar to tabbed browsing.
M-x customize-group ido then set Ido Mode to Turn on both buffer and file and set Ido Everywhere to on. Then click the Save for future sessions button at the top and enjoy ido magic for both files and buffers. Read the docs to get a sense of how to use ido.
Also, take a look at smex.
ido-mode provides an efficient way to switch buffers.
ibuffer is best for managing all opened buffers.
anything is good for selecting an interested thing from different
sources. (for eg: a single key can be used to switch to another
buffer or to open recently closed file or to open a file residing
in the same directory or ... anything you want ... )
If you've looked at the Emacs Wiki, you probably have all this information already, but here are a few other relevant Q&As:
Emacs: help me understand file/buffer management
Buffer switching in Emacs
How to invoke the buffer list in Emacs
My toolkit consists of ibuffer, windmove+framemove, winner-mode, and a custom binding to make C-xleft/right and C-cleft/right less of a hassle to use.
I have mapped the "ยง"-key to 'buffer-list and I find it to be very efficient.
I've started using anything for a couple of days and I'm really liking it: http://www.emacswiki.org/emacs/Anything .
Emacs-fu has an good intro to anything: http://emacs-fu.blogspot.com/2011/09/finding-just-about-anything.html
My favourite function for this is helm-mini which is part of helm.
As other helm functions, it allows incremental narrowing of the selection. It also searches your recently visited buffers, which is a really nice way to re-open a buffer. Helm can be a little surprising at first and as a new Emacs user, I found it visually overwhelming and I preferred ido or ibuffer which have been suggested in other replies. But now I absolutely love it and use it all the time for countless things.
Something that I realized by accident and that can be useful:
mouse-buffer-menu is by default bound to <C-mouse-1> (Control key + mouse left click) and opens a popup with a list of the current buffers.