Getting Unicode in copy and paste within emacs - unicode

I try to do copy and paste in emacs on a Mac but in the most recent version of gnu emacs (24.3.1) this does not work. Instead of Tesnière I get Tesni\350re. Is there some switch?

You could do the following:
C-x RET x
then select utf-8 (which is probably what you want)
C-x RET x (translated from C-x x) runs the command
set-selection-coding-system (found in global-map), which is an
interactive compiled Lisp function in `mule.el'.
It is bound to C-x RET x,
.
(set-selection-coding-system CODING-SYSTEM)
Make CODING-SYSTEM used for communicating with other X clients.
When sending or receiving text via cut_buffer, selection, and clipboard,
the text is encoded or decoded by CODING-SYSTEM.

Related

emacs - Kill the buffer with terminal emulator

I am aware of this option:
Kill the *terminal* buffer with C-d
But I am still a newbie in emacs, what is the original method to do this? I tried C-x k but it doesn't like it, C-x C-c kills all my windows and buffers...
I assume you're using a buffer in term-mode (M-x term). term-mode is a bit different than most modes in that it has two submodes, char and line. In char mode it acts more like a terminal than emacs, as in a lot of normal keybinds are not available. Put it in line mode with C-c C-j to put it in line mode, then you can run most normal keybinds including C-x k. You can put it back into char mode with C-c C-k.
I use the multi-term package, which I think has better defaults than plain term-mode and as the name suggests makes it easy to have many terminal buffers.

Use Ctrl-X commands while in terminal in emacs?

When I'm running a terminal inside emacs (with M-x term) I can't seem to use commands that start with C-X, such as, say C-x o to switch panes or C-x C-c to exit. Instead it seems that the terminal itself is receiving these C-x signals. By contrast, C-c commands are received by emacs itself. How can I change this behavior?
term has two different input submodes. In the default (character) mode, C-x simply transmits a literal control x to the terminal. Many keybindings which are normally available in the C-x map are instead now in the C-c map, so you can switch to a different buffer in the other window with C-c 4 b. Or you can switch to line mode with C-c C-j (and back to character mode with C-c C-k).
See also the documentation.

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))

On emacs, I can't jump to tags in GTAGS SELECT buffer

On emacs, I can't jump to tags in GTAGS SELECT buffer. I get "Buffer is read-only: <buffer *GTAGS SELECT*>" error when I press return.
Mac OS X 10.8.1
Emacs 24.2
gtags GNU GLOBAL 6.2.4 (installed by homebrew)
gtags.el 3.3 (installed by package.el)
"C-h k <return>" in GTAGS SELECT buffer showed the following message:
RET (translated from <return>) runs the command newline, which is an
interactive compiled Lisp function in `simple.el'.
It is bound to RET.
(newline &optional ARG)
Insert a newline, and move to left margin of the new line if it's blank.
If `use-hard-newlines' is non-nil, the newline is marked with the
text-property `hard'.
With ARG, insert that many newlines.
Call `auto-fill-function' if the current column number is greater
than the value of `fill-column' and ARG is nil.
I don't use GNU global, however a quick google search hints that downgrading the gtags.el to an older version might help:
http://lists.gnu.org/archive/html/help-global/2011-12/msg00003.html
EDIT: (cannot add comment to first post so editing here)
as Arne said, the RET key is not bound correctly for some reason. For gtags-select-mode RET should be bound to (gtags-select-tag) instead.

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))