Emacs 24.2 CUA-mode behaviour on Shift-up/down - emacs

I've set (cua-mode t) in my ~/.emacs in GNU Emacs 24.2 on Windows XP. However, when (with nothing selected) I type shift-up or shift-down no new selection is started, which is not the CUA behaviour as seen in MS Notepad, Eclipse etc. If I type shift-left/right then shift-up/down then indeed a new selection is created and extended as I continue to type shift-up/down.
Now, in Emacs 23.1 the initialisation sequence:
(pc-selection-mode)
(load "cua-mode")
(CUA-mode t)
did exhibit the expected behaviour, but all that is now obsolete AFAICS. So, any ideas on how to get the initial shift-selection working as in other Windows apps?

Related

How to configure emacs to work with ipython

I'm using ubuntu 14.04, emacs 24.3.1, python 2.7.6, ipython 1.2.1, python-mode 6.1.3. Ipython has been working well within emacs for at least a year, however, I have the following problem since two weeks ago.
use C-c! to start default interpreter, ipython shows as I hoped, but instead of split frame and show in another window, it appears in the original code window. (this is a minor problem)
use C-c| to execute a region, python interpreter starts, and the code sends to the python interpreter instead of ipython interpreter
I searched on SO, but this problem seems too recent to have an answer. I googled, found this page https://answers.launchpad.net/python-mode/+question/250905, tried methods therein, still didn't work... Could anyone help me fix the problem? Many thanks!
My .emacs python part looks like
(require 'python-mode)
(setq-default py-shell-name "ipython")
(setq-default py-which-bufname "IPython")
; switch to the interpreter after executing code
(setq py-shell-switch-buffers-on-execute-p t)
(setq py-switch-buffers-on-execute-p t)
; don't split windows
(setq py-split-windows-on-execute-p nil)
In order to split the window
(setq py-split-windows-on-execute-p t)
is needed, resp. reset to default - last line in example. Maybe check settings via M-x customize ... also, which may conflict with setq from init.
When selecting shell for execution: a shebang in buffer might override default py-shell-name.
When shebang should be ignored, use
(setq py-force-py-shell-name-p t)
See menu
Python/Customize/Switches/Interpreter
for an easy way to change this value during current session.

I'm having issues setting up ansi-term in emacs [duplicate]

I use ansi-term for my normal terminal sessions. I tend to use unicode characters in my prompt to do things like set the trailing character based on the type of source control I'm using.
I use the character "±" as my prompt for git repositories.
In Emacs' ansi-term, my prompt isn't rendered as unicode, and shows as "\302\261". Displaying the current coding system shows that it defaults to utf-8-unix for input to the process, but I get raw binary as the decoding output. I can hit C-c RET p to change the encoding and decoding coding systems. I'm drawing a blank as to how to set this automatically when I start a terminal? I've tried adding to term-mode-hook to set the buffer's coding system to no avail. I think I've found what I'm looking for in term.el, but I don't care to tweak the distribution elisp, and it appears the raw binary was added to fix a bug somewhere else.
EDIT: This was unclear originally. I'm having issues setting the default process coding system for ansi-term running under Cocoa-ized Emacs 23.3 on MacOS. Emacs itself isn't running in a terminal, my terminal is running in Emacs.
The following worked for me:
(add-hook 'term-exec-hook
(function
(lambda ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))))
ansi-term seems to ignore the default-process-coding-system variable, so I had to set it buffer-locally after it executes my shell.
After getting a better understanding of term.el, the following works:
(defadvice ansi-term (after advise-ansi-term-coding-system)
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(ad-activate 'ansi-term)
Trying this with term-mode-hook is broken because in term.el, term-mode-hook is called before switching to the terminal buffer, so set-buffer-process-coding-system breaks due to the lack of a process associated with the buffer.
Try
(set-terminal-coding-system 'utf-8-unix)
That's C-x RET t not C-x RET p.
So C-x RET p helps?
Unless C-h v default-process-coding-system is (utf-8-unix . utf-8-unix) try
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))

Aquamacs 2.4 -- WordWrap / Visual Line Mode -- bug workaround?

Has anyone found a workaround to the inability of Aquamacs 2.4 to correctly WordWrap at the window boundary?
The modes I use most often are text-mode and latex-mode.
I've removed the built-in hooks of text mode to try and isolate the bug and come up with a workaround:
(remove-hook 'text-mode-hook 'smart-spacing-mode)
(remove-hook 'text-mode-hook 'auto-detect-wrap)
The following code gives me a fancy indicator in the status bar WordWrap, but words are still fragmented at the window boundary.
(add-hook 'latex-mode-hook 'set-word-wrap)
(add-hook 'text-mode-hook 'set-word-wrap)
The following code gives me a pretty status bar indicator of vl WordWrap, but the words are still fragmented at the window boundary.
(setq-default global-visual-line-mode t)
The following code seems to have no appreciable effect:
(setq longlines-wrap-follows-window-size t)
I've really never seen this feature working, so I'm not sure it is even possible with Aquamacs 2.4.
The expected behavior is that words should stay together by automatically wrapping to the next line at the window boundary. As I resize the window, this should happen on the fly. As I type a line, this should happen automatically when I reach the window edge.
Just in case this is a conflict, I'll mention that I have Yasnippets, local and global whitespace, and flyspell all enabled. I also have line numbers, highlight the current line, size indication, and column numbers.
Perhaps someone could just give me the name of the el / elc file that is responsible for this behavior, and I'll take it from a 24.3 version and paste it into Aquamacs 2.4. I am primarily interested in this version because of the ease of which it handles LaTeX documents.
Have you tried in the "Options" menu the submenu "Line wrapping in this buffer"?
Alternatively,
(add-hook 'text-mode-hook #'visual-line-mode)
or
(global-visual-line-mode 1)
The nightly builds of Emacs / Aquamacs have fixed this issue.

Use semicolon in global-set-key for function in .emacs

I am trying to set [Ctrl]-[;] as a keybinding in my .emacs like this
(global-set-key "\C-;" 'comment-or-uncomment-region)
however it doesn't work when I try (i don't get any error messages, it just has no effect). It will work though if i try a normal character (such as setting it to "\C-p").
I have also tried
(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
but I don't like this option because for me it doesn't work when i run "emacs -nw". Any thoughts on how I can do this?
EDIT:
When I run C-hcC-; in emacs -nw I get the output:
; runs the command self-insert-command
which is exactly the same as when I run C-hc; in emacs -nw
So I believe phils is right, that it is a terminal problem, because emacs never actually sees C-;, it only sees ;
Indeed C-; is typically not something your terminal is able to send to an underlying application like Emacs (so it works under a GUI but not in a terminal). But I wonder: why do you need such a binding anyway, given that M-; is already bound to comment-dwim which does comment/uncomment the region when the region is selected, so it provides a superset of comment-or-uncomment-region.
Using (kbd "C-;") is absolutely fine and correct.
I suspect when you type C-; when running emacs -nw, your terminal is not actually sending anything to Emacs.
So your problem is more likely to be a question of how to get your terminal to send C-; to Emacs (or alternatively how to get Emacs to recognise the sequence which is sent).
If you run emacs -Q -nw and type C-hcC-;, do you get a "C-; is undefined" message?
Assuming that it is a terminal issue, here are some related Q&As which may point you in the right direction, but it's going to depend upon the particular terminal you are using.
Binding M-<up> / M-<down> in Emacs 23.1.1
Send "C-(" to Emacs in VT100/xterm terminal (Mac OS X's Terminal)?
How does one send S-RET to Emacs in a terminal?
emacs -nw issues with cscope and terminals

Unicode characters in emacs term-mode

I use ansi-term for my normal terminal sessions. I tend to use unicode characters in my prompt to do things like set the trailing character based on the type of source control I'm using.
I use the character "±" as my prompt for git repositories.
In Emacs' ansi-term, my prompt isn't rendered as unicode, and shows as "\302\261". Displaying the current coding system shows that it defaults to utf-8-unix for input to the process, but I get raw binary as the decoding output. I can hit C-c RET p to change the encoding and decoding coding systems. I'm drawing a blank as to how to set this automatically when I start a terminal? I've tried adding to term-mode-hook to set the buffer's coding system to no avail. I think I've found what I'm looking for in term.el, but I don't care to tweak the distribution elisp, and it appears the raw binary was added to fix a bug somewhere else.
EDIT: This was unclear originally. I'm having issues setting the default process coding system for ansi-term running under Cocoa-ized Emacs 23.3 on MacOS. Emacs itself isn't running in a terminal, my terminal is running in Emacs.
The following worked for me:
(add-hook 'term-exec-hook
(function
(lambda ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))))
ansi-term seems to ignore the default-process-coding-system variable, so I had to set it buffer-locally after it executes my shell.
After getting a better understanding of term.el, the following works:
(defadvice ansi-term (after advise-ansi-term-coding-system)
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix))
(ad-activate 'ansi-term)
Trying this with term-mode-hook is broken because in term.el, term-mode-hook is called before switching to the terminal buffer, so set-buffer-process-coding-system breaks due to the lack of a process associated with the buffer.
Try
(set-terminal-coding-system 'utf-8-unix)
That's C-x RET t not C-x RET p.
So C-x RET p helps?
Unless C-h v default-process-coding-system is (utf-8-unix . utf-8-unix) try
(setq default-process-coding-system '(utf-8-unix . utf-8-unix))