Emacs list function definitions popup like Sublime CMD + R - python

In Sublime Text (Mac OS X), you can do CMD + R shortcut to list function definitions in a popup. When you type function names, it does fuzzy matching to show matches. Press enter and go to the definition. I find it very handy.
In Emacs, is there something like that?
I'm using elpy for writing Python and I found elpy-occur-definitions (C-c C-o) which can show function definitions in a different buffer. Close. But not exactly what I want.
Thanks!

Thanks to #jenesaisquoi's comment, I found helm-imenu-anywhere
which does exactly what I want.
I override this key-binding M-r (since I don't use the navigation function that often) which is also very close to Cmd-R.
(global-set-key (kbd "M-r") 'helm-imenu-anywhere)
UPDATE:
If you are on Mac OS X and want to use the same CMD + R to do this, you ca bind the key to s-r instead:
(global-set-key (kbd "s-r") 'helm-imenu-anywhere)
UPDATE 2:
I found that, to list functions in current buffer (versus out of all files), the best trick is helm-semantic-or-imenu. So my ultimate setup is
(global-set-key (kbd "s-r") 'helm-semantic-or-imenu)
(global-set-key (kbd "s-o") 'helm-imenu-anywhere)

Related

windows does not properly handle * (asterisk) argument when passed to python script

I have a python script handling conversion of FIX (xml/json type) data.
However under windows the argument * does not work to select all files for processing.
However it does work under bash windows.
Any way to circumvent/address this behavior?
As it seems windows cannot handle wildcards on it's own for file expansion. The individual binaries like copy, move etc handle on their own.
The solution here is to add a loop to pass on each filename to the script:
FOR %%i IN (*.log) DO convert_FIX.py %%i

emacs ipython autoclear buffer after executing

I'm fairly new to Emacs and finally figured out how to set up python environment. I'm using elpy and iPython as python shell interpreter. My question is as follows:
After I press C-c C-c, the buffer on the right shows the executed result. The red box is the code being executed and the blue box is the executed result returned from python. My questions are:
Is there a way only showing the result?
And every time after the script being executed, how to set the buffer on the right only showing the current result, ie, clear previous executed results? Thanks.
Is there a way only showing the result?
elpy already has a custom variable for this:
(setq elpy-shell-echo-input nil)
And every time after the script being executed, how to set the buffer
on the right only showing the current result, ie, clear previous
executed results? Thanks.
elpy doesn't have this functionality. But you can create a wrapper function and bind it to the same keys:
(define-key elpy-mode-map (kbd "C-c C-c")
(lambda (p)
(interactive "P")
(ignore-errors
(with-current-buffer (process-buffer (python-shell-get-process-or-error))
(let ((comint-buffer-maximum-size 0))
(comint-clear-buffer))))
(elpy-shell-send-region-or-buffer p)))

How do you look up python builtin documentation with intellij/pycharm?

Say I have a file open and I know the type of a variable is a dict, but the editor doesn't know that. Is there a way I can navigate to dict documentation?
I tried search everywhere, but that doesn't seem to work.
Thanks!
If you haven't changed your default keymap you can place your cursor on the variable from which you want its documentation and hit Ctrl + q which opens a popup with the available documentation!
If Ctrl + q does not work for you, open File > Settings > Keymap and in the search bar search for "Quick Documentation" and use the listed hot-key mentioned there for that action!

Store `local-set-key` in the configuration of emacs

For example, I use the command local-set-key to set the key C-c C-n for flymake-goto-next-error in python-mode.
Instead of writing an expression and wrapping it into python-mode-hook, is there a convenient way to store this keybinding directly? Does anyone have ideas about this?
Command
(local-set-key (kbd "C-c C-n") 'flymake-goto-next-error)
works in the current buffer's local map. It is correct when local map is python-mode-map.
Convenient minimum lenght command (without using hook)
(define-key python-mode-map (kbd "C-c C-n") 'flymake-goto-next-error)
works when variable python-mode-map has been created.
Variable python-mode-map is created dynamically (in file python-mode.el) after call
(require 'python-mode)
If python-mode hasn't been loaded, command define-key can't directly use python-mode-map. Using hooks is for safety. Your emacs config should be reliable (it shouldn't depend on command's execution order if possible), and such wrapped (with hooks) commands prevent wrong situation: setting keybind in mode-map without setup mode.

How can I insert a console in to a pyGame Window?

I'm making a text adventure, and I want to have pyGame animations and illustrations and a HUD!
How can I insert this console?
Thanks!
I'm pretty sure that's impossible. If you want a console within a Pygame screen then you'll have to write your own, or find one written by someone else (e.g. http://pygame.org/project-pygame-console-287-.html)
For your game, you can use subsurface, for the different screen 'sections'.
Using python 3x will have issues with multiple libraries, that are not precompiled for you. If you can, it will simplify things to Use 2.7 or 2.6. (There is a python2.7 binary, but not on the front page)
A console isn't too hard. You need to break down the components, deciding what you need.
Start with a miniproject, implementing features one at a time.
keyboard input, print letters to console
render text from a string
blit cached text. will have demo code later, if you are interested
dict() of strings, for commands, with values of function names.
draw the last 10 lines of text
up = scroll through command history
allow command aliases, like "n" and "north" will point to move_north
Implement this using a class: Command() . Which stores a list of all aliases.
commands = { "n" : move_north, "s" : move_south, "fps" : toggle_fps, "help" : print_help }
On enter, call the dict's value, if key exists:
if cmd in commands:
commands[cmd]()
# same as commands["n"]()
You could even have the console's print_help() use the function docstrings.

Categories