Using the emacs bindings in pycharm in OS X Lion - python

I am trying to use the emacs keybindings in Pycharm 1.5 in OS X 10.7. They all work except that ALT+B inserts a beta symbol rather than moving back a word. It's puzzling since ALT+F does correctly move forward a word.
Also, I was wondering if Pycharm has support for moving between matching parentheses or brackets, like Control-Meta-F in emacs. I didn't see an option for this in the Pycharm keybindings preference pane.
Thanks!

I found a solution on the JetBrains forum. The forum post includes a keymap as an attachment that globally disables the alt keys from generating symbols.
Quoting the forum,
"So, after some digging around, I figured that this option key maps to these relatively unused symbols that are take precedence in the operating system. Using http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=ukelele (Ukelele), I was able to generate an optimized Emacs keyboard layout. You should take this and put it in your /Library/Keyboard Layouts/ folder.
Reboot, and switch to use this keyboard layout on the Mac OSX toolbar and the option key will be free for hotkeying in PyCharm. I'll write up a blog post about this later.
Hope this helps."

esc-ctrl-b works for me, but alt-b doesn't. It's right there in the emacs keymap, so it's strange at first, but I think the problem is that alt-b is mapped to a character (∫ rather than ß in my case) so PyCharm doesn't see it as a key-modifier pair, just a single character.
Switching to a different international keyboard map will change which combinations work and which don't. I'd suggest sending a bug report to PyCharm as it's something they can fix, or alternatively you'll have to hack your keyboard mapping somehow.
To answer your other question, I don't think that there's a way to go to matching parenthesis, or at least I've never found one.

Related

How to copy text from IDLE?

Is there a way to copy text out of Python IDLE on a Mac? When I highlight text and copy then past into a text editor, I get the same text pasted. It is some of the first text I start with in IDLE. None of the other text will copy out.
From The Things I Hate About IDLE That I Wish Someone Would Fix (from 2011):
1.2) NEW FEATURE: Auto-Copy-On-Highlight
Once we get rid of being able to move the cursor off the last line, that opens a new opportunity to implement an automatic copy-on-highlight feature that many terminal and IRC client programs implement. Since this text is read-only, the only reason a person has for highlighting it is to copy it (they can’t delete it.) As soon as the user highlights text in the shell window, it is copied to the clipboard.
Looks like the best you can do is save as a .py file. Open that in a text editor and continue working in IDLE. With each save, the text editor will refresh with all updates, including errors. At least TextWrangler will.
Sometimes in things like a linux terminal you can't do a normal copy and paste, try holding Command/Control + Shift + C after highlighting things and seeing if that works, since you're on mac i'm not sure if it would be the Command or Control key so try both
EDIT: There is an apple discussion about the exact same thing. They discuss going into the options menu, then into configuration and navigating to the keys section. Then you use a built in key-set, their suggestion is using IDLE Classic Mac.
I cannot tell from your description exactly what you did and what happened. But I can recommend that you upgrade to 3.4.4 or 3.5.1 (or 2.7.11 for 2.7 users). Among other improvements, they all contain a patch to make right-click for context menu work on Mac Aqua. This was issue 24801 on the CPython bug tracker.
If there is still an actual problem on Mac, I would like to know so it can be fixed.

How to get the backslash symbol to show up?

I keep on getting a yen symbol whenever I press the backslash key. Is there a way to change this? I'm using python by the way.
I had this same problem, but i changed the font in Python IDLE away from the default Meiryo and it fixed it. In IDLE go to Options > Configure IDLE, then in the 'Fonts/Tabs' tab, change the font face to something like Arial. This worked for me.
I know it has been over a year since this question has been asked. I was in your position and kind of ignored the problem, but I finally reached a solution that fixes it. It has to do with certain programs (including cmd.exe) using UNICODE. I was working with java and this problem was heeding progress in what I was doing.
This solution works in Windows 10, the method most likely exists for older versions such as 7 or 8 or 8.1
1) Go to language settings in Control Panel
2) Go to the 'Change date, time, or number formats' link on the left.
3) Go to the administrative tab
4) In the section for 'Language for non-Unicode programs,' it was set to Japanese for me. Since I live in Canada, I appropriately selected English (Canada)
5) Reboot your computer
6) To test this: open cmd.exe and look at the directory present. It should no longer be yen symbols, now backslashes.

Aquamacs (on Mac lion): whatever I write i being interpreted as "Enter"

I am editing a python script that I wrote a while ago, using aquamacs on Mac lion.
Whichever letter or number I type is being interpreted as "enter" (that is, I hit "g" for example, my text is dissrupted and a newline appears, but "g" does not appear). Restarting aquamacs, the terminal out of which I run it, or the whole computer did not help.
Other observations (that might or might not be connected):
- The script is located in a folder under Dropbox
- The file has special attributes (that is an "#" appears at the end of the permissions, upon typing ls -lah)
- I might have hit a combination of Control, Apple and other keys that I should not have ....
Any solution to this would be very much appreciated (and my apologies, if that has been treated before).
Thanks!
I also met with this problem recently.
You need to add minor mode Fill. Press on the Python in the mode line in mouse-3 way and choose Auto Fill.

keyboard short cut for accessing previous statements in python IDLE using a Mac

Is there a keyboard short cut for accessing previous statements in python IDLE? I am using a Mac
Thanks
On Windows this hotkey is alt-p.
However, assuming IDLE has options in Mac ;) you should be able to find out by going to Options->Configure IDLE. Then look in the Keys tab and under Custom Key Bindings, look for "history-previous".
That should tell you what you need to know.
Using IDLE on the MAC you would need Ctrl+P (not command) for Previous statement (instruction) and Ctrl+N for Next statement.
I was struggling with this same question as I am always using the Up arrow on most of the "shell" style programs.
Also, you can scroll back up to any previous line and hit 'return', which will place that statement in the current working line.

Windows Balloon-tooltips in Python

Following the example at http://article.gmane.org/gmane.comp.python.general/541418, I've succeeded in creating a callable class for balloon tooltips, but the greater complexities of that code elude me when it comes to customization. I browsed a bit of how it works through msdn, but being a novice at more windows-esque languagues like c and vb, etc. I was unable to make much sense of it.
So I ask ye snakely academics:
Things I'd like to be able to do with that code aside from the standard icon, title, text:
Perform actions based on clicking the tooltip
Modify the tooltip that pops up over the icon in the system tray after loading it (to reflect changing values)
Multiple lines? (Not sure if this can even be done, really)
More information on other things you could do in a windows 7 environment versus XP (which seems to be what this was written for).
Ideally I'd get some sort of return value or some semblance of an event when the tooltip is clicked so that I could run some code, but currently I'm importing that code as a module and calling at various times, so I'm not sure how to handle clicks outside of the popup code itself...
Information on handling these things with python seems quite scarce. Thanks in advance.
Perform actions based on clicking the tooltip
Whats the problem OnTaskbarNotify? Hock yourself in there.
Modify the tooltip that pops up over the icon in the system tray after loading it (to reflect changing values)
Probably not, I am not sure about the WinAPI here. I haven't seen it in the wild, so...
Multiple lines? (Not sure if this can even be done, really)
With most WinAPI, just insert a \n in the string.
More information on other things you could do in a windows 7 environment versus XP (which seems to be what this was written for).
LOTS... But that is a bit vague... It depends what your needs are. But for kol feturez you need to google on your own...
On Linux and Unix systems I use the notify-send OS already implemented system.
import os
os.system('notify-send "'+title+'" "'+message+'")
Maybe in Windows there is some API32 for this.
Check this https://gist.github.com/wontoncc/1808234

Categories